Skip to main content

SegmentedControl

A Segmented Control lets users choose a single or multiple options from a series of related choices.

Installation

Before you can start using the @mediahuis/chameleon-react component, you’ll need to install it, for more information check: Getting started for developers.

With that done, you’re now ready to implement the component in your application.

import { SegmentedControl } from '@mediahuis/chameleon-react';

export default function Example() {
return (
<SegmentedControl>
<SegmentedControlItem label="Item 1" value="item1" id="1" />
<SegmentedControlItem label="Item 2" value="item2" id="2" />
</SegmentedControl>
);
}

Properties

PropertyTypeDefaultRequiredDescription
onChangeFunction-NoCallback when the selected value(s) change.
type'single' | 'multiple''single'NoType of the segmented control: allows single or multiple selections.
orientation'horizontal' | 'vertical''horizontal'NoLayout orientation of the segmented control.
labelHiddenBoolean-NoWhether to visually hide the label while keeping it accessible.
size'sm' | 'lg''lg'NoSize of the segmented control.
fullWidthBooleanfalseNoWhether the control takes up the full width of the container.
valueString | Unknown-YesThe controlled value of the selected item(s). For single selection, this will be a string. For multiple selection, this will be an array of strings. If not provided, the component will manage its own state.
defaultValueString | Unknown-NoThe initial value of the selected item(s) in uncontrolled mode. For `type="single"`, this should be a string. For `type="multiple"`, this should be an array of strings.

SegmentedControlItem Properties

PropertyTypeDefaultRequiredDescription
iconSVGType-No
labelString-Yes
labelHiddenBoolean-No
valueString-Yes