Alert
Alert shows a status message inside the page. Use it for information, success, warning and error messages. Compose the icon, text, actions and close button as children.
- Stack layout: use no actions, or one or two Button actions. Leave out AlertClose.
- Inline layout: use AlertClose alone, one or two Button actions, or Buttons plus AlertClose.
- AlertClose doesn't remove the alert. Remove it in your own
onClickhandler.
Installation
Run npx nxds-cli@latest init first if nxds isn’t set up in your app yet. See Install.
Usage
Composition
Examples
Banner presentation
Show a full-width banner with square corners and a bottom border.
Dismissible close button
Remove the alert from state when the reader clicks AlertClose.
Actions below description
Place two Button actions under the message in the stack layout.
This example also needs: Button.
All variants
Compare the five status variants side by side.
Props
Alert
| Prop | Type | Default | Description |
|---|---|---|---|
layout | "inline" | "stack" | null | "stack" | No description |
presentation | "banner" | "card" | null | "card" | No description |
variant | "default" | "destructive" | "success" | "information" | "warning" | null | "default" | No description |
AlertActions
AlertActions adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertClose
AlertClose adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertContent
AlertContent adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertDescription
AlertDescription adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertIcon
AlertIcon adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertTitle
| Prop | Type | Default | Description |
|---|---|---|---|
asChild | boolean | false | Applies the title styles to the child element, such as a real heading. |
Alert shows a status message inside the page. Use it for information, success, warning and error messages. Compose the icon, text, actions and close button as children.
Installation
Install the following dependencies:
Copy and paste the following code into your project.
components/alert/Alert.vue components/alert/AlertActions.vue components/alert/AlertClose.vue components/alert/AlertContent.vue components/alert/AlertDescription.vue components/alert/AlertIcon.vue components/alert/AlertTitle.vue components/alert/index.ts lib/icons.ts Keep each file at the path shown above it.
Paths are relative to
packages/vue/src/. Keep the same folders under your@/root, and the imports between files work without edits.
Usage
Examples
Banner presentation
Show a full-width banner with square corners and a bottom border.
Dismissible close button
Remove the alert from state when the reader clicks AlertClose.
Actions below description
Place two Button actions under the message in the stack layout.
This example also needs: Button.
All variants
Compare the five status variants side by side.
Props
Alert
| Prop | Type | Default | Description |
|---|---|---|---|
layout | "stack" | "inline" | null | "stack" | No description |
presentation | "card" | "banner" | null | "card" | No description |
variant | "default" | "destructive" | "success" | "information" | "warning" | null | "default" | No description |
AlertActions
AlertActions adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertClose
AlertClose adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertContent
AlertContent adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertDescription
AlertDescription adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertIcon
AlertIcon adds no props of its own; it accepts the props of the element or primitive it wraps.
AlertTitle
AlertTitle adds no props of its own; it accepts the props of the element or primitive it wraps.