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 colors are ignored for AlertVariant.Destructive — that variant always applies the theme's destructive color to titleColor and descriptionColor.

API reference

Alert

ParameterTypeDefaultDescription
modifierModifierModifierApplied to the root Row container.
variantAlertVariantAlertVariant.DefaultVisual style controlling text colors.
colorsAlertStyleAlertDefaults.colors()Color tokens for the alert surface and text. Ignored for title/description colors when variant is Destructive.
icon(@Composable () -> Unit)?nullOptional leading icon composable.
title@Composable () -> UnitHeader content rendered in semibold text.
description@Composable () -> UnitBody content rendered in smaller muted text.

AlertVariant

ValueDescription
DefaultUses theme foreground and muted foreground for title and description.
DestructiveApplies the theme's destructive color to both title and description text.

AlertStyle

FieldTypeDescription
borderColorsColorBorder color of the alert container.
backgroundColorColorBackground fill of the alert container.
titleColorColorText color for the title. Overridden by Destructive variant.
descriptionColorColorText color for the description. Overridden by Destructive variant.

AlertDefaults

MemberDescription
colors()Returns the default AlertStyle using border, background, foreground, and mutedForeground from the active theme.
Edit this page on GitHub