coss.com Svelte

Alert

A callout for displaying important information.

Loading p-alert-1 preview…

Installation

pnpm dlx shadcn-svelte@latest add https://coss-sv.vercel.app/r/alert.json

Usage

<script lang="ts">
  import * as Alert from "$lib/components/ui/alert/index.js";
</script>

<Alert.Root>
  <Alert.Title>Heads up!</Alert.Title>
  <Alert.Description>
    You can add components and dependencies to your app using the CLI.
  </Alert.Description>
</Alert.Root>

API Reference

This is a custom component, not a Shards UI wrapper.

Alert.Root

Root container for the alert. Native div attributes pass to the rendered element.

PropTypeDefaultDescription
variant"default" \| "error" \| "info" \| "success" \| "warning""default"Controls the alert styling and color scheme

Alert.Title

Title text for the alert. Renders as a styled div.

Alert.Description

Description text for the alert. Renders as a styled div with muted foreground color.

Alert.Action

Container for action buttons. Automatically positions to the right on larger screens.

Examples

With Icon

Loading p-alert-2 preview…

With Icon and Action Buttons

Loading p-alert-3 preview…

Info Alert

Loading p-alert-4 preview…

Success Alert

Loading p-alert-5 preview…

Warning Alert

Loading p-alert-6 preview…

Error Alert

Loading p-alert-7 preview…