Skip to Content
ComponentsAlert

Alert

Keeps users informed of important and sometimes time-sensitive changes.

Documentation

Usage

import { Alert, Link, Text } from "@optiaxiom/react"; export function App() { return ( <Alert> <Text> You do not have the required permissions to perform this action. </Text> <Text> <Link href="data:,">Request access</Link> </Text> </Alert> ); }

Appearance

Use the intent prop to select between the different alert types.

import type { ComponentPropsWithoutRef } from "react"; import { Alert } from "@optiaxiom/react"; export function App({ intent, }: Pick<ComponentPropsWithoutRef<typeof Alert>, "intent">) { return <Alert intent={intent}>Description of the alert message</Alert>; }

Dismissible

Use the onDismiss prop to show a close button to the top right of the alert.

import { Alert, Button } from "@optiaxiom/react"; import { useState } from "react"; export function App() { const [open, setOpen] = useState(true); return ( <> {open && ( <Alert onDismiss={() => setOpen(false)}> You do not have the required permissions to perform this action. </Alert> )} {!open && <Button onClick={() => setOpen(true)}>Show alert</Button>} </> ); }

Related

AlertDialog

Display a modal with important content that expects confirmation from the user.

Banner

Display a prominent message at the top of the screen.

Toast

Display brief popup notifications.

Props

Alert

Supports all Box props in addition to its own. Renders a <div> element.

Prop

asChild

Change the default rendered element for the one passed as a child, merging their props and behavior.

Read the Composition guide for more details.

false | true

className

string

intent

Control the appearance by selecting between the different alert types.

"information" | "success" | "warning" | "danger" | "neutral"

Default: neutral

onDismiss

Show a close button inside the alert and invoke this callback when the close button is clicked.

() => void

Changelog

0.12.0

  • Breaking: renamed onClose prop to onDismiss

0.1.0

  • Added component
Last updated on