Feedback
Alert
Display contextual feedback messages with icons, actions, close button, and multiple visual styles.
Playground
Heads up!
You can add components using the CLI.
Basic Usage
Heads up!
You can add components to your app using the CLI.
<script lang="ts">
import { Alert } from 'sv5ui';
</script>
<Alert
title="Heads up!"
description="You can add components to your app using the CLI."
/>Variants
4 visual styles.
Solid
This is a solid alert.
Outline
This is a outline alert.
Soft
This is a soft alert.
Subtle
This is a subtle alert.
<Alert variant="solid" title="Solid" description="This is a solid alert." />
<Alert variant="outline" title="Outline" description="This is an outline alert." />
<Alert variant="soft" title="Soft" description="This is a soft alert." />
<Alert variant="subtle" title="Subtle" description="This is a subtle alert." />Colors
Semantic colors with icons for context.
Success
Your changes have been saved.
Warning
Your session is about to expire.
Error
Something went wrong. Please try again.
Info
A new version is available.
<Alert color="success" title="Success" description="Your changes have been saved." icon="lucide:check-circle" />
<Alert color="warning" title="Warning" description="Your session is about to expire." icon="lucide:alert-triangle" />
<Alert color="error" title="Error" description="Something went wrong. Please try again." icon="lucide:x-circle" />
<Alert color="info" title="Info" description="A new version is available." icon="lucide:info" />With Icon
Update available
A new software update is available for download.
<Alert
title="Update available"
description="A new software update is available for download."
icon="lucide:download"
color="info"
/>With Actions
Add action buttons.
Confirm action
Are you sure you want to proceed?
<Alert
title="Confirm action"
description="Are you sure you want to proceed with this action?"
icon="lucide:alert-triangle"
color="warning"
:actions={[
{ label: 'Cancel', variant: 'outline', color: 'surface', size: 'xs' },
{ label: 'Confirm', variant: 'solid', color: 'warning', size: 'xs' }
]}
/>Closable
Dismiss with a close button.
Dismissible alert
Click the close button to dismiss.
<script lang="ts">
import { Alert, Button } from 'sv5ui';
let alertOpen = $state(true);
</script>
{#if alertOpen}
<Alert
title="Dismissible alert"
description="Click the close button to dismiss this alert."
close
onClose={() => (alertOpen = false)}
/>
{/if}
{#if !alertOpen}
<Button
label="Show alert"
size="sm"
variant="outline"
onclick={() => (alertOpen = true)}
/>
{/if}Vertical
Stacked layout.
Vertical layout
This alert uses a vertical orientation.
<Alert
orientation="vertical"
title="Vertical layout"
description="This alert uses a vertical orientation for a stacked layout."
icon="lucide:layout"
color="tertiary"
:actions={[
{ label: 'Learn more', variant: 'outline', color: 'tertiary', size: 'xs' }
]}
/>UI Slots
| Slot | Description |
|---|---|
root | Outermost wrapper |
wrapper | Content wrapper |
title | Title text |
description | Description text |
icon | Icon element |
avatar | Avatar element |
actions | Action buttons container |
close | Close button |
Snippets
| Snippet | Description |
|---|---|
leading | Custom leading content (replaces icon/avatar) |
titleSlot | Custom title content |
descriptionSlot | Custom description content |
actionsSlot | Custom actions content |
closeSlot | Custom close button |
Props
| Prop | Type | Default |
|---|---|---|
title | string | - |
description | string | - |
icon | string | - |
avatar | AvatarProps | - |
color | ColorType | 'primary' |
variant | 'solid'|'outline'|'soft'|'subtle' | 'soft' |
orientation | 'horizontal'|'vertical' | 'horizontal' |
open | boolean | true |
close | boolean | ButtonProps | false |
closeIcon | string | 'lucide:x' |
onClose | () => void | - |
actions | ButtonProps[] | - |
as | keyof HTMLElementTagNameMap | 'div' |
ref | HTMLElement | null | null |
class | string | - |
ui | Record<Slot, Class> | - |