formsbeta

Switch

Switch component for Vellira applications.

Documentation
Preview
Live
Options

Usage

Import the component and configure it with the same props used in the playground.

tsx

Examples

Common patterns and practical usage examples.

Basic

Basic form control usage.

tsx

Disabled

Disabled state.

tsx

Selected

Selected state.

tsx

Required

Required form control.

tsx

API

Props available for the React Switch.

7 props
PropTypeDefaultDescription
accessibilityLabel
string-Accessible name announced by assistive technology.
checked
boolean-Controlled checked state.
defaultChecked
boolean-Initial checked state for uncontrolled usage.
disabled
boolean-Disables interaction.
required
boolean-Marks the control as required.
invalid
boolean-Marks the control as invalid.
onCheckedChange
((checked: boolean) => void)-Called when the checked state changes.

Accessibility

Guidance for accessible usage and interaction.

Accessible naming

Provide a visible label or another accessible name that clearly identifies the control.

State communication

Expose the current interactive state through the appropriate native semantics and keep it synchronized with the visual state.
checked

Disabled state

Disabled controls should remain identifiable while preventing interaction.
disabled

Required fields

Required state should be communicated semantically and not rely only on visual styling.
required

Keyboard and focus

Preserve expected keyboard interaction and visible focus behavior.

Related components

Explore components that are commonly used alongside this one.