Alert
Displays a callout for user attention.
Success! Your changes have been saved
This is an alert with icon, title and description.
This Alert has a title and an icon. No description.
Unable to process your payment.
Please verify your billing information and try again.
- Check your card details
- Ensure sufficient funds
- Verify billing address
Installation
pnpm add @heyramzi/uiUsage
import * as Alert from "@heyramzi/ui/shadcn/alert";<Alert.Root>
<Alert.Title>Your changes have been saved</Alert.Title>
<Alert.Description>This is an alert with a title and a description.</Alert.Description>
</Alert.Root>
<Alert.Root variant="destructive">
<Alert.Title>Unable to process your payment.</Alert.Title>
</Alert.Root>Keyboard and accessibility
- Alert has role="alert", so a screen reader reads it out as soon as it appears.
- For a message that's on the page from the start, pass role="status" or role={undefined} so it isn't read out of turn.
API reference
Alert.Root
variant"default" | "destructive"- Default
"default" refbindableHTMLDivElement | null- Default
null classstringrolestring- Default
"alert" childrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
variant | "default" | "destructive" | "default" |
ref bindable | HTMLDivElement | null | null |
class | string | |
role | string | "alert" |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Alert.Title
refbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |
Alert.Description
refbindableHTMLDivElement | null- Default
null classstringchildrenSnippet...rest- Every prop of
HTMLAttributes<HTMLDivElement>fromsvelte/elements
| Prop | Type | Default |
|---|---|---|
ref bindable | HTMLDivElement | null | null |
class | string | |
children | Snippet | |
...rest | Every prop of HTMLAttributes<HTMLDivElement> from svelte/elements | |