Switch
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.
Switch
import { Switch } from '@gxp-dev/app-ui'
Props
| Name | Type | Required / default | Description |
|---|---|---|---|
defaultValue | boolean | undefined | — | The state of the switch when it is initially rendered. Use when you do not need to control its state. |
modelValue | boolean | null | undefined | — | The controlled state of the switch. Can be bind as v-model. |
disabled | boolean | undefined | — | When true, prevents the user from interacting with the switch. |
id | string | undefined | — | — |
value | string | undefined | — | The value given as data when submitted with a name. |
trueValue | boolean | undefined | — | The value used when the switch is on. Defaults to true. |
falseValue | boolean | undefined | — | The value used when the switch is off. Defaults to false. |
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 | [payload: boolean] | — | — |
Slots
| Name | Type | Required / default | Description |
|---|---|---|---|
thumb | {} | — | — |
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 { Switch } from '.'
import { Label } from '../label'
{
render: (args) => ({
components: { Switch },
setup() {
return { args }
},
template: '<Switch v-bind="args" />',
}),
}
Checked
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { Switch } from '.'
import { Label } from '../label'
{
name: 'Checked',
render: () => ({
components: { Switch },
template: '<Switch :default-value="true" />',
}),
}
Disabled
import type { Meta, StoryObj } from '@storybook/vue3-vite'
import { Switch } from '.'
import { Label } from '../label'
{
name: 'Disabled',
render: () => ({
components: { Switch },
template: `
<div class="flex flex-col gap-4">
<Switch disabled />
<Switch disabled :default-value="true" />
</div>
`,
}),
}