Alert
Displays a short, important message with an optional icon, supporting default and destructive visual variants with full color customization.
Alert renders a full-width callout banner with a rounded border. It accepts an optional leading icon slot, a title, and a description. The Default variant uses theme foreground colors; the Destructive variant automatically switches title and description to the theme's destructive color regardless of the colors override.
Basic usage
Destructive variant
Use AlertVariant.Destructive to signal an error or a dangerous action. Title and description text automatically use the theme's destructive color.
With icon
Pass any composable to icon to prepend a leading indicator. The icon inherits the resolved title color via ProvideTextStyle.
Custom colors
Override any color token by calling AlertDefaults.colors().copy(...). Use this for branded or contextual callouts beyond the two built-in variants.
Color overrides passed via
colorsare ignored forAlertVariant.Destructive— that variant always applies the theme's destructive color totitleColoranddescriptionColor.
API reference
Alert
| Parameter | Type | Default | Description |
|---|---|---|---|
modifier | Modifier | Modifier | Applied to the root Row container. |
variant | AlertVariant | AlertVariant.Default | Visual style controlling text colors. |
colors | AlertStyle | AlertDefaults.colors() | Color tokens for the alert surface and text. Ignored for title/description colors when variant is Destructive. |
icon | (@Composable () -> Unit)? | null | Optional leading icon composable. |
title | @Composable () -> Unit | — | Header content rendered in semibold text. |
description | @Composable () -> Unit | — | Body content rendered in smaller muted text. |
AlertVariant
| Value | Description |
|---|---|
Default | Uses theme foreground and muted foreground for title and description. |
Destructive | Applies the theme's destructive color to both title and description text. |
AlertStyle
| Field | Type | Description |
|---|---|---|
borderColors | Color | Border color of the alert container. |
backgroundColor | Color | Background fill of the alert container. |
titleColor | Color | Text color for the title. Overridden by Destructive variant. |
descriptionColor | Color | Text color for the description. Overridden by Destructive variant. |
AlertDefaults
| Member | Description |
|---|---|
colors() | Returns the default AlertStyle using border, background, foreground, and mutedForeground from the active theme. |