Skip to content

Segment Control Bar

<tpg-segment-control-bar></tpg-segment-control-bar>

Segment Control Bar is used for switching between pre-filtered views of the same group of information.

A minimum of 2 items is required to assemble a Segment Control Bar while a maximum of 4 items per single line is recommended.

They have three visual states:

  • Selected: when item is selected
  • Unselected: when item is not selected
  • Disabled: when an item is not selectable/available

Component behavior

The segment control item (child of segment-control-bar) will respond to clicks or presses inside the entirety of its area, which takes up all available space by default.

Like a radio-group, only one segment can be selected at a time. Selecting a new segment will deselect the previously selected one.

Examples

Basic usage

Basic usage with 2-4 options. The width of the segment control bar component will always be 100% of the parent component, and the items will divide all space equaly.

Setting icons

You can use the leading-icon-template & trailing-icon-template attributes to set icons for the Segment Control Item.

Appearance

You can choose between a default and dark appearance using the type attribute.

Tables

Properties

Attribute Property Description Type Default Value
type type 'dark' | 'default' 'default'
selected-value selectedValue string ''

Events

Event name Reactjs attribute Description
tpg-change ontpg-change Event fired when a new segment-control-item is selected. Returns value of the selected item.

Functions

Name Description Arguments
No functions found.

Slots

Name Description
items slot reserved for tpg-segment-control-item components
Default slot for content

CSS Parts

Attribute Description
No CSS parts found.

Sandbox