Switch

Switch is a component used to toggle between on and off states.

Usage

import { Switch } from "@yamada-ui/react"
<Switch />

Change Variant

Change Size

Change Color Scheme

Change Label Position

Change Shape

Disable

Read-Only

Customize Icon

Customize Label

Control

Props

Accessibility

The Switch follows the WAI-ARIA - Switch Pattern for accessibility.

Keyboard Navigation

KeyDescriptionState
TabFocuses on a switch that is not disabled.-
SpaceToggles the state of the focused switch.-
EnterToggles the state of the focused switch when checkOnEnter is true.-

ARIA Roles and Attributes

ComponentRoles and AttributesUsage
Switchrole="switch"Indicates that this is a switch.
aria-checkedSets to "true" if the switch is on, and "false" if it is off.
aria-describedbyIf Switch is within a Field.Root and Field.Root has an errorMessage, helperMessage, or a Field.ErrorMessage, Field.HelperMessage, sets its id.
aria-disabledSets to "true" if disabled is set.
aria-invalidSets to "true" if invalid is set.
aria-readonlySets to "true" if readOnly is set.
aria-requiredSets to "true" if required is set.