Skip to content

Alert - Web Component โ€‹

Browser support โ€‹

Parameters โ€‹

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

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

NameTypeDescription
config
(optional)
string

Defines the state of the alert. Possible values are:

info, alert, negative and positive

content
(optional)
stringThe content of the alert.
confirm-text
(optional)
stringThe text of the button.

The events emitted from the component are:

NamePayloadDescription
onconfirmEventFired when the user confirms the alert.
oncloseEventFired when the user closes the alert.

config โ€‹

The config attribute is used to set the state of the alert. Possible values are: info, alert, negative and positive.

This is an info alert This is an alert alert This is a negative alert This is a positive alert

confirm-text โ€‹

The confirm-text attribute is used to set the text of the confirm button.

This is an info alert

Both background color and text color can be customized using the --z-alert--bg and --z-alert--color tokens.

Custom alert

Playground โ€‹

Customization โ€‹

HTML Examples โ€‹

Imports
html
<link rel="stylesheet" href="/0.4.3/@zurich/web-components/styles.css" />
<script type="module" src="/0.4.3/@zurich/web-components/alert.js"></script>
Code
html
<z-alert config="info" confirm-text="Okay">Alert text</z-alert>
<z-alert config="alert" confirm-text="Okay" content="Alert text"></z-alert>
<z-alert config="negative" confirm-text="Okay" content="Alert text"></z-alert>