Segmented Item

Segmented items allow the user to select a single option from a group using a button-like control.

A Segmented Item is designed to be used within a Segmented Group . When a Segmented Item has focus, the arrow keys can be used to change the selected option.

Option 1 Option 2 Option 3

To set the initial value and checked state, use the value attribute on the containing radio group.

Option 1 Option 2 Option 3

Use the disabled attribute to disable a segmented item.

Option 1 Option 2 Option 3

Use the prefix and suffix slots to add icons.

Option 1 Option 2 Option 3

You can omit button labels and use icons instead. Make sure to set a label attribute on each icon so screen readers will announce each option correctly.

import '@ods/components/web.segmented-item';

Note: You only need to import a web component once in your code, as it registers itself globally when defined, allowing you to use it anywhere within your application without needing to re-import it each time you want to use the component.

Slots

NameDescription
(default)The segmented-item button's label.
prefixA presentational prefix icon or similar element.
suffixA presentational suffix icon or similar element.

Properties

Please note, both DOM properties and HTML attributes are shown in the table below. Unless otherwise specified, the property and attribute names are identical.

Property/AttributeReflectsTypeDefault
value
string
disabled
booleanfalse
size
'small' | 'medium' | 'large''medium'
pill
booleanfalse

Events

React EventDescriptionEvent Detail
ods-blurEmitted when the button loses focus.--
ods-focusEmitted when the button gains focus.--

Methods

NameDescriptionArguments
focus()Sets focus on the segmented-item button.--
blur()Removes focus from the segmented-item button.--

Parts

NameDescription
baseThe component's base wrapper.
buttonThe internal `<button>` element.
button--checkedThe internal button element when the segmented-item button is checked.
prefixThe container that wraps the prefix.
labelThe container that wraps the segmented-item button's label.
suffixThe container that wraps the suffix.

Search