Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Checkbox Group
- Collapsible
- Combobox
- Command
- Context Menu
- Date Picker
- Dialog
- Drawer
- Dropdown Menu
- Empty
- Field
- Fieldset
- Form
- Frame
- Group
- Input
- Input Group
- Kbd
- Label
- Menu
- Menubar
- Message
- Meter
- Number Field
- OTP Field
- Pagination
- Popover
- Preview Card
- Progress
- Questionnaire
- Radio Group
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Toolbar
- Tooltip
Shared
- Artifact
- Audio Player
- Canvas
- Chain of Thought
- Checkpoint
- Code Block
- Commit
- Connection
- Context
- Controls
- Edge
- Environment Variables
- Mic Selector
- Model Selector
- Node
- Node Toolbar
- Open in Chat
- Panel
- Plan
- Prompt Input
- Queue
- Reasoning
- Sandbox
- Schema Display
- Shimmer
- Snippet
- Sources
- Speech Input
- Stack Trace
- Suggestion
- Tool
- Transcription
- Web Preview
Hooks
Resources
Toggle
A two-state button that can be toggled on or off.
import { Toggle } from "@/components/ui/toggle";
export default function Particle() {
return <Toggle>Toggle</Toggle>;
}
Installation
pnpm dlx shadcn@latest add @frontal-labs/toggle
Usage
import { Toggle } from "@/components/ui/toggle";<Toggle>Toggle</Toggle>API Reference
Toggle
Styled wrapper for Toggle.Root from Base UI with variant and size options.
| Prop | Type | Default | Description |
|---|---|---|---|
variant | "default" | "outline" | "default" | Controls the toggle styling |
size | "default" | "sm" | "lg" | "default" | Controls the toggle size |
Examples
Outline
import { Toggle } from "@/components/ui/toggle";
export default function Particle() {
return <Toggle variant="outline">Outline Toggle</Toggle>;
}
With Icon
import { BoldIcon } from "lucide-react";
import { Toggle } from "@/components/ui/toggle";
export default function Particle() {
return (
<Toggle aria-label="Toggle bold" variant="outline">
<BoldIcon />
</Toggle>
);
}
Small Size
import { Toggle } from "@/components/ui/toggle";
export default function Particle() {
return (
<Toggle size="sm" variant="outline">
Small
</Toggle>
);
}
Large Size
import { Toggle } from "@/components/ui/toggle";
export default function Particle() {
return (
<Toggle size="lg" variant="outline">
Large
</Toggle>
);
}
Disabled
import { Toggle } from "@/components/ui/toggle";
export default function Particle() {
return (
<Toggle disabled variant="outline">
Disabled
</Toggle>
);
}
Icon Group
import { BoldIcon, ItalicIcon, UnderlineIcon } from "lucide-react";
import { Toggle } from "@/components/ui/toggle";
export default function Particle() {
return (
<div className="flex items-center gap-1">
<Toggle aria-label="Toggle bold" variant="outline">
<BoldIcon />
</Toggle>
<Toggle aria-label="Toggle italic" variant="outline">
<ItalicIcon />
</Toggle>
<Toggle aria-label="Toggle underline" variant="outline">
<UnderlineIcon />
</Toggle>
</div>
);
}