ToggleButton
allows users to toggle a selection on or off, for example switching between two states or modes.
Import
import { ToggleButton } from '@contentful/f36-components';// orimport { ToggleButton } from '@contentful/f36-button';
Examples
Basic
Example of simple usage:
States
Example of active and disabled toggle buttons:
Grouped
You can group several ToggleButtons
using ButtonGroup
component.
Props (API reference)
- Name
aria-label
DescriptionAria label is required when using icon only
string - Name
children
ReactNode - Name
className
DescriptionCSS class to be appended to the root element
string - Name
icon
DescriptionExpects any of the icon components
ReactElement<any, string | JSXElementConstructor<any>> - Name
isActive
DescriptionApplies active styles
falsetrue - Name
isDisabled
DescriptionDisabled interaction and applies disabled styles
falsetrue - Name
onToggle
DescriptionFunction triggered when the toggle button is clicked.
() => void - Name
size
DescriptionDetermines size variation of Button component
"small""medium""large" - Name
testId
DescriptionA [data-test-id] attribute used for testing purposes
string