BNA

BNA UI
26

A control that allows the user to toggle between checked and not checked states.

Installation

pnpm dlx bna-ui add switch

Usage

import { Switch } from '@/components/ui/switch';
<Switch
  label='Enable notifications'
  value={isEnabled}
  onValueChange={setIsEnabled}
/>

Examples

Default

Without Label

With Error State

Disabled State

Settings List

Custom Colors

API Reference

Switch

A toggle switch component with optional label and error states.

PropTypeDefaultDescription
labelstring-Optional label text for the switch.
errorstring-Error message to display (changes label color).
labelStyleTextStyle-Additional styles to apply to the label text.
valueboolean-The current state of the switch.
onValueChange(value: boolean) => void-Callback fired when the switch state changes.
disabledbooleanfalseWhether the switch is disabled.
...propsSwitchProps (from React Native)-All other React Native Switch props are supported.

Accessibility

The Switch component is built with accessibility in mind:

  • Uses native React Native Switch for optimal platform behavior
  • Supports screen reader announcements for state changes
  • Proper focus management and keyboard navigation
  • Color contrast meets accessibility standards
  • Label text is properly associated with the switch control
  • Error states provide clear feedback to assistive technologies