Liking cljdoc? Tell your friends :D

x-badge

A small indicator that displays a count, a text label, or a dot. Supports five semantic colour variants, two sizes, pill shape, and dot-only mode.


Tag

<x-badge></x-badge>

Attributes

AttributeTypeDefaultDescription
variantenum"neutral"Colour variant: neutral info success warning error
sizeenum"md"Size: sm md
countnumberNumeric value to display. Capped at max.
maxnumber99Maximum displayed count. Values above show as "<max>+".
textstringShort label string (e.g. "NEW", "BETA").
dotbooleanfalseDot-only mode — no text shown.
pillbooleanfalseFully rounded pill shape.
aria-labelstringOverrides the accessible label on the host.
aria-describedbystringReferences an element that describes the badge.

Display mode priority

ConditionModeRendered content
Slotted content presentslotCustom slotted content
count attribute presentcountNumber (capped at max)
text attribute presenttextText string
dot attribute presentdotDot, no text
None of the aboveemptyHidden

Properties

PropertyTypeReflects attribute
variantstringvariant
sizestringsize
pillbooleanpill
dotbooleandot
countnumbercount
maxnumbermax
textstringtext

Parts

PartDescription
badgeOuter container element
labelText content <span>

Examples

Colour variants

<x-badge variant="neutral">Neutral</x-badge>
<x-badge variant="info">Info</x-badge>
<x-badge variant="success">Success</x-badge>
<x-badge variant="warning">Warning</x-badge>
<x-badge variant="error">Error</x-badge>

Count with cap

<x-badge variant="error" count="7"></x-badge>
<x-badge variant="error" count="999" max="99"></x-badge>

Text labels

<x-badge variant="success" text="NEW"></x-badge>
<x-badge variant="warning" text="BETA"></x-badge>

Small size

<x-badge variant="info" size="sm" count="5"></x-badge>

Dot

<x-badge variant="error" dot></x-badge>

Pill

<x-badge variant="success" pill count="3"></x-badge>

ClojureScript (hiccup renderer)

[:x-badge {:variant "error" :count "23"}]
[:x-badge {:variant "success" :text "NEW"}]
[:x-badge {:variant "error" :dot true}]

Can you improve this documentation?Edit on GitHub

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close