Alert
A notice that stands out from the page to tell the reader something important.
Installation
Needs the arene setup first.
Install the packages it imports:
Set up the token layer and the StyleX compiler, if you have not already. See
Installation. The alert also needs interop.css, which
places the icon and sizes it.
Paste this source into the file named in its title.
Change the @/ imports if your project uses different aliases.
Usage
Composition
The icon is any svg passed as a direct child. The alert is a three-column
grid, and interop.css places the icon in the first column and the action in
the last. Both columns collapse to nothing when empty.
Basic
The default variant with an icon, a title and a description.
Variants
Use the variant prop to set the tone: default, info, success, warning
or destructive. Each is a flat tinted fill with a matching border, and the
icon takes the variant's accent colour. The title and description keep the
page's own text colours, so every variant reads the same way.
Action
Put a button in AlertAction. It sits in the alert's last column, beside the text.
API reference
Pass render to replace a part's element or compose it with another component.
Alert
Renders a div with role="alert", which a screen reader announces as soon as
it appears. For a notice that is part of the page, such as a note in an article,
pass role="note" instead. Every part also takes xstyle and className.
| Prop | Type | Default |
|---|---|---|
variant | "default" | "info" | "success" | "warning" | "destructive" | "default" |
alertStyles
The style map behind the component, exported so you can apply the same styles to any element.
| Key | Description |
|---|---|
base | The grid, padding, border width and type |
variants | One entry per variant, keyed by its name |
Data attributes
| Attribute | On | Effect |
|---|---|---|
data-slot="alert" | the root | Where interop.css keys the icon's grid slot |
data-variant | the root | Reflects the variant prop |
data-slot="alert-title" | the title | Links inside are underlined by interop.css |
data-slot="alert-description" | the description | Links inside are underlined by interop.css |
data-slot="alert-action" | the action | Targets the action from a parent |
CSS variables
| Variable | On | Effect |
|---|---|---|
--arene-alert-accent | the root | The icon's colour. Set by the variant, read by interop.css |