ComponentsAlert

Alert

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

Documentation

Usage

Some action is not permitted

You do not have the required permissions to perform this action.

Request access

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 colorScheme prop to select between the different alert types.

Alert title
Description of the alert message
import type { ComponentPropsWithoutRef } from "react";
 
import { Alert, AlertDescription, AlertTitle } from "@optiaxiom/react";
 
export function App({
  colorScheme,
}: Pick<ComponentPropsWithoutRef<typeof Alert>, "colorScheme">) {
  return (
    <Alert colorScheme={colorScheme}>
      <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.

Some action is not permitted
You do not have the required permissions to perform this action.
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>}
    </>
  );
}

Props

Alert

Supports all Box props in addition to its own.

Name

Type

asChild

false | true

colorScheme

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

onClose

() => void

AlertTitle

Supports all Box props in addition to its own.

Name

Type

asChild

false | true

AlertDescription

Supports all Box props in addition to its own.

Name

Type

asChild

false | true

Changelog

0.1.0

  • Added component

Copyright 2024 © Optimizely.