Skip to main content
Version: v1 (Current)

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 commit fc6bfb108634735f1657e533206c3f8702ad357d; 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'

Repository source

Props​

NameTypeRequired / defaultDescription
defaultValueboolean | undefined—The state of the switch when it is initially rendered. Use when you do not need to control its state.
modelValueboolean | null | undefined—The controlled state of the switch. Can be bind as v-model.
disabledboolean | undefined—When true, prevents the user from interacting with the switch.
idstring | undefined——
valuestring | undefined—The value given as data when submitted with a name.
trueValueboolean | undefined—The value used when the switch is on. Defaults to true.
falseValueboolean | undefined—The value used when the switch is off. Defaults to false.
asChildboolean | 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.
asAsTag | Component | undefined—The element or component this component should render as. Can be overwritten by asChild.
namestring | undefined—The name of the field. Submitted with its owning form as part of a name/value pair.
requiredboolean | undefined—When true, indicates that the user must set the value before the owning form can be submitted.

Events​

NameTypeRequired / defaultDescription
update:modelValue[payload: boolean]——

Slots​

NameTypeRequired / defaultDescription
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>
`,
}),
}