Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

Switch

Controlled appearance preferences with supporting descriptions.

Preview

Live preview

Changes apply to this preview only.

Use a dark palette everywhere.
Match the operating system preference.

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Sizes

sm, md and lg.

Open preview

Variants

The color of the active track.

Open preview

States

Disabled, required and described switches.

Open preview

Usage

Use Switch for an immediately applied setting; keep persistence in the application.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluSwitchProps

Type source
PimoluSwitchProps public API
NameTypeDefaultDescription
size"sm" | "md" | "lg" | undefined"md"Visual size.
variant"primary" | "secondary" | "neutral" | "success" | "warning" | "danger" | undefined"primary"Active color.
labelstring | undefined—Visible accessible label.
descriptionstring | undefined—Additional descriptive text.
onCheckedChange((checked: boolean) => void) | undefined—Called when the checked state changes.
onChangeChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined—Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefined—Standard React/HTML attribute.
classNamestring | undefined—Standard React/HTML attribute.
styleCSSProperties | undefined—Standard React/HTML attribute.
aria-labelstring | undefined—Defines a string value that labels the current element.
onClickMouseEventHandler<HTMLInputElement> | undefined—Standard React/HTML attribute.
disabledboolean | undefinedfalseStandard React/HTML attribute.
namestring | undefined—Standard React/HTML attribute.
valuestring | number | readonly string[] | undefined—Standard React/HTML attribute.
requiredboolean | undefinedfalseStandard React/HTML attribute.
size

"sm" | "md" | "lg" | undefined

Default: "md"

Visual size.

variant

"primary" | "secondary" | "neutral" | "success" | "warning" | "danger" | undefined

Default: "primary"

Active color.

label

string | undefined

No default extracted.

Visible accessible label.

description

string | undefined

No default extracted.

Additional descriptive text.

onCheckedChange

((checked: boolean) => void) | undefined

No default extracted.

Called when the checked state changes.

onChange

ChangeEventHandler<HTMLInputElement, HTMLInputElement> | undefined

No default extracted.

Standard React/HTML attribute.

defaultValue

string | number | readonly string[] | undefined

No default extracted.

Standard React/HTML attribute.

className

string | undefined

No default extracted.

Standard React/HTML attribute.

style

CSSProperties | undefined

No default extracted.

Standard React/HTML attribute.

aria-label

string | undefined

No default extracted.

Defines a string value that labels the current element.

onClick

MouseEventHandler<HTMLInputElement> | undefined

No default extracted.

Standard React/HTML attribute.

disabled

boolean | undefined

Default: false

Standard React/HTML attribute.

name

string | undefined

No default extracted.

Standard React/HTML attribute.

value

string | number | readonly string[] | undefined

No default extracted.

Standard React/HTML attribute.

required

boolean | undefined

Default: false

Standard React/HTML attribute.

Accessibility

  • Give every setting a visible label and check checked/disabled states with keyboard input.
Read the accessibility guide →