Skip to content

Boolean icon - Web Component

Browser support

Detected engine:  

  • Chromium

  • Webkit

  • Gecko

Parameters

The Web component uses the <z-boolean-icon> tag:

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

NameTypeDescription
configstring

Icon set to be used as a checkbox. The possible values are: star, heart, bookmark, like, dislike, lock, unlock, mute, unmute, sound-on, sound-off, visible, or invisible

label
(optional)
stringLabel of the input
value
(optional)
booleanValue of the model
checked
(optional)
booleanOverrides the "value" parameter as in the standard
disabled
(optional)
booleanBlocks the interaction with the input component.
required
(optional)
booleanMarks the input component as required.
name
(optional)
stringIdentification for the field inside the form
invalid
(optional)
booleanThe forced state for set the input as invalid

The events emitted from the component are:

NamePayloadDescription
onchangebooleanReturns the new value of the "value" attribute

The available slots for the component are:

NameTagsDescription
defaultspan

Common API

For the basics, check the common specifications.

config

The config paramater requires the name of the icon set to be used as a checkbox. The possible values are:

star, heart, bookmark, like, dislike, lock, unlock, mute, unmute, sound-on, sound-off, visible or invisible.

label

The z-boolean-icon parameter accepts a label attribute to set the text label of the component.

value & checked

Both value and checked parameters are used to set the value of the component.

disabled

The attribute disabled will block the interaction with the component.

required

The attribute required will set the component as required.

name

The attribute name will set the name of the component. This is useful when the component is part of a form.

invalid-text

The invalid-text attribute will set the component as invalid. Without label, the text won't be present but the boolean icon will still be invalid,

The color and the size of the icon can be customized using the --z-boolean-icon--color, --z-boolean-icon--color--off and --z-boolean-icon--size CSS custom properties.

Playground

Customization

HTML Examples

Imports
html
<link rel="stylesheet" href="/0.5.1/@zurich/web-components/styles.css" />
<script type="module" src="/0.5.1/@zurich/web-components/boolean-icon.js"></script>
<link rel="stylesheet" href="/0.5.1/@zurich/web-components/styles.css" />
Code
html
<z-boolean-icon config="star"></z-boolean-icon>
<z-boolean-icon config="star" disabled></z-boolean-icon>
<z-boolean-icon config="star" invalid-text="Invalid input"></z-boolean-icon>

<z-boolean-icon config="star" checked></z-boolean-icon>
<z-boolean-icon config="star" checked disabled></z-boolean-icon>
<z-boolean-icon config="star" checked invalid-text="Invalid input"></z-boolean-icon>

<z-boolean-icon config="star" label="Boolean icon"></z-boolean-icon>
<z-boolean-icon config="star" label="Boolean icon" disabled></z-boolean-icon>
<z-boolean-icon config="star" label="Boolean icon" invalid-text="Invalid input"></z-boolean-icon>      

<z-boolean-icon config="star" label="Boolean icon" checked></z-boolean-icon>
<z-boolean-icon config="star" label="Boolean icon" checked disabled></z-boolean-icon>
<z-boolean-icon config="star" label="Boolean icon" checked invalid-text="Invalid input"></z-boolean-icon>