Skip to content

Toast - Web Component โ€‹

...

Browser support โ€‹

Detected engine: ย 

  • Chromium

  • Webkit

  • Gecko

Parameters โ€‹

The Web component uses the <z-toast> tag:

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

NameTypeDescription
config
(optional)
string

Setting this attribute to a div tag will render a toast component. Possible values are: info, alert, negative, positive.

timestamp
(optional)
stringThe timestamp of the toast. If not, current time is used
content
(optional)
stringThe text of the toast

The available slots for the component are:

NameTagsDescription
defaultspan
timestampspan

config โ€‹

The config parameter is used to define the toast status. Possible values are: info, alert, negative, positive. Being omitted, the default value is info.

Toast textToast textToast textToast text

timestamp โ€‹

The timestamp parameter is used to define the time to be displayed in the toast. The format must be HH:mm. If not set, the current time will be used.

Toast textToast text

Both background color and text color can be customized using the --z-toast--bg and --z-toast--color CSS custom properties, respectively.

Custom toast

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/toast.js"></script>
Code
html
<z-toast config="info" timestamp="15:46">Toast text</z-toast>
<z-toast config="alert" timestamp="15:46">Toast text</z-toast>
<z-toast config="positive" timestamp="15:46">Toast text</z-toast>
<z-toast config="negative" timestamp="15:46">Toast text</z-toast>