Introduction
Components
- Accordion
- Action Sheet
- Alert
- Audio Player
- Audio Recorder
- Audio Waveform
- Avatar
- AvoidKeyboard
- Badge
- BottomSheet
- Button
- Camera
- Camera Preview
- Card
- Carousel
- Checkbox
- Collapsible
- Color Picker
- Combobox
- Date Picker
- File Picker
- Gallery
- Hello Wave
- Icon
- Image
- Input
- Input OTP
- Link
- MediaPicker
- Mode Toggle
- Onboarding
- ParallaxScrollView
- Picker
- Popover
- Progress
- Radio
- ScrollView
- SearchBar
- Separator
- Share
- Sheet
- Skeleton
- Spinner
- Switch
- Table
- Tabs
- Text
- Toast
- Toggle
- Video
- View
Charts
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.
Prop | Type | Default | Description |
---|---|---|---|
children | ReactNode | - | The content to display inside the toggle. |
pressed | boolean | false | Whether 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. |
disabled | boolean | false | Whether the toggle is disabled. |
style | ViewStyle | - | Additional styles to apply to the toggle container. |
textStyle | TextStyle | - | Additional styles to apply to the toggle text. |
ToggleGroup
A set of two-state buttons that can be toggled on or off.
Prop | Type | Default | Description |
---|---|---|---|
type | 'single' | 'multiple' | 'single' | Whether to allow single or multiple selection. |
value | string | string[] | - | The controlled value(s) of the toggle group. |
onValueChange | (value: string | string[]) => void | - | Callback fired when the value changes. |
items | ToggleGroupItem[] | - | 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. |
disabled | boolean | false | Whether the entire group is disabled. |
style | ViewStyle | - | 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.
Prop | Type | Default | Description |
---|---|---|---|
value | string | - | The unique value for this toggle item. |
label | string | - | The text label for this toggle item. |
icon | React.ComponentType<LucideProps> | - | Optional icon component to display. |
disabled | boolean | false | Whether this specific item is disabled. |
ToggleGroupSingle
Convenience component for single-selection toggle groups.
Prop | Type | Default | Description |
---|---|---|---|
value | string | - | The controlled value of the selected toggle. |
onValueChange | (value: string) => void | - | Callback fired when the selected value changes. |
...props | Omit<ToggleGroupProps, ...> | - | All other ToggleGroup props except type and callbacks. |
ToggleGroupMultiple
Convenience component for multiple-selection toggle groups.
Prop | Type | Default | Description |
---|---|---|---|
value | string[] | - | The controlled array of selected toggle values. |
onValueChange | (value: string[]) => void | - | Callback fired when the selected values change. |
...props | Omit<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