Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Alert

An alert that conveys important information to the user. Supports four variants (info, success, warning, danger).

View in Storybook (opens in a new tab)

Installation

import { Alert } from "@ginga-ui/core";

Basic usage

A simple alert with a title and description.

Notice

The service will be unavailable tomorrow from 2:00 AM to 4:00 AM for scheduled maintenance.

alert.tsx
import { Alert, AlertDescription, AlertTitle } from "@ginga-ui/core";
import { Info } from "lucide-react";

export function BasicExample() {
  return (
    <Alert icon={<Info />}>
      <AlertTitle>Notice</AlertTitle>
      <AlertDescription>
        The service will be unavailable tomorrow from 2:00 AM to 4:00 AM for
        scheduled maintenance.
      </AlertDescription>
    </Alert>
  );
}

Variants

Four variants are available: info, success, warning, and danger.

Info

A new version is available.

Success

Your changes have been saved.

Warning

You are running low on storage space.

Error

Failed to load data.

alert.tsx
alert.module.css
import { Alert, AlertDescription, AlertTitle } from "@ginga-ui/core";
import styles from "./alert.module.css";
import { CircleAlert, CircleCheck, Info, TriangleAlert } from "lucide-react";

export function VariantsExample() {
  return (
    <div className={styles.alertStack}>
      <Alert variant="info" icon={<Info />}>
        <AlertTitle>Info</AlertTitle>
        <AlertDescription>A new version is available.</AlertDescription>
      </Alert>
      <Alert variant="success" icon={<CircleCheck />}>
        <AlertTitle>Success</AlertTitle>
        <AlertDescription>Your changes have been saved.</AlertDescription>
      </Alert>
      <Alert variant="warning" icon={<TriangleAlert />}>
        <AlertTitle>Warning</AlertTitle>
        <AlertDescription>
          You are running low on storage space.
        </AlertDescription>
      </Alert>
      <Alert variant="danger" icon={<CircleAlert />}>
        <AlertTitle>Error</AlertTitle>
        <AlertDescription>Failed to load data.</AlertDescription>
      </Alert>
    </div>
  );
}

Description only

You can omit the title and show only the description. When inserting it dynamically as a notification, pass alert to the role attribute or consider using Toast.

Your profile has been updated.

alert.tsx
import { Alert, AlertDescription } from "@ginga-ui/core";
import { CircleCheck } from "lucide-react";

export function DescriptionOnlyExample() {
  return (
    <Alert variant="success" icon={<CircleCheck />}>
      <AlertDescription>Your profile has been updated.</AlertDescription>
    </Alert>
  );
}

Props

Alert

NameTypeDefaultDescription
variant"info" | "success" | "warning" | "danger""info"Color variant that represents the kind of message.
iconReactNode-Icon shown before the content.
render(props) => ReactElement-Replaces the root element. Return an element that receives the given props, such as next/link.

Also accepts the attributes of the HTML div (opens in a new tab) element.

AlertTitle

NameTypeDefaultDescription
render(props) => ReactElement-Replaces the root element. Return an element that receives the given props, such as next/link.

Also accepts the attributes of the HTML div (opens in a new tab) element.

AlertDescription

NameTypeDefaultDescription
render(props) => ReactElement-Replaces the root element. Return an element that receives the given props, such as next/link.

Also accepts the attributes of the HTML p (opens in a new tab) element.