Alert
Keeps users informed of important and sometimes time-sensitive changes.
#
Documentation
#
#
Usage
#
You do not have the required permissions to perform this action.
import {
Alert,
AlertDescription,
AlertTitle,
Link,
Text,
} from "@optiaxiom/react";
export function App() {
return (
<Alert>
<AlertTitle>Some action is not permitted</AlertTitle>
<AlertDescription>
<Text>
You do not have the required permissions to perform this action.
</Text>
<Text>
<Link href="data:,">Request access</Link>
</Text>
</AlertDescription>
</Alert>
);
}
#
Appearance
#
Use the intent
prop to select between the different alert types.
import type { ComponentPropsWithoutRef } from "react";
import { Alert, AlertDescription, AlertTitle } from "@optiaxiom/react";
export function App({
intent,
}: Pick<ComponentPropsWithoutRef<typeof Alert>, "intent">) {
return (
<Alert intent={intent}>
<AlertTitle>Alert title</AlertTitle>
<AlertDescription>Description of the alert message</AlertDescription>
</Alert>
);
}
#
Close button
#
Use the onClose
prop to show a close button to the top right of the alert.
import { Alert, AlertDescription, AlertTitle, Button } from "@optiaxiom/react";
import { useState } from "react";
export function App() {
const [open, setOpen] = useState(true);
return (
<>
{open && (
<Alert onClose={() => setOpen(false)}>
<AlertTitle>Some action is not permitted</AlertTitle>
<AlertDescription>
You do not have the required permissions to perform this action.
</AlertDescription>
</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 |
onClose Show a close button inside the alert and invoke this callback when the close button is clicked. () => void |
#
AlertTitle
#
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 |
#
AlertDescription
#
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 |
#
Changelog
#
#
0.1.0
#
- Added component