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>
    );
}

Top ↑

Props Props

label label

  • Type: string

Label for the form element.

Top ↑

hideLabelFromVision hideLabelFromVision

  • Type: boolean
  • Required: No
  • Default: false

If true, the label will only be visible to screen readers.

Top ↑

isAdaptiveWidth isAdaptiveWidth

  • Type: boolean
  • Required: No
  • Default: false

Determines if segments should be rendered with equal widths.

Top ↑

isBlock isBlock

  • Type: boolean
  • Required: No
  • Default: false

Renders ToggleGroupControl as a (CSS) block element.

Top ↑

onChange onChange

  • Type: boolean
  • Required: No
  • Default: false

Callback when a segment is selected.

Top ↑

value value

  • Type: string | number

The value of the ToggleGroupControl.

Top ↑

help help

  • Type: ReactNode
  • Required: No

If this property is added, a help text will be generated using help property as the content.