Get Started
Components
- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Attachment
- Avatar
- Badge
- Breadcrumb
- Bubble
- Button
- Button Group
- Calendar
- Card
- Carousel
- Chart
- Checkbox
- Collapsible
- Combobox
- Command
- Confirm Dialog
- Container
- Context Menu
- Dialog
- Direction
- Drawer
- Dropdown Menu
- Empty
- Field
- Hover Card
- Input
- Input Group
- Input Number
- Input OTP
- Item
- Kbd
- Label
- Marker
- Menubar
- Message
- Message Scroller
- Native Select
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner
- Spinner
- Switch
- Table
- Tabs
- Tailwind Indicator
- Textarea
- Toggle
- Toggle Group
- Tooltip
import { Bold, Italic, Underline } from "lucide-react"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
export function ToggleGroupDemo() {Installation
pnpm slabui add toggle-group
Usage
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"<ToggleGroup type="single">
<ToggleGroupItem value="a">A</ToggleGroupItem>
<ToggleGroupItem value="b">B</ToggleGroupItem>
<ToggleGroupItem value="c">C</ToggleGroupItem>
</ToggleGroup>Composition
Use the following composition to build a ToggleGroup:
ToggleGroup
โโโ ToggleGroupItem
โโโ ToggleGroupItemOutline
Use variant="outline" for an outline style.
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
export function ToggleGroupOutline() {
return (
<ToggleGroup variant="outline" defaultValue={["all"]}>Size
Use the size prop to change the size of the toggle group.
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
export function ToggleGroupSizes() {
return (
<div className="flex flex-col gap-4">Spacing
Use spacing to add spacing between toggle group items.
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
export function ToggleGroupSpacing() {
return (
<ToggleGroup size="sm" defaultValue={["top"]} variant="outline" spacing={2}>Vertical
Use orientation="vertical" for vertical toggle groups.
import { BoldIcon, ItalicIcon, UnderlineIcon } from "lucide-react"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
export function ToggleGroupVertical() {Disabled
import { Bold, Italic, Underline } from "lucide-react"
import { ToggleGroup, ToggleGroupItem } from "@/components/ui/toggle-group"
export function ToggleGroupDisabled() {Custom
A custom toggle group example.
Use font-normal to set the font weight.
"use client"
import * as React from "react"
import { Field, FieldDescription, FieldLabel } from "@/components/ui/field"API Reference
See the Base UI Toggle Group documentation.