ToggleGroupControl
Edit
This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
ToggleGroupControl
is a form component that lets users choose options represented in horizontal segments. To render options for this control use ToggleGroupControlOption
component.
Usage Usage
import { __experimentalToggleGroupControl as ToggleGroupControl, __experimentalToggleGroupControlOption as ToggleGroupControlOption, } from '@wordpress/components'; function Example() { return ( <ToggleGroupControl label="my label" value="vertical" isBlock> <ToggleGroupControlOption value="horizontal" label="Horizontal" /> <ToggleGroupControlOption value="vertical" label="Vertical" /> </ToggleGroupControl> ); }
Props Props
label
label
- Type:
string
Label for the form element.
hideLabelFromVision
hideLabelFromVision
- Type:
boolean
- Required: No
- Default:
false
If true, the label will only be visible to screen readers.
isAdaptiveWidth
isAdaptiveWidth
- Type:
boolean
- Required: No
- Default:
false
Determines if segments should be rendered with equal widths.
isBlock
isBlock
- Type:
boolean
- Required: No
- Default:
false
Renders ToggleGroupControl
as a (CSS) block element.
onChange
onChange
- Type:
boolean
- Required: No
- Default:
false
Callback when a segment is selected.
value
value
- Type:
string | number
The value of the ToggleGroupControl
.
help
help
- Type:
ReactNode
- Required: No
If this property is added, a help text will be generated using help property as the content.