Toggle
A toggleable button with active/inactive states
Source
LLM docs
Docs
Package
Usage
Toggle is a button that can be toggled between active and inactive states.
It is a polymorphic component and can be rendered as any element.
Controlled and uncontrolled
Use defaultActive to set the initial state of an uncontrolled Toggle,
active and onActiveChange props to control it.
Auto contrast
Set autoContrast prop to automatically adjust icon color based on the active toggle
background color, for example with variant="filled" and light colors.
Auto width
By default, Toggle renders as a square button. Set autoWidth to allow
the width to adjust to content.
Configurator
Accessibility
Toggle renders a button element with aria-pressed attribute that reflects the active state.
When using icon-only toggles, provide an aria-label prop so that screen readers can
announce the button purpose.
When Toggle is rendered as a non-button element (for example, component="a"), the disabled prop
sets aria-disabled, removes the element from the tab order and prevents clicks.