BNA

BNA UI
26

A two-state button that can be either on or off.

Installation

pnpm dlx bna-ui add toggle

Usage

import {
  Toggle,
  ToggleGroup,
  ToggleGroupSingle,
  ToggleGroupMultiple,
} from '@/components/ui/toggle';
<Toggle pressed={pressed} onPressedChange={setPressed}>
  <Bold size={16} />
</Toggle>

Examples

Default

Variants

Sizes

With Text

Disabled

Toggle Group Single

Toggle Group Multiple

Toggle Group Vertical

Toggle Group Outline

API Reference

Toggle

A two-state button that can be either on (pressed) or off.

PropTypeDefaultDescription
childrenReactNode-The content to display inside the toggle.
pressedbooleanfalseWhether the toggle is pressed (on).
onPressedChange(pressed: boolean) => void-Callback fired when the pressed state changes.
variant'default' | 'outline''default'The visual variant of the toggle.
size'default' | 'icon''icon'The size of the toggle.
disabledbooleanfalseWhether the toggle is disabled.
styleViewStyle-Additional styles to apply to the toggle container.
textStyleTextStyle-Additional styles to apply to the toggle text.

ToggleGroup

A set of two-state buttons that can be toggled on or off.

PropTypeDefaultDescription
type'single' | 'multiple''single'Whether to allow single or multiple selection.
valuestring | string[]-The controlled value(s) of the toggle group.
onValueChange(value: string | string[]) => void-Callback fired when the value changes.
itemsToggleGroupItem[]-Array of toggle items to render.
variant'default' | 'outline''default'The visual variant of the toggles.
size'default' | 'icon''default'The size of the toggles.
disabledbooleanfalseWhether the entire group is disabled.
styleViewStyle-Additional styles to apply to the group container.
orientation'horizontal' | 'vertical''horizontal'The orientation of the toggle group.

ToggleGroupItem

Configuration for individual items in a toggle group.

PropTypeDefaultDescription
valuestring-The unique value for this toggle item.
labelstring-The text label for this toggle item.
iconReact.ComponentType<LucideProps>-Optional icon component to display.
disabledbooleanfalseWhether this specific item is disabled.

ToggleGroupSingle

Convenience component for single-selection toggle groups.

PropTypeDefaultDescription
valuestring-The controlled value of the selected toggle.
onValueChange(value: string) => void-Callback fired when the selected value changes.
...propsOmit<ToggleGroupProps, ...>-All other ToggleGroup props except type and callbacks.

ToggleGroupMultiple

Convenience component for multiple-selection toggle groups.

PropTypeDefaultDescription
valuestring[]-The controlled array of selected toggle values.
onValueChange(value: string[]) => void-Callback fired when the selected values change.
...propsOmit<ToggleGroupProps, ...>-All other ToggleGroup props except type and callbacks.

Accessibility

The Toggle components are built with accessibility in mind:

  • Uses TouchableOpacity for proper touch handling
  • Supports disabled state with visual feedback
  • Proper color contrast for different states
  • Screen reader compatible with semantic structure
  • Keyboard navigation support through native React Native components