bit Bheadless

Toggle / Toggle Group

Two-state buttons on their own, or grouped for formatting, alignment and view switchers.

Implementation: CSS Tailwind

Toggle button

BitBhToggle is the APG Button pattern's toggle variant: a native <button> with aria-pressed and data-state="on|off". Space / Enter or a click flips it. Use @bind-Pressed, DefaultPressed for uncontrolled use, and Disabled.

Muted: no

State-aware content with Template

When the content depends on the pressed state, use Template instead of child content — its context is the bool pressed state. Keep the label itself constant (APG): only the icon swaps here, aria-pressed conveys the state.

Multiple: text formatting

Type="BitBhToggleGroupType.Multiple" renders a role="group" of aria-pressed buttons bound with @bind-Values. The group is a single tab stop: ← / → move focus (wrapping), Home / End jump, Space / Enter toggle.

The quick brown fox jumps over the lazy dog.

Values: bold

Single: alignment

The default Type="BitBhToggleGroupType.Single" behaves like a radio group (role="radiogroup" of role="radio" items with aria-checked); the pressed item is the tab stop. Clicking the pressed item normally clears the value — AllowEmpty="false" keeps one alignment selected at all times.

Headless components ship behavior and accessibility, and leave every pixel of the presentation to you — so this paragraph can be aligned however you like.

Vertical orientation

Orientation="BitBhRovingOrientation.Vertical" switches navigation to ↑ / ↓ and sets data-orientation="vertical" for styling. This group is uncontrolled (DefaultValue) and each item's Template receives its pressed state to draw a check mark.

Disabled items

Disabled="true" on an item renders the native disabled attribute and data-disabled; arrow keys skip it. On the group it disables every item.

An unhandled error has occurred. Reload 🗙