Components
Switch
A Radix switch for on/off settings.
Ombelle · light
Installation
Run in a project initialized with an Ombelle preset (see Get started). The component uses the saved project preset. Run the command from your app folder; it shows the changes and asks before writing.
pnpm dlx @ombelle-ui/cli@1.1.2 add switchAdds components/ui/switch.tsx and installs react, @radix-ui/react-switch, clsx, tailwind-merge with lifecycle scripts disabled. This is a client component.
In a liquid glass project the plan adds a notice that accessibility is not guaranteed, because text contrast depends on the background behind the glass.
Usage
example.tsx
import { Switch, SwitchThumb } from '@/components/ui/switch'
export function NotificationSetting() {
return (
<>
<label htmlFor="notifications">Enable notifications</label>
<Switch id="notifications" name="notifications" value="enabled">
<SwitchThumb />
</Switch>
</>
)
}API and states
- API
- Switch (checked, onCheckedChange, name, value, size default or sm), SwitchThumb
- Minimum states
- Off, on, focus, disabled
- Native basis
- Radix primitive with switch semantics
- Styles
- Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.