Toggle Group
Generated from public Vue/TypeScript exports by
pnpm docs:generate. Edit source comments and stories to update this reference. Types describe the declared API; browser/device constraints are covered in the guides. This catalog reflects source commitfc6bfb108634735f1657e533206c3f8702ad357d; match your installed package and typed manifest before using an export. Source review does not establish registry-release availability.
ToggleGroup
import { ToggleGroup } from '@gxp-dev/app-ui'
Props
| Name | Type | Required / default | Description |
|---|---|---|---|
variant | "default" | "outline" | null | undefined | — | — |
size | "default" | "sm" | "lg" | null | undefined | — | — |
rovingFocus | boolean | undefined | — | When false, navigating through the items using arrow keys will be disabled. |
disabled | boolean | undefined | — | When true, prevents the user from interacting with the toggle group and all its items. |
orientation | DataOrientation | undefined | — | The orientation of the component, which determines how focus moves: horizontal for left/right arrows and vertical for up/down arrows. |
dir | Direction | undefined | — | The reading direction of the combobox when applicable. <br> If omitted, inherits globally from ConfigProvider or assumes LTR (left-to-right) reading mode. |
loop | boolean | undefined | — | When loop and rovingFocus is true, keyboard navigation will loop from last item to first, and vice versa. |
asChild | boolean | undefined | — | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. |
as | AsTag | Component | undefined | — | The element or component this component should render as. Can be overwritten by asChild. |
name | string | undefined | — | The name of the field. Submitted with its owning form as part of a name/value pair. |
required | boolean | undefined | — | When true, indicates that the user must set the value before the owning form can be submitted. |
type | SingleOrMultipleType | undefined | — | Determines whether a "single" or "multiple" items can be selected at a time. This prop will overwrite the inferred type from modelValue and defaultValue. |
modelValue | AcceptableValue | AcceptableValue[] | undefined | — | The controlled value of the active item(s). Use this when you need to control the state of the items. Can be binded with v-model |
defaultValue | AcceptableValue | AcceptableValue[] | undefined | — | The default active value of the item(s). Use when you do not need to control the state of the item(s). |
Events
| Name | Type | Required / default | Description |
|---|---|---|---|
update:modelValue | [payload: AcceptableValue | AcceptableValue[]] | — | — |
Slots
| Name | Type | Required / default | Description |
|---|---|---|---|
default | {} | — | — |
Examples
These are authored Storybook excerpts, not complete standalone modules. Relative imports refer to the story file; in an app import public components from @gxp-dev/app-ui. Default meta arguments are applied before each story.
Single
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-vue-next'
import { ToggleGroup, ToggleGroupItem } from '.'
{
render: () => ({
components: { ToggleGroup, ToggleGroupItem, AlignLeft, AlignCenter, AlignRight },
setup() {
const alignment = ref('left')
return { alignment }
},
template: `
<ToggleGroup type="single" v-model="alignment">
<ToggleGroupItem value="left" aria-label="Align left">
<AlignLeft class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="center" aria-label="Align center">
<AlignCenter class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="right" aria-label="Align right">
<AlignRight class="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>
`,
}),
}
Multiple
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-vue-next'
import { ToggleGroup, ToggleGroupItem } from '.'
{
render: () => ({
components: { ToggleGroup, ToggleGroupItem, Bold, Italic, Underline },
setup() {
const formatting = ref(['bold'])
return { formatting }
},
template: `
<ToggleGroup type="multiple" v-model="formatting">
<ToggleGroupItem value="bold" aria-label="Toggle bold">
<Bold class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="italic" aria-label="Toggle italic">
<Italic class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="underline" aria-label="Toggle underline">
<Underline class="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>
`,
}),
}
Outline
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-vue-next'
import { ToggleGroup, ToggleGroupItem } from '.'
{
render: () => ({
components: { ToggleGroup, ToggleGroupItem, Bold, Italic, Underline },
setup() {
const formatting = ref([])
return { formatting }
},
template: `
<ToggleGroup type="multiple" variant="outline" v-model="formatting">
<ToggleGroupItem value="bold" aria-label="Toggle bold">
<Bold class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="italic" aria-label="Toggle italic">
<Italic class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="underline" aria-label="Toggle underline">
<Underline class="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>
`,
}),
}
ToggleGroupItem
import { ToggleGroupItem } from '@gxp-dev/app-ui'
Props
| Name | Type | Required / default | Description |
|---|---|---|---|
variant | "default" | "outline" | null | undefined | — | — |
size | "default" | "sm" | "lg" | null | undefined | — | — |
value | AcceptableValue | Required | A string value for the toggle group item. All items within a toggle group should use a unique value. |
asChild | boolean | undefined | — | Change the default rendered element for the one passed as a child, merging their props and behavior. Read our Composition guide for more details. |
as | AsTag | Component | undefined | — | The element or component this component should render as. Can be overwritten by asChild. |
disabled | boolean | undefined | — | When true, prevents the user from interacting with the toggle. |
Slots
| Name | Type | Required / default | Description |
|---|---|---|---|
default | {} | — | — |
Examples
These are authored Storybook examples. Relative imports refer to the story file; in an app import public components from @gxp-dev/app-ui. Default meta arguments are applied before each story.
Single
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-vue-next'
import { ToggleGroup, ToggleGroupItem } from '.'
{
render: () => ({
components: { ToggleGroup, ToggleGroupItem, AlignLeft, AlignCenter, AlignRight },
setup() {
const alignment = ref('left')
return { alignment }
},
template: `
<ToggleGroup type="single" v-model="alignment">
<ToggleGroupItem value="left" aria-label="Align left">
<AlignLeft class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="center" aria-label="Align center">
<AlignCenter class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="right" aria-label="Align right">
<AlignRight class="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>
`,
}),
}
Multiple
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-vue-next'
import { ToggleGroup, ToggleGroupItem } from '.'
{
render: () => ({
components: { ToggleGroup, ToggleGroupItem, Bold, Italic, Underline },
setup() {
const formatting = ref(['bold'])
return { formatting }
},
template: `
<ToggleGroup type="multiple" v-model="formatting">
<ToggleGroupItem value="bold" aria-label="Toggle bold">
<Bold class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="italic" aria-label="Toggle italic">
<Italic class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="underline" aria-label="Toggle underline">
<Underline class="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>
`,
}),
}
Outline
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { AlignCenter, AlignLeft, AlignRight, Bold, Italic, Underline } from 'lucide-vue-next'
import { ToggleGroup, ToggleGroupItem } from '.'
{
render: () => ({
components: { ToggleGroup, ToggleGroupItem, Bold, Italic, Underline },
setup() {
const formatting = ref([])
return { formatting }
},
template: `
<ToggleGroup type="multiple" variant="outline" v-model="formatting">
<ToggleGroupItem value="bold" aria-label="Toggle bold">
<Bold class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="italic" aria-label="Toggle italic">
<Italic class="h-4 w-4" />
</ToggleGroupItem>
<ToggleGroupItem value="underline" aria-label="Toggle underline">
<Underline class="h-4 w-4" />
</ToggleGroupItem>
</ToggleGroup>
`,
}),
}