SegmentedControl Edit

This feature is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.

SegementedControl is a form component that lets users choose options represented in horizontal segments. To render options for this control use SegmentedControlOption component.

Usage Usage

import {
    __experimentalSegmentedControl as SegmentedControl,
    __experimentalSegmentedControlOption as SegmentedControlOption,
} from '@wordpress/components';

function Example() {
    return (
        <SegmentedControl label="my label" value="vertical" isBlock>
            <SegmentedControlOption value="horizontal" label="Horizontal" />
            <SegmentedControlOption value="vertical" label="Vertical" />
        </SegmentedControl>
    );
}

Top ↑

Props Props

label label

  • Type: string

Label for the form element.

Top ↑

baseId baseId

  • Type: string
  • Required: No

ID that will serve as a base for all the items IDs.

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 SegmentedControl 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 SegmentedControl.