Toggle
A two-state button that can be on or off.
Loading...
Loading code...
Installation
Usage
import { Toggle } from "@/components/ui/toggle"<Toggle>Toggle</Toggle>Examples
Outline
Loading...
Loading code...
With Icon
Loading...
Loading code...
Small Size
Loading...
Loading code...
Large Size
Loading...
Loading code...
Disabled
Loading...
Loading code...
Icon Group
Loading...
Loading code...
Comparing with Radix / shadcn
If you’re already familiar with Radix UI and shadcn/ui, this guide highlights the small differences and similarities so you can get started with ui/topia quickly.
Quick Checklist
- If you used
asChildon parts, switch to therenderprop
Additional Notes
Size Comparison
ui/topia toggle sizes are more compact compared to shadcn/ui, making them better suited for dense applications:
| Size | Height (shadcn/ui) | Height (ui/topia) |
|---|---|---|
sm | 32px | 28px |
default | 36px | 32px |
lg | - | 36px |
So, for example, if you were using the default size in shadcn/ui and you want to preserve the original height, you should use the lg size in ui/topia.