Alert

Alerts are used to communicate a state that affects a system, feature or page.

chakra ui pro

Import#

Chakra UI exports 4 alert related components.

  • Alert: The wrapper for alert components.
  • AlertIcon: The visual icon for the alert that changes based on the status prop.
  • AlertTitle: The title of the alert to be announced by screen readers.
  • AlertDescription: The description of the alert to be announced by screen readers.
import {
Alert,
AlertIcon,
AlertTitle,
AlertDescription,
} from "@chakra-ui/react"

Usage#

Editable Example

Status#

Change the status of the alerts by passing the status prop. This affects the color scheme and icon used. Alert supports error, success, warning, and info statuses.

Editable Example

Variant#

Alert has 4 variant styles you can use. Pass the variant prop and use either subtle, solid, left-accent or top-accent.

Editable Example

Composition#

Alert ships with smaller components to allow for flexibility in creating all kinds of layouts. Here's an example of a custom alert style and layout:

Editable Example

Alert can also incorporate other Chakra components. Here's an example of an alert with wrapping description text:

Editable Example

Props#

Alert Props#

Alert is the wrapper for Alert component. It composes the Flex component.

colorScheme

Type
"whiteAlpha" | "blackAlpha" | "gray" | "red" | "orange" | "yellow" | "green" | "teal" | "blue" | "cyan" | "purple" | "pink" | "linkedin" | "facebook" | "messenger" | "whatsapp" | "twitter" | "telegram"
Default
"blue"

size

Description

Sizes for Alert are not implemented in the default theme. You can extend the theme to implement them.

Type
string

status

Description

The status of the alert

Type
"info" | "warning" | "success" | "error"

variant

Type
"solid" | "subtle" | "left-accent" | "top-accent"
Default
"subtle"

AlertIcon Props#

AlertIcon composes Icon and changes the icon based on the status prop.

AlertTitle Props#

AlertTitle composes the Box component.

AlertDescription Props#

AlertDescription composes the Box component.

Proudly made inNigeria by Segun Adebayo