Vivid API

Alert

Alerts display short-lived important information to the user, usually at the top or bottom of the screen.

Usage

import { registerAlert } from '@vonage/vivid-api';
registerAlert('your-prefix');

Opening and Closing

Open

Use the open attribute to toggle the Alert open state.

Timeoutms

Use the timeoutms attribute to set the time in milliseconds after which the Alert will automatically close.

The default value is 0, which means the Alert will not close automatically.

Position Strategy

The strategy attribute controls the position strategy of the Alert. The default is fixed, which will position the Alert relative to the viewport.

When set to static, placement will have no effect, and the Alert will behave as an element in page flow.

Slots

Main Slot

If you want to add rich content to an Alert, you can use the main slot.

Action Items Slot

You can add action items elements using the action-items slot. They will be displayed at the inline-end of the Alert.

Icon Slot

Set the icon slot to add an icon to the Alert. If set, the icon attribute (deprecated) is ignored.

CSS Variables

Minimum inline Size

Use the --alert-min-inline-size variable to set the Alert’s minimum inline size. The default value is 420px.

Maximum inline Size

Use the --alert-max-inline-size variable to set the Alert’s maximum inline size. This is helpful to prevent the Alert from becoming too wide when displaying a long message.

The default value is fit-content, which allows the Alert to grow as needed.

API Reference

Properties

PropertyTypeDefaultDescription
connotation'accent' | 'success' | 'alert' | 'warning' | 'information' | 'announcement'Sets an appropriate icon / icon color for the connotation.
dismissButtonAriaLabelstringAllows setting a custom aria-label for the dismiss button.
headlinestringAdds a headline to the Alert.
openbooleanOpen state of the Alert.
placement'top' | 'bottom' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'The placement of the Alert on the screen.
removablebooleanAdds a close button to the Alert.
strategy'fixed' | 'static'Controls the `position` of the Alert.
textstringThe main text of the Alert.
timeoutmsnumberTimeout after which the Alert will close.
PropertyTypeDefaultDescription
connotation'accent' | 'success' | 'alert' | 'warning' | 'information' | 'announcement'Sets an appropriate icon / icon color for the connotation.
dismiss-button-aria-labelstringAllows setting a custom aria-label for the dismiss button.
headlinestringAdds a headline to the Alert.
openbooleanOpen state of the Alert.
placement'top' | 'bottom' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end'The placement of the Alert on the screen.
removablebooleanAdds a close button to the Alert.
strategy'fixed' | 'static'Controls the `position` of the Alert.
textstringThe main text of the Alert.
timeoutmsnumberTimeout after which the Alert will close.

Slots

NameDescription
action-itemsAdd action items to the Alert using this slot.
iconThe preferred way to add an icon to the component.
mainThe main content of the Alert.
NameDescription
action-itemsAdd action items to the Alert using this slot.
iconThe preferred way to add an icon to the component.
mainThe main content of the Alert.

Events

NameTypeDescription
closeCustomEvent<undefined>Fired when the Alert is closed
openCustomEvent<undefined>Fired when the Alert is opened
NameTypeDescription
closeCustomEvent<undefined>Fired when the Alert is closed
openCustomEvent<undefined>Fired when the Alert is opened