Badges ​

The badge component provides a set of classes to style short labels, such as a status or a count.

Base class ​

The .badge class is the base class for all badge styles. Use .w-fit-content if you want the badge to fit its label.

Variants ​

There are three badge colour variants provided by default: .primary, .secondary, and .tertiary. Add the variant class alongside .badge to change the text and border colours.

If you are compiling your own version of Graupl, you can set the badge module’s $themeable variable to false to skip generating theme variants.

Custom Properties ​

The following custom properties can be used to customize the badge component:

PropertyDescriptionDefault Value
--graupl-badge-font-sizeThe font size of the badge component.var(--graupl-font-size-sm)
--graupl-badge-backgroundThe background colour of the badge component.var(--graupl-background)
--graupl-badge-colorThe text colour of the badge component.var(--graupl-color)
--graupl-badge-border-colorThe border colour of the badge component.var(--graupl-border-color)
--graupl-badge-padding-xThe horizontal padding of the badge component.var(--graupl-spacer-5)
--graupl-badge-padding-yThe vertical padding of the badge component.var(--graupl-spacer-3)
--graupl-badge-paddingThe padding of the badge component (combines y and x padding).var(--graupl-badge-padding-y) var(--graupl-badge-padding-x)
--graupl-badge-border-top-widthThe top border width of the badge component.var(--graupl-border-top-width)
--graupl-badge-border-right-widthThe right border width of the badge component.var(--graupl-border-right-width)
--graupl-badge-border-bottom-widthThe bottom border width of the badge component.var(--graupl-border-bottom-width)
--graupl-badge-border-left-widthThe left border width of the badge component.var(--graupl-border-left-width)
--graupl-badge-border-widthThe border width of the badge component (combines top, right, bottom, and left widths).var(--graupl-badge-border-top-width) var(--graupl-badge-border-right-width) var(--graupl-badge-border-bottom-width) var(--graupl-badge-border-left-width)
--graupl-badge-border-top-styleThe top border style of the badge component.var(--graupl-border-top-style)
--graupl-badge-border-right-styleThe right border style of the badge component.var(--graupl-border-right-style)
--graupl-badge-border-bottom-styleThe bottom border style of the badge component.var(--graupl-border-bottom-style)
--graupl-badge-border-left-styleThe left border style of the badge component.var(--graupl-border-left-style)
--graupl-badge-border-styleThe border style of the badge component (combines top, right, bottom, and left styles).var(--graupl-badge-border-top-style) var(--graupl-badge-border-right-style) var(--graupl-badge-border-bottom-style) var(--graupl-badge-border-left-style)
--graupl-badge-border-top-left-radiusThe top-left border radius of the badge component.var(--graupl-border-top-left-radius)
--graupl-badge-border-top-right-radiusThe top-right border radius of the badge component.var(--graupl-border-top-right-radius)
--graupl-badge-border-bottom-right-radiusThe bottom-right border radius of the badge component.var(--graupl-border-bottom-right-radius)
--graupl-badge-border-bottom-left-radiusThe bottom-left border radius of the badge component.var(--graupl-border-bottom-left-radius)
--graupl-badge-border-radiusThe border radius of the badge component (combines top-left, top-right, bottom-right, and bottom-left radii).var(--graupl-badge-border-top-left-radius) var(--graupl-badge-border-top-right-radius) var(--graupl-badge-border-bottom-right-radius) var(--graupl-badge-border-bottom-left-radius)

Sass variables ​

The following Sass variables can be used to customize the generation of the badge component:

VariableDescriptionDefault Value
$selector-baseThe selector base for the component."."
$modifier-selector-baseThe selector base for component modifiers."."
$themeableFlag to generate theme modifiers.true
$generate-base-theme-mapA flag to generate the base theme maps for badge variants.true
$badge-selector-baseThe selector base for the badge component."."
$badge-selectorThe badge component selector."badge"
$badge-theme-selector-baseThe selector base for the badge theme component modifiers."."
$badge-theme-selector-prefixThe badge theme component modifier selector prefix.""
$badge-theme-mappingsA map of properties and color shades used to generate all badge variants.()
$badge-theme-mapA map of all properties, colors, and color shades used to generate all badge variants.()