Alert

Alert

Semantic alert boxes with role="alert" for info, warning, destructive, and success states

Installation

npx @ravikumarsurya/mdx-ui add alert

Usage

page.mdx
<Alert variant="info">
  <AlertTitle>Heads up</AlertTitle>
  <AlertDescription>
    You can customise this component in your project.
  </AlertDescription>
</Alert>

Examples

Info

page.mdx
<Alert variant="info">
  <AlertTitle>New version available</AlertTitle>
  <AlertDescription>
    Run npm update to get the latest features.
  </AlertDescription>
</Alert>

Warning

page.mdx
<Alert variant="warning">
  <AlertTitle>Deprecation notice</AlertTitle>
  <AlertDescription>
    This API will be removed in v3.0. Migrate to the new endpoint.
  </AlertDescription>
</Alert>

Destructive

page.mdx
<Alert variant="destructive">
  <AlertTitle>Build failed</AlertTitle>
  <AlertDescription>
    TypeScript errors were found. Check the output for details.
  </AlertDescription>
</Alert>

Success

page.mdx
<Alert variant="success">
  <AlertTitle>Deployment complete</AlertTitle>
  <AlertDescription>Your changes are live at production.</AlertDescription>
</Alert>

Without title

page.mdx
<Alert variant="info">
  <AlertDescription>
    You can omit AlertTitle and use AlertDescription on its own.
  </AlertDescription>
</Alert>

Difference from Callout

AlertCallout
Semantic rolerole="alert" (live region)none
Screen readersAnnounced immediatelyNot announced
Use forStatus changes, errors, confirmationsTips, notes, documentation callouts

Use Alert when something has happened or changed (form errors, success messages, warnings about an action). Use Callout for static informational notes in documentation.

Props

Alert

PropTypeDefaultDescription
variant"default" | "info" | "warning" | "destructive" | "success""default"Visual style
classNamestringExtra classes

AlertTitle

PropTypeDescription
childrenReactNodeTitle text
classNamestringExtra classes

AlertDescription

PropTypeDescription
childrenReactNodeDescription content
classNamestringExtra classes