Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • Context Menu
  • Drawer
  • Footer
  • Menu
  • Navbar
  • On This Page
  • Separator
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • Text
  • Link
  • Button
  • Form
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • Input GroupNew
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Tag InputNew
    • Text EditorNew
    • Textfield
    • Time Picker
    • Time Range Picker
  • Toggle
  • Toggle Group
  • Alert
  • Avatar
  • Badge
  • Chip
  • Empty
  • Icon
  • Popover
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • SpreadsheetNew
  • Column Filter Editor
  • Pagination
  • Pick List
  • Barcode
  • QR Code
  • Calendar
  • Table
  • Attachment
  • Overview
    • Bar
    • Bullet
    • Column
    • Dot Plot
    • Dumbbell
    • Icon
    • Lollipop
    • Radial Bar
    • Range
    • Word Cloud
    • Area
    • Bump
    • Bump Area
    • Candlestick
    • Gantt
    • Horizon
    • Line
    • Slope
    • Small Multiples
    • Stream Graph
    • Funnel
    • Gauge
    • Marimekko
    • Nightingale
    • Pie
    • Treemap
    • Waffle
    • Waterfall
    • Circular Treemap
    • Convex Treemap
    • Dendrogram
    • Sunburst
    • Barcode
    • Beeswarm
    • Box Plot
    • Density Plot
    • Histogram
    • Radial Histogram
    • Ridgeline
    • Strip Plot
    • Violin Plot
    • Categorical Scatter
    • Contour
    • Hexagonal Binning
    • Quadrant
    • Scatter
    • Heatmap
    • Matrix
    • Parallel Coordinates
    • Radar
    • Arc Diagram
    • Chord Diagram
    • Flowchart
    • Network Diagram
    • Sankey
    • Euler Diagram
    • Venn Diagram
  • Bubble
  • Marker
  • Message
  • Dialog Service
  • Toast Service
API DocumentationAI Agents & Skills
Home Get Started

Feedback

TwAlert

TwAlert is a Blazor alert component for status messages. Set Color, Dense, StartIcon and EndIcon, and make it Dismissible with a bindable Dismissed value.

Last updated 10 October 2026

Alert

Provide contextual feedback messages for typical user actions with the handful of available and flexible alert messages.

This is an example alert with a link.

RAZOR
<TwAlert Id="example-alert" Class="mt-2" Color="Color.Accent">
    <p>This is an example alert with a <a href="/alert" class="underline m-0 p-0 inline">link</a>.</p>
</TwAlert>

Colors

TwAlert supports all the standard theme colors via the Color property.
Primary
Accent
Success
Danger
Warning
Info
Light
Dark
RAZOR
@foreach (Color c in ((Color[])Enum.GetValues(typeof(Color))).Take(10))
{
    <TwAlert Id="@($"{c.ToString()}-alert")" Class="mt-2" Color="@c" Dense>
        @c.ToString()
    </TwAlert>
}

Announcements

A screen reader announces an alert when it appears. An error or a warning (Color.Danger, Color.Warning) interrupts with role="alert"; every other color waits its turn with role="status". Set Role to choose for yourself, or to none for an alert that is part of the page from the start and should be read in place like any other content.
Saved. Announced when the screen reader is idle.
Payment failed. Announced at once.
Prices include tax. Read in place, never announced.
RAZOR
<TwAlert Id="status-alert" Class="mt-2" Color="Color.Success" Dense>Saved. Announced when the screen reader is idle.</TwAlert>
<TwAlert Id="urgent-alert" Class="mt-2" Color="Color.Danger" Dense>Payment failed. Announced at once.</TwAlert>
<TwAlert Id="static-alert" Class="mt-2" Color="Color.Info" Role="none" Dense>Prices include tax. Read in place, never announced.</TwAlert>

Dense alerts

You can also make alerts dense and take up less space using the Dense property.
This is a dense alert.
This is another dense alert.
RAZOR
<div class="grid grid-cols-1 md:grid-cols-2 mb-2 gap-2">
    <TwAlert Id="dense-alert-1" Class="mt-2" Color="Color.Success" Dense>
        This is a dense alert.
    </TwAlert>
    <TwAlert Id="dense-alert-2" Class="mt-2" Color="Color.Warning" Dense>
        This is another dense alert.
    </TwAlert>
</div>

Alert icons

TwAlert also supports easy icons parameters StartIcon and EndIcon. A small padding separates each icon from the text; override it with StartIconPadding and EndIconPadding.
This is a dense alert with a start icon.
This is another dense alert with an end icon.
This is an alert with a start icon.
This is another alert with an end icon.
RAZOR
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
    <TwAlert Id="icon-alert-1" Class="mt-2" Color="Color.Primary" Dense StartIcon="Icon.Wallet">
        This is a dense alert with a start icon.
    </TwAlert>
    <TwAlert Id="icon-alert-2" Class="mt-2" Color="Color.Danger" Dense EndIcon="Icon.Exclamation_Circle">
        This is another dense alert with an end icon.
    </TwAlert>
    <TwAlert Id="icon-alert-3" Class="mt-2" Color="Color.Info" StartIcon="Icon.Play">
        This is an alert with a start icon.
    </TwAlert>
    <TwAlert Id="icon-alert-4" Class="mt-2" Color="Color.Warning" EndIcon="Icon.Star">
        This is another alert with an end icon.
    </TwAlert>
</div>

Dismissible alerts

You can also make alerts dismissible by using OnDismiss or the Dismissible property set as true, setting Dismissible to true will show the X button and won't require an event callback.
This is a dense alert that is dismissible.
RAZOR
<TwAlert Id="info-alert" StartIcon="Icon.Info_Circle" Class="mt-2" Color="Color.Primary" Dense OnDismiss="@(() => HandleDismiss())">
    This is a dense alert that is dismissible.
</TwAlert>
CSHARP
@code {
    private void HandleDismiss() => ToastService.ShowInfo("Alert dismissed!", "You have dismissed the alert.");
}

Keyboard navigation

An alert is read out by screen readers when it appears. Only a dismissible alert has a control to focus.
Key What it does
Tab Moves focus to the dismiss button.
Enter or Space Dismisses the alert. Focus moves to the next control on the page.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwAlertTheme), configured via the AddTwBlazor() options callback described on the Get Started page. Every property is a set of Tailwind classes, so changes are picked up by your own Tailwind build.
Property Type Controls
TextWrapper string
Padding string
DensePadding string
StartIconPadding string
EndIconPadding string
Transition string
DismissButtonSize string
DismissButtonSpacingWithEndIcon string
DismissButtonColor string

Global Theme Configuration

These reuse shared design tokens configured once on TwBlazorTheme, rather than being unique to this component.
Property Type Controls
Colors TwBlazorPalette

Full reference: TwAlertTheme on the API docs.

On this page

  • Alert
  • Colors
  • Announcements
  • Dense alerts
  • Alert icons
  • Dismissible alerts
  • Keyboard navigation
  • Theme configuration
twblazor

The Tailwind CSS component library for Blazor. Accessible, themeable and MIT licensed.

Discord (opens in a new tab) GitHub(opens in a new tab)

Get started

  • Install guide
  • Theming
  • Class merging
  • Localization

Guides

  • Tailwind CSS with Blazor
  • Why twblazor?
  • Right to left
  • AI agents and skills

Resources

  • API documentation (opens in a new tab)
  • llms.txt (opens in a new tab)
  • MIT License (opens in a new tab)

Community

  • Contributing (opens in a new tab)
  • Code of conduct (opens in a new tab)
  • Report an issue (opens in a new tab)

twblazor is and always will be free and open source.

An unhandled error has occurred. Reload