Skip to content

Segmented control - Web Component

The SegmentedControl component can be used imported from:

Playground

Parameters

The Web component uses the <z-segmented-control> tag:

By default, all the parameters are optional or can be set in different, except for the ones marked as required

The parametrization of the component can be done with the following custom HTML params:

NameTypeDescriptionSlotA11y
optionsobject[]Array of options to be displayeddefault
namestringName of the input
disabledbooleanBlocks user interaction with the component

Events

This component has events. Check the documentation about how to use the events.

NamePayloadDescription
changestringReturns the new value of the "value" attribute
restartedvoidEmitted on value reset

Slots

This component has slots. Check the documentation about how to use the slots.

NameTagsDescription
defaultspan

Parameters use

options

The options parameter is used to set the options of the segmented control. Each option object should contain the text and value keys, also the disabled key is optional.

We can use <option> tags to define the values of options

name

The name parameter is used to set the name of the segmented control.

Flags

disabled

The disabled parameter is used to block the interaction with the component.

Methods

reset()

We can all the reset() method of the WebComponent in order to reset the value. This will clean the internal states and emit the nullable value with the change event, plus a restarted event:

In this example, the button triggers the method:

Value:  1

Browser support

Detected engine:  

  • Chromium

  • Webkit

  • Gecko

HTML Examples

CodeSandbox example