Feedback

Alert

Display contextual feedback messages with icons, actions, close button, and multiple visual styles.

Playground

Basic Usage

<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.

<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.

<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

<Alert
  title="Update available"
  description="A new software update is available for download."
  icon="lucide:download"
  color="info"
/>

With Actions

Add action buttons.

<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.

<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.

<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

SlotDescription
rootOutermost wrapper
wrapperContent wrapper
titleTitle text
descriptionDescription text
iconIcon element
avatarAvatar element
actionsAction buttons container
closeClose button

Snippets

SnippetDescription
leadingCustom leading content (replaces icon/avatar)
titleSlotCustom title content
descriptionSlotCustom description content
actionsSlotCustom actions content
closeSlotCustom close button

Props

PropTypeDefault
titlestring-
descriptionstring-
iconstring-
avatarAvatarProps-
colorColorType'primary'
variant'solid'|'outline'|'soft'|'subtle''soft'
orientation'horizontal'|'vertical''horizontal'
openbooleantrue
closeboolean | ButtonPropsfalse
closeIconstring'lucide:x'
onClose() => void-
actionsButtonProps[]-
askeyof HTMLElementTagNameMap'div'
refHTMLElement | nullnull
classstring-
uiRecord<Slot, Class>-