Components
Toggle
A two-state button that stays pressed until it is pressed again.
Ombelle · light
Toggle
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 toggleAdds components/ui/toggle.tsx and installs react, @radix-ui/react-toggle, 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 { Toggle } from '@/components/ui/toggle'
export function Example(){return <div style={{ display: "flex", alignItems: "center", flexWrap: "wrap", gap: "0.75rem" }}><Toggle defaultPressed>Show grid</Toggle><Toggle variant="outline" aria-label="Pin preview">Pin</Toggle></div>}API and states
- API
- Toggle (variant default or outline, size sm, default or lg, pressed, defaultPressed, onPressedChange, disabled)
- Minimum states
- Off, on, hover, focus, disabled
- Native basis
- Radix Toggle; Base UI Toggle in the Base UI edition
- Styles
- Stable in Ombelle, Papier, Organic, Retro futurism, minimalist, neo-brutalism and flat, light and dark. Liquid glass: stable, accessibility not guaranteed.