Examples
Basic
| Prop | Default | Type | Description |
|---|---|---|---|
items | [] | Array<T> | The items to display in the toggle group. |
defaultValue | - | AcceptableValue | Array<AcceptableValue> | The default active value of the item(s). |
disabled | false | boolean | When set to true, disables user interaction with the toggle group and all its items. |
modelValue | - | AcceptableValue | Array<AcceptableValue> | The controlled value of the active item(s), which can be bind using v-model. |
name | - | string | The name of the field. Submitted with its owning form as part of a name/value pair. |
orientation | - | vertical | horizontal | The orientation of the component, which determines how focus moves. |
required | - | boolean | When true, indicates that the user must set the value before the owning form can be submitted. |
rovingFocus | true | boolean | When false, navigating through the items using arrow keys will be disabled. |
type | - | single | multiple | Determines whether a "single" or "multiple" items can be selected at a time. |
The T generic extends the array of NToggleGroupItemProps, which means that you can use all the props and events from the NToggleGroupItem component that extends of Toggle component.
Orientation
| Prop | Default | Type | Description |
|---|---|---|---|
orientation | horizontal | horizontal, vertical | Set the orientation of the toggle-group. |
Type
| Prop | Default | Type | Description |
|---|---|---|---|
type | - | single, multiple | Set the type of the toggle-group. |
What is also important is that you can not explicitly define type through prop, but use a reactive model with an array of values or a single value, and ToggleGroup automatically will understand which type you want to use.
Variant and Color
| Prop | Default | Type | Description |
|---|---|---|---|
toggle-on | soft-accent | {variant}-{color} | Change the color of the toggle when item is on. |
toggle-off | ghost-gray | {variant}-{color} | Change the color of the toggle when item is off. |
You can also use the prop _toggleGroupItem by specifying options for each element, or you can directly use the props in the object of each element.
Size
Adjust the toggle-group size without limits. Use breakpoints (e.g., sm:sm, xs:lg) for responsive sizes or states (e.g., hover:lg, focus:3xl) for state-based sizes.
| Prop | Default | Type | Description |
|---|---|---|---|
size | sm | string | Adjusts the overall size of the toggle-group component. |
_toggleGroupItem.size | sm | string | Customizes the size of each item within the toggle-group. |
Slots
It is important that you can also use dynamic slots to customize individual parts of ToggleGroup. You also have the option for item to use the slot field in the object itself for further dynamic binding.
| Name | Props | Description |
|---|---|---|
default | modelValue | The default slot, overrides everything. |
#{{ item.slot }} | item, value | The item dynamic slot. |
item | item, active | The item static slot. |
Custom Rendering
Use the default slot for full control over the toggle-group's structure. This allows you to compose the toggle-group using its individual sub-components (like NToggleGroup, NToggleGroupItem, listed in the Components section), similar to libraries like shadcn/ui.