Skip to content
Razor catalogue

On this page

@addTagHelper *, Webority.Ui.Razor

Tones

Pick a tone because it signals something, not to decorate a row of peer badges.

The tones
Primary Approved Needs review Overdue Info
Show code
<app-badge tone="Primary">Primary</app-badge>
<app-badge tone="Success">Approved</app-badge>
<app-badge tone="Warning">Needs review</app-badge>
<app-badge tone="Danger">Overdue</app-badge>
<app-badge tone="Info">Info</app-badge>

Counts and labels

Use a count beside its label for a number, and a one- or two-word tag next to a title.

A count and a label
Inbox 3 Lightning Report New
Show code
<span>Inbox <app-badge tone="Danger">3</app-badge></span>
<span>Lightning Report <app-badge tone="Primary">New</app-badge></span>

Dot style

Switch to the compact dot when the badge only needs to flag that something is there.

Dot and no dot
3 3
Show code
<app-badge tone="Danger">3</app-badge>
<app-badge tone="Danger" dot="true">3</app-badge>

Content shape

Keep badge content to a word or a number; a sentence belongs in the page, not the badge.

Number, label and rich content
12 New 3
Show code
<app-badge tone="Primary">12</app-badge>
<app-badge tone="Success">New</app-badge>
<app-badge tone="Info"><strong>3</strong></app-badge>

Every option

Every value of every prop, one cell each.

tone: neutral | primary | success | warning | danger | info

(none, default)
Badge
tone="neutral"
Badge
tone="primary"
Badge
tone="success"
Badge
tone="warning"
Badge
tone="danger"
Badge
tone="info"
Badge

dot

(default, no dot)
3
dot, combined with tone
3

content shape

number
12
short label
New
node children
3
empty children

tooltip

(default, no tooltip)
Badge
tooltip="Shown on hover or focus"
Badge

tooltipPlacement: auto | top | bottom | start | end

tooltip-placement="auto" (default)
Badge
tooltip-placement="top"
Badge
tooltip-placement="bottom"
Badge
tooltip-placement="start"
Badge
tooltip-placement="end"
Badge

className

class="analytics-flag"
Tracked

Guidance

What to do, and what to avoid.

Use it when

  • A count sits beside a label, such as an unread inbox or a pending queue.
  • A short static tag marks something: New, Beta, Pro.
  • You need a tiny inline emphasis that fits on the same line as its text.

Reach for something else when

  • You are showing a status mapped from an enum. → AppStatusBadge
  • The token should be removable (a filter or tag). → AppChip
  • It performs an action when clicked. → AppButton
  • It is a persistent inline message. → AppAlert

Keep badge text to a word or a number

Do
Notifications 12

A short count attached to its label. The badge reads instantly.

Avoid
This item was updated 3 minutes ago by an editor

A sentence in a badge is the wrong tool. Badges hold a word or a number, not prose.

Use one tone for one tag

Do
New

A neutral New tag in one intentional tone.

Avoid
New New New

The same label in three tones invents meaning that is not there. One tag, one tone.

Reference

Try every prop, read the full list, and check keyboard and screen reader behaviour.

(none) neutral primary success warning danger info
(auto) top bottom start end
New
React, generated from the controls
<AppBadge>New</AppBadge>
Razor, the same props
<app-badge>New</app-badge>

5 props. The 4 most used come first.

Used on most screens 4 props

PropTypeDefaultDescription
tonedefault - neutral | primary | success | warning | danger | info - The badge colour.
dotdefault false bool false Shows the badge in its compact dot style.
tooltipdefault - string - A tooltip on hover or focus that flips to stay on screen.
tooltip-placementdefault auto auto | top | bottom | start | end auto The preferred tooltip side. auto picks the side with the most room.

Less common 1 props

PropTypeDefaultDescription
(content)default - string - Badge content: a short label or a number.

Screen reader

2 notes
  • The badge is a plain inline element with no role of its own, so the text inside it carries the meaning.
  • A tooltip opens on hover and on keyboard focus.

Do and avoid

2 pairs

Keep badge text to a word or a number

Do
Notifications 12

A short count attached to its label. The badge reads instantly.

Avoid
This item was updated 3 minutes ago by an editor

A sentence in a badge is the wrong tool. Badges hold a word or a number, not prose.

Use one tone for one tag

Do
New

A neutral New tag in one intentional tone.

Avoid
New New New

The same label in three tones invents meaning that is not there. One tag, one tone.