Skip to Content
ComponentsAlert

Alert

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

Documentation

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> ); }

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

import { Alert, Flex } from "@optiaxiom/react"; export function App() { return ( <Flex> <Alert intent="neutral">This is an example of a neutral alert.</Alert> <Alert intent="information"> This is an example of an information alert. </Alert> <Alert intent="success">This is an example of a success alert.</Alert> <Alert intent="warning">This is an example of a warning alert.</Alert> <Alert intent="danger">This is an example of a danger alert.</Alert> <Alert intent="opal">This is an example of an opal alert.</Alert> </Flex> ); }

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

"use client"; 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>} </> ); }

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

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" | "opal"

Default: neutral

onDismiss

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

() => void

Changelog

  • Breaking: renamed onClose prop to onDismiss
  • Added component
Last updated on