shadcn-templ 2.0 beta. Switch to templUI v1
1.7k

Alert

Displays a callout for user attention.

package examples import (

Installation

shadcn-templ add alert

Usage

import "github.com/axadrn/shadcn-templ/v2/components/alert"
@alert.Alert() {	@icon.Info()	@alert.Title() {		Heads up!	}	@alert.Description() {		You can add components to your app using the cli.	}	@alert.Action() {		@button.Button(button.Props{Variant: button.VariantOutline}) {			Enable		}	}}

Composition

Use the following composition to build an Alert:

alert.Alert├── icon├── alert.Title├── alert.Description└── alert.Action

Basic

A basic alert with an icon, title and description.

package examples import (

Destructive

Use Variant: alert.VariantDestructive to create a destructive alert.

package examples import (

Action

Use alert.Action to add a button or other action element to the alert.

package examples import (

Custom Colors

You can customize the alert colors by adding custom classes such as bg-amber-50 dark:bg-amber-950 to the Alert component.

package examples import (

API Reference

Alert

The Alert component displays a callout for user attention.

Prop Type Default
Variant VariantDefault | VariantDestructive VariantDefault
Class string -

Title

The alert.Title component displays the title of the alert.

Prop Type Default
Class string -

Description

The alert.Description component displays the description or content of the alert.

Prop Type Default
Class string -

Action

The alert.Action component displays an action element (like a button) positioned absolutely in the top-right corner of the alert.

Prop Type Default
Class string -