Free
Pro

Alert

The alert box takes the focus away from the current window, and forces the user to read the message.

free

Default Alert

Default Alert examples below. Use color="" to control <base-alert> color. Supported colors are "primary", "success", "danger", "warning" and "accent". >

Some text for info alert
Some text for info alert
Some text for danger alert
Some text for success alert
Some text for accent alert
Some text for warning alert

HTML

Alerts with icons

Use icon="" to add an icon to <base-alert>. Choose any icon from our Icon Pack page.

Some text for info alert
Some text for info alert
Some text for danger alert
Some text for success alert
Some text for accent alert
Some text for warning alert

HTML

Alert with action buttons

Add a <base-alert-actions> tag at the bottom and add one or multiple buttons for preferred actions. You can use the baseAlertDismiss directive on any button inside the actions to allow users to close the alert.

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suspendisse potenti nullam ac tortor vitae purus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suspendisse potenti nullam ac tortor vitae purus.
Some text for danger alert Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suspendisse potenti nullam ac tortor vitae purus.
Some text for success alert Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suspendisse potenti nullam ac tortor vitae purus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suspendisse potenti nullam ac tortor vitae purus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Suspendisse potenti nullam ac tortor vitae purus.

HTML

Alert with close button

Add close="true" to the <base-alert> to activate the default close (X) button. When the alert is closed, it emits a (closed) event.

Some text for info alert
Some text for info alert
Some text for danger alert
Some text for success alert
Some text for accent alert
Some text for warning alert

HTML

Alert Variants

Alerts support three visual variants: soft (default), solid, and outline.

Soft (Default)

Soft variant
Soft variant

Solid

Solid variant
Solid variant

Outline

Outline variant
Outline variant

HTML

Auto-dismiss

Use the duration property to automatically close the alert after a specific amount of time (in milliseconds).

This alert will disappear in 5 seconds.

HTML

Installation

Run the following command to add this component to your project:

bash

npx base-ui-cli add alert

API Reference

For AI agents

Copy a prompt with the registry name, CLI install, and import — or add the Base UI MCP server.

bash

npx -y base-ui-mcp

Base UI provides standalone components. Import the exact elements you want to use into your component.

typescript (Example)

// Install: npx base-ui-cli add alert
// Paths are relative to aliases.components (default: src/app/components)
import { AlertActionsComponent } from './alert/alert-actions/alert-actions.component';
import { AlertDismissDirective } from './alert/alert-dismiss.directive';
import { AlertComponent } from './alert/alert.component';

@Component({
  selector: 'app-your-component',
  imports: [
    AlertActionsComponent,
    AlertComponent,
    AlertDismissDirective
  ],
  template: `...`
})
export class YourComponent {}

API for alert — generated from JSDoc in the library source.

API reference for alert
APIMemberTypeDefaultDescription
base-alertclassstring''Additional host CSS classes (merged via cn()).
base-alertcolorAlertColor''
base-alertvariantAlertVariant'soft'
base-alerticonstring | undefinedundefined
base-alertclosebooleanfalse
base-alertdurationnumber0
base-alert(closed)voidEmits when closed occurs.
base-alert-actionsContainer for action buttons within an alert component.
[baseAlertDismiss]A directive that dismisses the parent `base-alert` when clicked.