Appearance
Appearance
import Alert from "@ui/Alert.vue"Display informative messages that may change and update over time
export type Props = {
role?: 'log' | 'status' | 'alert' | 'progressbar' | 'marquee' | 'timer'
} & PastelProps & AlignmentPropsBy default, screenreaders will read out all alerts on a page. This is annoying and intrusive. Do use a more polite role such as status to skip the initial announcement, and use the (default) alert role only on extremely important announcements.
Careful with the alert role!
The
alertrole is intended for messages that are dynamically displayed, not for content that appears on page load. For example, it can show an error message if user-added content has an invalid format or the backend throws an error - the alert would immediately read out the message. It should not be used on HTML that the user hasn't interacted with. For example, if a page loads with multiple visible alerts scattered throughout, choose a role other thanalert, as the messages were not dynamically triggered.
Read more: Using Alignment props
<Alert>
Awesome artist
<template #actions>
<Button disabled>
Deny
</Button>
<Button primary>
Got it
</Button>
</template>
</Alert>Never rely on color alone to convey relevant information
Many people will not perceive certain colors, so give them other affordances to understand the meaning of a given alert.
Read more: Using Color
<Alert blue>
Blue alert
</Alert>
<Alert red>
Red alert
</Alert>
<Alert purple>
Purple burglar alert
</Alert>
<Alert green>
Green alert
</Alert>
<Alert yellow>
Yellow alert
</Alert>Using this component
<Alert
v-if="isAlertStatus"
role="status"
blue
>
Your settings have been saved successfully.
</Alert>
<Alert
v-if="isAlertUrgent"
role="alert"
red
>
Connection lost. Please check your internet connection and try again.
<template #actions>
<Button
aria-label="Close 'connection lost' alert"
@click="toggleUrgent"
>
Dismiss
</Button>
</template>
</Alert>