The Toggle component is a two-state button that allows users to toggle between states via an action.
When not to use
If you need to conditionally render content based on a binary condition, use the Show component.
import { ToggleParts } from '@cerberus/react'The Toggle component is unstyled to fit any scenario you may need.
You can utilize the primitive components or the css prop to customize the toggle.
| Component | Description |
|---|---|
| ToggleRoot | The context provider for the Toggle parts |
| ToggleIndicator | The indicator shown based on the toggle state |
The ToggleParts API is an Object containing the full family of components.
Note
It is best to only use the ToggleParts if you are building a custom solution. Importing Object based components will ship every property it includes into your bundle, regardless if you use it or not.
| Name | Description |
|---|---|
| Root | The ToggleRoot component which is the Provider for the family. |
| Indicator | The component which displays based on the pressed state. |
ToggleIndicator