Components
BaseToggleGroup
A segmented control for views, periods and short options, with icons and counters.
components/ui/inputs/BaseToggleGroup.vue
View in the demo
Example
Views with counters and custom items
compact fit is the views bar of every list (orders, customers, invoices…). countColor highlights an urgent count. The #item slot renders anything inside a segment.
API
Props
Name | Type | Default | Description |
|---|---|---|---|
itemsrequired | BaseToggleItem[] | — | The segments, each { title, value, icon?, count?, countColor?, disabled? }. With an icon, only the icon shows and the title becomes its tooltip. |
mandatory | boolean | false | Prevents clearing the selection. |
size | string | "small" | The Vuetify button size. |
compact | boolean | false | Lower segments for toolbars. |
fit | boolean | false | Sizes the group to its content instead of the full width. |
collapse | boolean | false | Renders a select with the same items (counts in brackets) instead of the segments below 600px and whenever the segments do not fit their container, so long view lists never clip or scroll. It switches back to segments when the container grows. |
label | string | — | The visible label above the field, linked to it with for and aria-labelledby. |
input-id | string | — | A fixed id for the input. One is generated with useId() when you leave it out. |
optional | boolean | — | Adds “(optional)” after the label. Never mark required fields. |
info | BaseInputInfo | — | A help popover next to the label: a text or a list of { title, text }. |
v-model | BaseSelectionValue | null | null | The selected value. |
Slots
Name | Slot props | Description |
|---|---|---|
#item | { item: BaseToggleItem; active: boolean; } | The content of a segment, with item and active. |
Events
Name | Payload | Description |
|---|---|---|
@update:modelValue | [value: BaseSelectionValue | null] | — |
Accessibility
Each segment is a button with aria-pressed. Icon-only segments get their title as aria-label. Give the group a label or an aria-label.