Skip to main content

Segmented Control

A segmented control is a set of checkable buttons. No more than one button can be checked at a time. When a user checks an unchecked button, the previously checked button is automatically unchecked.

It is possible to initialise the set with all buttons in the unchecked state. This forces the user to check one of the buttons before moving past a certain point in the workflow.

Use cases:

  • Used anywhere someone may want to visually and structurally group related interactive controls.

Examples

Item 1Item 2Item 3Chosen Option:

Declaration

  <rapid-segmented-control></rapid-segmented-control>

Usage

  @customElement({
name: 'my-element',
template: html`
<rapid-segmented-control value=${sync((x) => x.controlValue)}>
<rapid-segmented-item>Item 1</rapid-segmented-item>
<rapid-segmented-item>Item 2</rapid-segmented-item>
<rapid-segmented-item>Item 3</rapid-segmented-item>
</rapid-segmented-control>
`,
})

export class MyElement extends GenesisElement {
@observable controlValue = '';
controlValueChanged() {
console.log(this.controlValue);
}
}

API

Attributes

NameTypeDescriptionExample
readonlybooleanConfigures the component so the user cannot alter the state via the web browser.
<rapid-segmented-control readonly>
disabledbooleanSimilar to readonly, but with a blur on the component
<rapid-segmented-control disabled>
namestringDefines the name of the element
<rapid-segmented-control name="componentName">
valuestringDefines the value associated with this element.
<rapid-segmented-control value=${sync((x) => x.controlValue)}>
orientation"horizontal" | "vertical"Sets the orientation of the group of components. Default: horizontal
<rapid-segmented-control orientation="vertical">

Properties:

This component doesn't have any properties which are not also controlled via attributes.

Slots

SlotDescription
DefaultThe default slot where rapid-segmented-items go
labelThe label

Parts

There are no parts.

Events fired

EventTypeUseExample
changevoidEmits a custom change event when the component state changes.
<rapid-segmented-control @change="${(x) => x.myChangeHandler()}">

Events listened to

This component doesn't listen to any events.