Badges

A basic badge utility style for simple inline notifications or content notes.

Examples (anchor)

Please note. The badges will inherit whatever normalize/reset styles are present requiring only minor adjustments to suit base font property values, but as demonstrated they've been designed to work seamlessly with the StyleMods content styles.

Heading 1 New

Heading 2 New

Heading 3 New

Heading 4 New

Heading 5 New
Heading 6 New

Paragraph New

Example HTML
<h1>Heading 1 <span class="badge">New</span></h1>
<h2>Heading 2 <span class="badge">New</span></h2>
<h3>Heading 3 <span class="badge">New</span></h3>
<h4>Heading 4 <span class="badge">New</span></h4>
<h5>Heading 5 <span class="badge">New</span></h5>
<h6>Heading 6 <span class="badge">New</span></h6>
<p>Paragraph <span class="badge">New</span><p>
<button>Button <span class="badge">New</span></button>

Fixed light and dark (anchor)

Heading 1 New

Heading 2 New

Heading 3 New

Heading 4 New

Heading 5 New
Heading 6 New

Paragraph New

Heading 1 New

Heading 2 New

Heading 3 New

Heading 4 New

Heading 5 New
Heading 6 New

Paragraph New

Example HTML
<div>
<h1>Heading 1 <span class="badge badge-light">New</span></h1>
<h2>Heading 2 <span class="badge badge-light">New</span></h2>
<h3>Heading 3 <span class="badge badge-light">New</span></h3>
<h4>Heading 4 <span class="badge badge-light">New</span></h4>
<h5>Heading 5 <span class="badge badge-light">New</span></h5>
<h6>Heading 6 <span class="badge badge-light">New</span></h6>
<p>Paragraph <span class="badge badge-light">New</span><p>
<button class="btn-light">Button <span class="badge badge-light">New</span></button>
</div>
<div>
<h1>Heading 1 <span class="badge badge-dark">New</span></h1>
<h2>Heading 2 <span class="badge badge-dark">New</span></h2>
<h3>Heading 3 <span class="badge badge-dark">New</span></h3>
<h4>Heading 4 <span class="badge badge-dark">New</span></h4>
<h5>Heading 5 <span class="badge badge-dark">New</span></h5>
<h6>Heading 6 <span class="badge badge-dark">New</span></h6>
<p>Paragraph <span class="badge badge-dark">New</span><p>
<button class="btn-dark">Button <span class="badge badge-dark">New</span></button>
</div>

Using the module (anchor)

Load StyleMods as demonstrated (change file path as required) then include the Sass mixin anywhere below.

custom.scss
@use "stylemods/scss" as *;
@include badges-css;

See the using modules page for more information including how to compile the modules in cascade layers and include and reuse them in multiple source files.

Using the framework (anchor)

Using the recommended custom setup enable the styles in an overrides document:

overrides.scss
@use "stylemods/scss/configuration" as *;
$enable-badges: true;

Include the overrides and the framework styles with your custom document for compiling the framework:

custom.scss
@use "overrides";
@use "stylemods/scss/stylemods";

See using the framework for more information including how the styles can also be compiled within cascade layers.

Source code (anchor)

The modules and the framework follow the same methods for customizing the default values and using the CSS variables to create custom theme documents. See the customizing page for more information.

badges.scss
// ---------------------------------------------------------- 
// Badges
// ----------------------------------------------------------
$badge-text-color:        var(--badge-text, CanvasText) !default;
$badge-font-size:         var(--badge-fs, 0.65em) !default;
$badge-font-weight:       var(--badge-fw, 600) !default;
$badge-padding-block:     var(--badge-py, 0.375em) !default;
$badge-padding-inline:    var(--badge-px, 0.65em) !default;
$badge-border-color:      var(--badge-bd-color, color-mix(in srgb, CanvasText 15%, Canvas)) !default;
$badge-radius:            var(--badge-radius, 0.188rem) !default;
$badge-background-color:  var(--badge-bg, color-mix(in srgb, CanvasText 4%, Canvas)) !default;

@mixin badges-css {

:where(.badge) {
  color: $badge-text-color;
  font-size: $badge-font-size;
  font-weight: $badge-font-weight;
  text-align: center;
  line-height: 1;
  position: relative;
  inset-block-start: -0.125em;
  display: inline-block;
  vertical-align: baseline;
  padding-block: $badge-padding-block;
  padding-inline: $badge-padding-inline;
  border: 1px solid $badge-border-color;
  border-radius: $badge-radius;
  background-color: $badge-background-color;
}

.badge-light {
  color-scheme: light;
}

.badge-dark {
  color-scheme: dark;
}

} // end badges-css