Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

Toggle

A formatting option with an observable pressed state.

Preview

Live preview

Changes apply to this preview only.

saved

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.

Variants

Enumerated from toggleVariantMap. Each row shows the resting and pressed states.

Open preview

Sizes

Enumerated from toggleVariantMap: sm, md and lg.

Open preview

Examples

Real compositions built from the same parts.

Open preview

Usage

Use pressed state for an on/off command, rather than modelling it as navigation.

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.

PimoluToggleProps

Type source
PimoluToggleProps public API
NameTypeDefaultDescription
pressedboolean | undefined—Controlled pressed state.
defaultPressedboolean | undefinedfalseInitial pressed state when uncontrolled.
onPressedChange((pressed: boolean) => void) | undefined—Called with the next pressed state.
variant"outline" | "ghost" | "default" | undefined"default"Visual treatment. Defaults to "default".
size"sm" | "md" | "lg" | undefined"md"Height and font size. Defaults to "md".
childrenRequiredReactNode—Public Pimolu prop; see the source declaration for details.
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<HTMLButtonElement> | undefined—Standard React/HTML attribute.
disabledboolean | undefinedfalseStandard React/HTML attribute.
namestring | undefined—Standard React/HTML attribute.
type"submit" | "reset" | "button" | undefined"button"Standard React/HTML attribute.
valuestring | number | readonly string[] | undefined—Standard React/HTML attribute.
pressed

boolean | undefined

No default extracted.

Controlled pressed state.

defaultPressed

boolean | undefined

Default: false

Initial pressed state when uncontrolled.

onPressedChange

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

No default extracted.

Called with the next pressed state.

variant

"outline" | "ghost" | "default" | undefined

Default: "default"

Visual treatment. Defaults to "default".

size

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

Default: "md"

Height and font size. Defaults to "md".

childrenRequired

ReactNode

No default extracted.

Public Pimolu prop; see the source declaration for details.

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<HTMLButtonElement> | 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.

type

"submit" | "reset" | "button" | undefined

Default: "button"

Standard React/HTML attribute.

value

string | number | readonly string[] | undefined

No default extracted.

Standard React/HTML attribute.

Accessibility

  • Keep the accessible name stable as aria-pressed changes.
Read the accessibility guide →