Toggle Group
A toggle group is a segmented control for choosing exactly one value from a short list of mutually exclusive options.
Overview
Pass options (array of { value, label?, icon?, disabled? }) and bind modelValue as a single selected value. Set an option's icon to render a decorative Catnip icon before its visible label.
catnip-toggle-group also provides:
- Field label (prop or
labelslot), required / optional markers,infotooltip supporting-textbelow the group (validation, hints)appearance—default(white selected pill) oraccent(brand selected pill)size—morlsegment and label sizingrole="radiogroup"witharia-labelledby/aria-describedbywiring
Use catnip-radio-group when each option needs a full radio row with supporting text. Use catnip-tabs for navigation between views or panels.
Live example
Related
- Radio Group — Overview — labelled single-select with radio rows
- Tabs — Overview — navigation tabs
- Toggle — Overview — single on/off switch
Guidelines
When to use
| Pattern | Use |
|---|---|
catnip-toggle-group | Compact single-select from 2–5 short labels (Figma Toggle group). |
catnip-radio-group | Labelled single-select when each option needs supporting text or a full radio row. |
catnip-tabs | Navigation between views, panels, or routes. |
catnip-toggle | A single on/off setting. |
Binding
vue
<catnip-toggle-group
label="View"
appearance="accent"
size="l"
.options="options"
.modelValue="selected"
@update:modelValue="selected = $event.detail[0] ?? $event.detail"
/>js
const selected = ref("day");
const options = [
{ value: "day", label: "Day", icon: "clock" },
{ value: "week", label: "Week", icon: "calendar" },
{ value: "month", label: "Month", icon: "calendar-changes" }
];Bind .options and .modelValue on the host (see Component API). Toggling updates modelValue on the toggle group host.
Use the optional icon field when it helps users distinguish short choices. Each icon-bearing option still needs a text label; see What you own.
Variants
| Variant | Selected style |
|---|---|
default | White pill with bold dark text — use on neutral surfaces. |
accent | Brand purple pill with white text — use when the selection should draw more attention. |