Skip to content

Segmented control - Web Component โ€‹

Browser support โ€‹

Detected engine: ย 

  • Chromium

  • Webkit

  • Gecko

Parameters โ€‹

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

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

NameTypeDescription
optionsobject[]Array of options to be displayed
name
(optional)
stringName of the input
disabled
(optional)
booleanBlocks user interaction with the component

The events emitted from the component are:

NamePayloadDescription
onchangestringReturns the new value of the "value" attribute

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.

name โ€‹

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

disabled โ€‹

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

Playground โ€‹

Customization โ€‹

HTML Examples โ€‹

Imports
html
<link rel="stylesheet" href="/0.4.5/@zurich/web-components/styles.css" />
<script type="module" src="/0.4.5/@zurich/web-components/segmented-control.js"></script>
Code
html
<!-- Default -->
<z-segmented-control name="segmented-control-2" value="1"
  options='[{"text":"Text 1"}, {"text":"Text 2"}]'></z-segmented-control>

<!-- icon -->
<z-segmented-control name="segmented-control-2i" value="1"
  options='[{"icon":"bar-chart:line"}, {"icon":"bar-chart:line"}]'></z-segmented-control>

<!-- combined -->
<z-segmented-control name="segmented-control-2c" value="1"
  options='[{"icon":"bar-chart:line"}, {"icon":"bar-chart:line","text":"Text 1"}]'></z-segmented-control>

<!-- disabled -->
<z-segmented-control name="segmented-control-2d" value="1" disabled
  options='[{"text":"Text 1"}, {"text":"Text 2"}]'></z-segmented-control>