Skip to main content
twblazor
Home
  • Get started
  • Tailwind with Blazor
  • Why twblazor?
  • Theme
  • Class Merge
    • Configuring localization
    • RTL Provider
  • Breadcrumb
  • Card
  • Carousel
  • Collapse
  • DrawerNew
  • Footer
  • MenuNew
  • Navbar
  • On This PageNew
  • Sidebar
  • Stepper
  • Tabs
  • Tree List
  • Container
  • Flex
  • Grid
  • TextNew
  • Link
  • Button
  • FormNew
    • AutocompleteNew
    • Checkbox
    • Color Picker
    • Date Picker
    • Date Range Picker
    • Datetime Picker
    • Datetime Range Picker
    • File Upload
    • NumericNew
    • Masked InputNew
    • Radio Button
    • Range SliderNew
    • RatingNew
    • Select
    • Slider
    • Switch
    • Textfield
    • Time Picker
    • Time Range Picker
  • Alert
  • Avatar
  • BadgeNew
  • Chip
  • Icon
  • PopoverNew
  • Progress
  • Skeleton
  • Spinner
  • Tooltip
  • Data Table
  • Pagination
  • Pick List
  • BarcodeNew
  • QR CodeNew
  • CalendarNew
  • Table
  • AttachmentNew
  • 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

TwBadge

TwBadge overlays a count, text label or dot on a corner of any content - an icon, avatar or button.

Last updated 3 November 2026

Please be aware this component is new, may have bugs and/or be subject to change. Please report any bugs at https://github.com/twblazor/twblazor/issues.

Basic usage

Wrap any content and set Count, Content or Dot to overlay a badge. On a primary/purple button, use Color="Color.Accent" so the badge doesn't blend in.
5 New JD
RAZOR
<div class="flex items-center gap-8">
    <TwBadge Count="5"><TwIcon Icon="Icon.Bell" Class="text-2xl" /></TwBadge>
    <TwBadge Content="New" Color="Color.Accent"><TwButton Label="Inbox" Color="Color.Primary" /></TwBadge>
    <TwBadge Dot><TwAvatar Name="Jane Doe" /></TwBadge>
</div>

Count with cap

Use Max to cap a large count, e.g. 99+.
3 99+ 10+
RAZOR
<div class="flex items-center gap-8">
    <TwBadge Count="3"><TwIcon Icon="Icon.Envelope" Class="text-2xl" /></TwBadge>
    <TwBadge Count="150"><TwIcon Icon="Icon.Envelope" Class="text-2xl" /></TwBadge>
    <TwBadge Count="120" Max="10"><TwIcon Icon="Icon.Envelope" Class="text-2xl" /></TwBadge>
</div>

Placement

Set Placement to choose the corner. Defaults to BadgePlacement.TopEnd.
A1 A1 A1 A1
RAZOR
<div class="flex items-center gap-8">
    <TwBadge Count="1" Placement="BadgePlacement.TopStart"><TwAvatar Name="A" /></TwBadge>
    <TwBadge Count="1" Placement="BadgePlacement.TopEnd"><TwAvatar Name="A" /></TwBadge>
    <TwBadge Count="1" Placement="BadgePlacement.BottomStart"><TwAvatar Name="A" /></TwBadge>
    <TwBadge Count="1" Placement="BadgePlacement.BottomEnd"><TwAvatar Name="A" /></TwBadge>
</div>

Colors

Badges default to Color.Primary. Choose any of the theme colors.
1 1 1 1
RAZOR
<div class="flex items-center gap-8">
    <TwBadge Count="1"><TwIcon Icon="Icon.Bell" Class="text-2xl" /></TwBadge>
    <TwBadge Count="1" Color="Color.Success"><TwIcon Icon="Icon.Bell" Class="text-2xl" /></TwBadge>
    <TwBadge Count="1" Color="Color.Warning"><TwIcon Icon="Icon.Bell" Class="text-2xl" /></TwBadge>
    <TwBadge Count="1" Color="Color.Info"><TwIcon Icon="Icon.Bell" Class="text-2xl" /></TwBadge>
</div>
On a purple/primary surface use Accent, Light or Dark so the badge doesn't blend in.
3 3 3
RAZOR
<div class="flex items-center gap-8">
    <TwBadge Count="3" Color="Color.Accent"><TwButton Label="Inbox" Color="Color.Primary" /></TwBadge>
    <TwBadge Count="3" Color="Color.Light"><TwButton Label="Inbox" Color="Color.Primary" /></TwBadge>
    <TwBadge Count="3" Color="Color.Dark"><TwButton Label="Inbox" Color="Color.Primary" /></TwBadge>
</div>

Accessibility

The count or label pill is exposed with role="status". Pass AriaLabel (e.g. <TwBadge Count="3" AriaLabel="3 unread messages" />) so a screen reader announces the count with context rather than a bare number. A Dot badge is decorative and is hidden with aria-hidden.

Keyboard navigation

This component is not interactive, so it has no keyboard controls of its own and is not a Tab stop. Anything interactive you place inside it keeps its own keyboard behaviour.

Theme configuration

Styling is controlled by TwBlazorTheme.Components (a TwBadgeTheme), 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
Wrapper string
Badge string
Dot string
TopStart string
TopEnd string
BottomStart string
BottomEnd 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: TwBadgeTheme on the API docs.

On this page

  • Basic usage
  • Count with cap
  • Placement
  • Colors
  • Accessibility
  • 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