Toggle
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.
Toggle
import { Toggle } from '@gxp-dev/app-ui'
Props
| Name | Type | Required / default | Description |
|---|---|---|---|
variant | "default" | "outline" | null | undefined | — | — |
size | "default" | "sm" | "lg" | null | undefined | — | — |
defaultValue | boolean | undefined | — | The pressed state of the toggle when it is initially rendered. Use when you do not need to control its open state. |
modelValue | boolean | null | undefined | — | The controlled pressed state of the toggle. Can be bind as v-model. |
disabled | boolean | undefined | — | When true, prevents the user from interacting with the toggle. |
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. |
Events
| Name | Type | Required / default | Description |
|---|---|---|---|
update:modelValue | [value: boolean] | — | — |
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.
Default
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { Bold, Italic } from 'lucide-vue-next'
import { Toggle } from '.'
{
render: (args) => ({
components: { Toggle, Bold },
setup() {
const pressed = ref(false)
return { args, pressed }
},
template: `
<Toggle v-bind="args" v-model="pressed" aria-label="Toggle bold">
<Bold class="h-4 w-4" />
</Toggle>
`,
}),
}
Outline
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { Bold, Italic } from 'lucide-vue-next'
import { Toggle } from '.'
{
render: () => ({
components: { Toggle, Italic },
setup() {
const pressed = ref(false)
return { pressed }
},
template: `
<Toggle variant="outline" v-model="pressed" aria-label="Toggle italic">
<Italic class="h-4 w-4" />
</Toggle>
`,
}),
}
Sizes
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { ref } from 'vue'
import { Bold, Italic } from 'lucide-vue-next'
import { Toggle } from '.'
{
render: () => ({
components: { Toggle, Bold },
template: `
<div class="flex items-center gap-4">
<Toggle size="sm" aria-label="Toggle bold (small)">
<Bold class="h-4 w-4" />
</Toggle>
<Toggle size="default" aria-label="Toggle bold (default)">
<Bold class="h-4 w-4" />
</Toggle>
<Toggle size="lg" aria-label="Toggle bold (large)">
<Bold class="h-4 w-4" />
</Toggle>
</div>
`,
}),
}