PeakUI

Alert

A status message with an icon, title and description

Usage

import {Alert} from "@peakui/react";

Content inside an Alert reads the default surface level, even when the Alert sits on a raised Surface.

Anatomy

import {Alert} from "@peakui/react";

export default () => (
  <Alert>
    <Alert.Indicator />
    <Alert.Content>
      <Alert.Title>Title</Alert.Title>
      <Alert.Description>Description</Alert.Description>
    </Alert.Content>
  </Alert>
);

Examples

Statuses

With Actions

Without Description

Custom Indicator

Alert.Indicator shows the status icon by default; children replace it.

Customization

Tailwind CSS

<Alert className="max-w-md">…</Alert>

Global CSS

@layer components {
  .alert {
    @apply rounded-2xl;
  }
}

Styling Reference

PeakUI follows the BEM methodology, so variants and states are plain class names you can target.

CSS Classes

The Alert component uses these CSS classes (view source styles):

Base Class

  • .alert - Base alert styles

Status Classes

  • .alert--default
  • .alert--accent
  • .alert--success
  • .alert--warning
  • .alert--danger

Element Classes

  • .alert__indicator - The status icon slot
  • .alert__content - The text container
  • .alert__title - The title element
  • .alert__description - The description element

Slots

  • [data-slot="alert-root"] - The root element
  • [data-slot="alert-indicator"] - The status icon slot
  • [data-slot="alert-content"] - The text container
  • [data-slot="alert-title"] - The title element
  • [data-slot="alert-description"] - The description element
  • [data-slot="alert-default-icon"] - The icon the indicator renders by default

API Reference

Alert

PropTypeDefaultDescription
childrenReactNode-Alert content (required)
status'accent' | 'danger' | 'default' | 'success' | 'warning''default'Alert status; sets the indicator and title color
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element

Every other attribute of a <div> is accepted.

Alert.Indicator

PropTypeDefaultDescription
childrenReactNode-Custom indicator; replaces the default status icon
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element

Every other attribute of a <div> is accepted.

Alert.Content

PropTypeDefaultDescription
childrenReactNode-Content children
classNamestring-Additional classes
renderDOMRenderFunction<'div', undefined>-Replaces the rendered <div> with your own element

Every other attribute of a <div> is accepted.

Alert.Title

PropTypeDefaultDescription
childrenReactNode-Title text
classNamestring-Additional classes
renderDOMRenderFunction<'p', undefined>-Replaces the rendered <p> with your own element

Every other attribute of a <p> is accepted.

Alert.Description

PropTypeDefaultDescription
childrenReactNode-Description text
classNamestring-Additional classes
renderDOMRenderFunction<'span', undefined>-Replaces the rendered <span> with your own element

Every other attribute of a <span> is accepted.

On this page