Installation
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
uvx django_shadcn@latest add toggle_group
Usage
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<c-toggle-group>
<c-toggle-group.item>Left</c-toggle-group.item>
<c-toggle-group.item>Center</c-toggle-group.item>
<c-toggle-group.item>Right</c-toggle-group.item>
</c-toggle-group>
Variant and size go on the group, not on each item.
Examples
Outline
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<c-toggle-group variant="outline">
<c-toggle-group.item>Left</c-toggle-group.item>
<c-toggle-group.item>Center</c-toggle-group.item>
<c-toggle-group.item>Right</c-toggle-group.item>
</c-toggle-group>
Sizes
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<c-toggle-group variant="outline" size="sm">...</c-toggle-group>
<c-toggle-group variant="outline" size="lg">...</c-toggle-group>
Spaced
copied = false, 2000)
"
:aria-label="copied ? 'Copied' : 'Copy code'"
class="absolute right-3 top-3 z-10 inline-flex size-7 items-center justify-center rounded-md border border-border bg-background text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
>
<c-toggle-group variant="outline" spacing="1">
<c-toggle-group.item>Left</c-toggle-group.item>
</c-toggle-group>
Notes
Radix hands variant and size down through React context. Cotton has no
equivalent, so the group styles its own children with [&>*] selectors. Two
data-* conditions on one element combine the way you would expect; two
group-data-* would chain into a descendant selector instead, which is why the
rules live on the group rather than on the item.
Each item keeps its own pressed state. Radix also offers single-selection mode,
where picking one clears the rest — that needs shared state and is not here yet.