Tabler React 2 Docs

Segmented Control

Segmented Control

Segmented controls allow a user to select a value from a set of options.

Signature

import { SegmentedControl } from "tabler-react-2";
<SegmentedControl {...props} />;

Props

PropRequiredTypeDefaultDescription
valueNoString or NumberThe value of the selected option.
onChangeNofunction (called with object)A function that fires when the user selects a new option.
itemsYesArray of SegmentedControlItemsAn array of options to be displayed in the segmented control.
verticalNoBooleanfalseWhether the segmented control should be displayed vertically.
sizeNoString [sm | lg]The size of the segmented control.
classNameNoStringA class name to be added to the segmented control.
buttonClassNameNoStringA class name to be added to the segmented control buttons.
styleNoObjectA style object to be added to the segmented control.
buttonStyleNoObjectA style object to be added to the segmented control buttons.

Basic Usage

The SegmentedControl component is used to display a segmented control.

<SegmentedControl
value="one"
onChange={(v) => alert(`Selected ${v.label}`)}
items={[
{ id: "one", label: "One" },
{ id: "two", label: "Two" },
{ id: "three", label: "Three" },
]}
/>

Segmented Control Items

PropRequiredTypeDefaultDescription
idYesStringThe value of the option.
labelYesStringThe label of the option.
iconNoReact.ReactNodeAn icon to be displayed in the segmented control.
disabledNoBooleanfalseWhether the option should be disabled.
classNameNoStringA class name to be added to the segmented control option.
styleNoObjectA style object to be added to the segmented control option.
Edit this page on GitHub