Skip to content
WingoUI
ComponentsTemplatesDocsPricingAI agentsBlogChangelogContact
Components
Buttons & Actions
ButtonButton GroupCopy ButtonDelete ButtonTheme ToggleToggleToggle Group
Inputs
Avatar UploadCalendarCheckboxColor PickerComboboxCountry SelectCron PickerCurrency InputDate PickerDate Range PickerDate Time PickerDuration PickerEmail InputEmoji PickerFile UploadFilter BuilderInputInput GroupListboxMasked InputMention InputMonth PickerMulti SelectNumber InputOTP InputPassword InputPhone InputRadio GroupRatingSearch InputSegmented ControlSelectSignature PadSliderSwitchTag InputTextareaTime PickerTimezone SelectTree Select
Forms
Address InputBooking WidgetCSV ImportFieldForm WizardInline EditInvoice line itemsRich Text EditorSchema Builder
Navigation
Back To TopBounce SidebarBreadcrumbCommand MenuGlobal SearchGooey NavHook SidebarNav MenuNav TabsPaginationProximity SidebarScroll ProgressSidebarStepsTable Of ContentsTabsTopbarUser MenuWorkspace Switcher
Overlays
Alert DialogContext MenuDialogDrawerDropdown MenuFamily DrawerHover CardPopoverShare DialogSheetShortcuts DialogTooltipTour
Feedback
AlertBannerCookie ConsentEmoji ReactionEmpty StateNotification BellNotification CenterProgressRoute ProgressSetup ChecklistSkeletonSpinnerToast
Data Display
Approval FlowAvatarBadgeCalendar ViewCode BlockComment ThreadContact cardCountdownDescription ListDiff ViewerFile ListFile managerFolderGanttJSON ViewerKbdLog ViewerMarkdownPresenceSchedulerTagTimelineTree View
Tables & Lists
Audit LogData TableDeal PipelineEditable GridKanbanListMembers tablePermissions MatrixTableTask ListVirtual List
Charts & Stats
Animated CounterArea chartBar chartDonut chartFunnel chartGaugeGitHub ActivityHeatmap calendarLeaderboardLine chartRadar chartRadial barSparklineStat CardTrackerTrend badge
Layout
AccordionApp ShellCardCollapsibleDetail LayoutEntity HeaderPage HeaderScroll AreaSeparatorSettings LayoutSplit ViewToolbar
Media
Audio PlayerCarouselCSV ViewerDOCX EditorDOCX ViewerExcel ViewerFile SystemImage compareImage CropperImage GalleryImage LightboxLocation MapPDF ViewerPowerPoint ViewerQR CodeStep PlayerVideo Player
AI Kit
Agent Status CardChat MessageChat ThreadChat WidgetConversation ListFluid OrbGrid RevealMatrix OrbModel PickerPrompt InputReasoning IndicatorRule BuilderSuggestion ChipsTool Call TimelineUsage MeterVoice InputWorkflow Canvas
Text & Effects
Background PatternGravity LettersMarqueeTerminalText AnimateText Rotate
Mobile
Action SheetBottom Tab BarFABHaptic ButtonHero HeaderInstall PromptLarge Title HeaderNotification BannerOnboarding CarouselPicker WheelPull To RefreshSlide To ConfirmSticky CTA BarSwipe DeckSwipeable Tabs
Commerce
Cart drawerCategory pickerCheckout stepsCoupon inputFavorite buttonFilter panelListing cardListing gridOrder trackerPricePrice rangePricing tableProduct galleryQuantity stepperReviewsSeller card
Marketing Sections
App Download SectionBlog Cards SectionCTA SectionFAQ SectionFeature GridFeature ShowcaseHero SectionIntegrations SectionLogo CloudMarketing FooterMarketing HeaderMarketing SectionNewsletter SectionPricing SectionStats SectionSteps SectionTeam SectionTestimonials SectionTimeline SectionVideo Section
Blocks
Admin Dashboard PageAdmin ShellAI Chat PageAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInbox PageInvoice PageKPI DashboardListing Detail PageLogin PageMarketplace Home PageMarketplace Search PageMarketplace ShellMobile App HomeOnboarding FlowOrder History PagePost Listing WizardPricing PageProfile PageRegister PageSettings PageUsers Admin Page
Templates
About PageAcademy PageAccessibility PageAffiliate PageAgency PageAI Product PageAppointment Booking PageBlog PageBlog Post PageBug Bounty PageCareers PageChangelog PageCommunity PageCompare PageContact PageCustomer Story PageCustomers PageDemo Booking PageDevelopers PageDocs Home PageDownload PageEnterprise PageEvents PageExperts PageFAQ PageFeature PageGlossary PageHelp Article PageHelp Center PageHome Services PageImpact PageIntegration Detail PageIntegrations PageJob Detail PageLanding PageLaunch PageLegal PageManifesto PagePortfolio PagePress PageProduct Tour PagePromo PageReal Estate PageReferral PageResearch Report PageRestaurant PageRoadmap PageROI Calculator PageSecurity PageSolutions PageStartups PageStatus PageStorefront PageSwitch PageTemplate Gallery PageTravel PageWaitlist PageYear in Review Page
Hooks & Utilities
AI ChatChart kitCommerceDate utilsFile exportFile typesFiltersForm validationHapticsInvoicingMotion presetsNavigationNumber formatRelative timeRomanian locationsSpreadsheetText matchTonesUIProvideruseClipboarduseConsentuseControllableStateuseCooldownuseDebounceuseKeyboardInsetuseLocaleuseLongPressuseMediaControlsuseMediaQueryuseOverflowItemsusePersistedStateuseScrollEdgesuseScrollStateuseSelectionuseShortcutuseStickToBottom
GalleryTheme

Feedback

Alert

Feedback

Alert React component for Tailwind CSS v4

TourBanner
Live props
Content
title
description
closeLabel
Appearance
variant
tone
color
size
radius
Layout
banner
Behavior
dismissible
role
State
defaultOpen
Code
import { Alert } from "@/components/ui/alert"

<Alert />
  1. Home
  2. Components
  3. Feedback
  4. Alert
Free

Alert React component for Tailwind CSS v4

v1.0.0·Added in 1.0.0

A React alert for inline messages about a page or section, from a failed payment to a maintenance banner, in three variants and six tones.

The alert sits in the page and never blocks it: server-rendered alerts show up as they are, and one that appears later (after a failed submit) fades in without pushing the page around. Its actions are real buttons that match the tone, and on a solid fill they flip to the fill's text color. With dismissible on, the close button (or Tab to it, then Enter or Space) fades the alert out while its space collapses and the content below slides up; open it again and it springs back in. With reduced motion it only fades. Closing it with focus inside moves focus to the next control instead of dropping it on the page (after a tap a text field is skipped, so the phone keyboard never pops up). Errors and warnings are announced by screen readers right away, other tones politely. On a phone two or more actions stretch into a full-width button bar under the text, and the close button keeps a 44px hit area. As a banner it spans the page: one line with the actions at the end once it is wide enough, stacked on a phone or in a narrow panel.

Alert is a free React component in the React feedback components category, written in TypeScript for React 19 and Tailwind CSS v4. It installs as source with npx wingo-ui@latest add alert, together with Button, Motion presets, Tones, useControllableState and UIProvider and the npm packages motion and lucide-react.

Add to a project

Requirements: React 19 and Tailwind CSS v4, in Next.js (App Router or Pages), Vite or React Router. Installation guide · Next.js setup · Vite setup

npx wingo-ui@latest add alert

Usage

Import Alert from @/components/ui/alert.

import { Alert, AlertAction, AlertActions, AlertDescription, AlertTitle } from "@/components/ui/alert"

export function PaymentError({ onRetry }: { onRetry: () => void }) {
  return (
    <Alert
      tone="danger"
      title="We could not process the payment"
      description="Your bank declined the card. Try another card or pay on delivery."
      actions={
        <>
          <AlertAction onClick={onRetry}>Try again</AlertAction>
          <AlertAction variant="ghost">Pay on delivery</AlertAction>
        </>
      }
      dismissible
      closeLabel="Close"
    />
  )
}

// the parts, for lists and custom layouts
export function ListingChecklist() {
  return (
    <Alert tone="warning">
      <AlertTitle>The listing cannot be published yet</AlertTitle>
      <AlertDescription>
        <ul className="list-disc ps-4">
          <li>Add at least 3 photos</li>
          <li>Fill in the floor area</li>
        </ul>
      </AlertDescription>
      <AlertActions>
        <AlertAction>Complete it</AlertAction>
      </AlertActions>
    </Alert>
  )
}

Props

  • titledefault ""
    ReactNode

    The headline, in the tone's text color. Without it the description lines up with the icon.

  • descriptiondefault ""
    ReactNode

    The message under the title. Long words wrap instead of overflowing, and links inside stay underlined.

  • closeLabeldefault "Dismiss"
    string

    Accessible name of the close button, read by screen readers. Translate it with the rest of the page.

  • variantdefault "soft"
    "soft" | "outline" | "solid"

    soft is a tinted surface for most messages, outline a hairline on the page for quieter ones, solid a full fill for urgent banners.

  • tonedefault "neutral"
    "neutral" | "brand" | "success" | "warning" | "danger" | "info"

    danger for errors, warning for things that need attention, success for done, info for tips. Also picks the default icon and the screen reader role.

  • colordefault ""
    string

    Any CSS color. Replaces the tone for the tint, the border, the fill, the icon and the actions; text on a solid fill turns black or white by lightness.

  • sizedefault "md"
    "sm" | "md"

    md for page and section messages (16px padding, 20px icon). sm for inline form messages (12px padding, 13px text, 16px icon).

  • radiusdefault "md"
    "none" | "sm" | "md" | "lg" | "full"

    Corner shape: 0, 12, 16 or 24px; full falls back to 24px. A banner is always square.

  • bannerdefault false
    boolean

    A full-bleed page banner: no radius, a bottom border, the content centered in max-w-5xl. It lays out by its own width: one line with the actions at the end from 672px, stacked below that. At the very top of a phone screen, add pt-[env(safe-area-inset-top)].

  • dismissibledefault false
    boolean

    Shows a close button. Pressing it sets open to false and the alert collapses out.

  • defaultOpendefault true
    boolean

    Starts visible. A server-rendered alert shows up at once and one mounted later fades in; keep it mounted and flip open to collapse it out and expand it back.

  • open
    boolean

    Controlled visibility. When set, the parent decides whether a dismiss really closes it.

  • onOpenChange
    (open: boolean) => void

    Called with false when the close button is pressed, controlled or not.

  • icon
    ReactNode

    The leading icon. Defaults per tone: Info for neutral and info, Sparkles for brand, CircleCheck for success, TriangleAlert for warning, CircleAlert for danger. Pass null to hide it; the text then starts at the edge.

  • actions
    ReactNode

    Buttons under the text, usually AlertAction: a small Button (ButtonProps) in the alert's tone and color, solid by default (pass variant for secondary actions) and inverted on a solid alert so it always reads. On a phone two or more share the alert's full width like a native button bar; in a wide banner they sit at the end of the line.

  • children
    ReactNode

    Extra content under the description, or the parts (AlertTitle, AlertDescription, AlertActions) for full control over lists, links and custom layouts.

  • roledefault ""
    "alert" | "status" | "none"

    The live region. Unset (the empty option), it follows the tone: "alert" for danger and warning (announced at once), "status" for the rest (announced politely). "none" adds no role, for alerts that are part of the page from the start.

  • classNames
    Partial<Record<"wrapper" | "container" | "icon" | "content" | "title" | "description" | "actions" | "close", string>>

    Extra classes for the inner parts. wrapper is the full-width collapsing element around the alert (put grid or flex placement there); container is the centered row of a banner.

  • className
    string

    Extra classes for the alert surface, merged last. Override the tone vars here, e.g. [--tone-soft:...]. In a flex column or grid the collapse also takes the parent's gap along, so nothing snaps when it closes.

Parts

  • AlertTitle

    component

    The headline as a child of Alert, sized by the alert's size and colored by its tone. Use it instead of the title prop when the headline needs markup. Takes any div prop.

  • AlertDescription

    component

    The message under the title. Takes paragraphs, lists and links; links stay underlined so they read as links on touch screens too. Takes any div prop.

  • AlertActions

    component

    The row of actions under the text. Wraps on phones, where two or more actions stretch into a full-width button bar, and moves to the end of the line in a wide banner.

  • AlertAction

    component

    A small Button that matches its alert: the alert's tone and color by default, solid unless you pass a variant, and inverted on a solid alert so it always reads. Takes every Button prop (loading, leftIcon, onClick, asChild).

    • variantdefault "solid"
      "solid" | "soft" | "outline" | "ghost" | "link"

      Button variant; use ghost or outline for secondary actions.

    • sizedefault "sm"
      ButtonSize

      Button size; sm fits the alert's padding.

    • tone
      Tone

      Overrides the alert's tone for this action.

  • AlertProps

    type

    Props of Alert, for wrappers that forward them.

  • AlertTone

    type

    The tone union: neutral, brand, success, warning, danger, info.

Examples

Tones

Six tones in the soft variant, each with its own icon. Danger and warning are announced right away.

Variants

soft, outline and solid. AlertAction follows the tone, and flips to the fill's text color on solid.

Dismissible

The close button collapses the alert and the card below slides up. Bring it back to see it expand in.

Inline form message

size sm under a field, opened and closed by the validation. aria-describedby links it to the input.

Page banner

banner spans the page. It lays out by its own width: one line when wide, stacked here and on a phone.

Custom color and icon

Any CSS color replaces the tone; text on a solid fill turns black or white by itself.

Parts

AlertTitle, AlertDescription and AlertActions for lists, links and custom layouts.

Without a title or icon

The description lines up with the icon, and with icon={null} the text starts at the edge.

Dependencies

motionlucide-reactbuttonmotiontonesuse-controllable-stateui-config

Files

  • components/ui/alert.tsx

FAQ

Is the React Alert component free?

Yes. The source is free and needs no account: copy it from the Code tab or install it with the CLI.

How do I install Alert?

Run npx wingo-ui@latest add alert. It also adds the Wingo UI items it builds on (Button, Motion presets, Tones, useControllableState and UIProvider) and the npm packages motion and lucide-react. With shadcn, run npx shadcn@latest add https://wingo-ui.com/r/alert.json.

How does Alert behave on phones?

On a phone two or more actions stretch into a full-width button bar under the text, and the close button keeps a 44px hit area. As a banner it spans the page: one line with the actions at the end once it is wide enough, stacked on a phone or in a narrow panel.

See also

Alert DialogBadgeButtonToneslibMotion presetslib

Used in

Onboarding FlowLogin PageOrder trackerCheckout stepsCSV ImportAPI Keys PageAutomation Builder PageCheckout PageCRM Contact PageCRM Pipeline PageError PagesInvoice Page

and 5 more.

More React feedback components

ToastProgressBannerCookie ConsentEmpty StateNotification Bell
All 13 React feedback components

Articles using this component

  • Sonner Alternative for React: 4 Toast Libraries Compared

    Comparisons and alternatives · Oct 9, 2026 · 11 min read

PreviousTourNext Banner

Checkout

$249.00
We could not process the payment
Your bank declined the card. Try another card or pay on delivery.
  • Tomtoc 14" laptop sleeve

    Dark gray

    $129.00
  • Logitech M650 wireless mouse

    Graphite

    $120.00

Visa •••• 4242

Expires 09/26

Retry or pay on delivery to watch it collapse