Segmented Group

Segmented Group is used to group multiple Segmented Items, where only one can be selected at a time..

Option 1 Option 2 Option 3
Option 1 Option 2 Option 3

The direction attribute can be used to vertically layout items.

Option 1 Option 2 Option 3
import '@ods/components/web.segmented-group';

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 default slot where `<ods-segmented-item>` elements are placed.
labelThe segmented group's label. Required for proper accessibility. Alternatively, you can use the `label` attribute.
help-textText that describes how to use the segmented group. Alternatively, you can use the `help-text` attribute.

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
defaultValue
string''
label
string''
helpText
help-text
string''
errorText
error-text
string''
name
string'option'
value
string''
size
'small' | 'medium' | 'large''medium'
disabled
booleanfalse
form
string''
required
booleanfalse
direction
'horizontal' | 'vertical''horizontal'
gap
booleanfalse
validity
validationMessage

Events

React EventDescriptionEvent Detail
ods-changeEmitted when the segmented group's selected value changes.--
ods-inputEmitted when the segmented group receives user input.--
ods-invalidEmitted when the form control has been checked for validity and its constraints aren't satisfied.--

Methods

NameDescriptionArguments
checkValidity()Checks for validity but does not show a validation message. Returns `true` when valid and `false` when invalid.--
getForm()Gets the associated form, if one exists.--
reportValidity()Checks for validity and shows the browser's validation message if the control is invalid.--
setCustomValidity()Sets a custom validation message. Pass an empty string to restore validity.--

Parts

NameDescription
form-controlThe form control that wraps the label, input, and help text.
form-control-labelThe label's wrapper.
form-control-inputThe input's wrapper.
form-control-help-textThe help text's wrapper.
form-control-error-textThe error text's wrapper.
button-groupThe button group that wraps segmented items.
button-group__baseThe button group's `base` part.

Dependencies

This component automatically imports the following dependencies.

  • ods-button-group

Search