Skip to content

Four-level alerts in React

The four classic interface messages: information, success, warning and error.

Here is an excerpt of this component's code in React. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in React

AlertLevels.tsx
export function AlertLevels() {
  return (
    <div className="mx-auto w-[min(100%_-_2rem,40rem)] py-8">
      <div className="grid gap-3">
        <div className="grid grid-cols-[auto_1fr] gap-3 rounded-[10px] border border-l-4 px-4.5 py-4 border-blue-200 border-l-blue-800 bg-blue-50 dark:border-blue-900 dark:border-l-blue-300 dark:bg-[#0f1d3a] [&_svg]:text-blue-800 dark:[&_svg]:text-blue-300">
          <svg
            className="mt-0.5"
            aria-hidden="true"
            viewBox="0 0 24 24"
            width="20"
            height="20"
            fill="none"

Free component: copy it freely, including for commercial projects.

Toasts and alerts components in React
  • A banner that warns visitors when they lose the network and announces when it is back, using browser events, with no request.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A bell with an unread badge that opens a notification panel: icons by type, read and unread items told apart, and a "Mark all as read" button.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Three callouts for technical documentation: note, tip and warning.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A notice warning of a scheduled service interruption, with date, time and impact.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A dashed callout highlighting an offer and its code, with the end date.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • An announcement bar at the top of the page with a link and a button to close it.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component