Switch

Toggle a single preference or setting on and off accessibly.

Preview

Usage

import { z } from 'zod'
import { AutoForm } from '@vitnode/core/components/form/auto-form'
import { AutoFormSwitch } from '@vitnode/core/components/form/fields/switch'
const formSchema = z.object({
  acceptTerms: z.boolean().refine((val) => val, {
    message: 'You must accept the terms and conditions',
  }),
})
<AutoForm
  formSchema={formSchema}
  fields={[
    {
      id: 'acceptTerms',
      component: (props) => (
        <AutoFormSwitch {...props} label="I accept the terms and conditions" />
      ),
    },
  ]}
/>
import { Switch } from '@vitnode/core/components/ui/switch';
<Switch checked={value} onCheckedChange={onChange} />

API Reference

Base UI - Switch