Anchor Design System

Badge3.0

Badges are used as a small numerical value or status descriptor for UI elements.

Installation

npm i @tryg/ui-library

Usage

Individual only imports the desired component, and only needs to be included once within the application. Which is beneficial to keep the application size small.

Webcomponent
  <script type="module">
    import { defineCustomElement } from '@tryg/ui-library/dist/components/anchor-badge';
    defineCustomElement();
  </script>
  <anchor-badge>New message</anchor-badge>

Global only needs to be defined once in the application, but it will import all components even the ones that are not in use..

Webcomponent
  <script type="module">
    import { defineCustomElements } from '@tryg/ui-library/dist/loader';
    defineCustomElements();
  </script>
  <anchor-badge>New message</anchor-badge>

Sizes

Pass the size prop with value normal or small to display the badge with different sizes.

Webcomponent
<anchor-badge size="normal">New message</anchor-badge>
<anchor-badge size="small">New message</anchor-badge>

Variants

Pass the variant prop with value highlight, helpful, or neutral to display the different badge variants.

Webcomponent
<anchor-badge type="highlight">New message</anchor-badge>
<anchor-badge type="helpful">New message</anchor-badge>
<anchor-badge type="neutral">New message</anchor-badge>

Modes

Pass the mode prop with value on-light, or on-light to display the different modes of the badge.

Webcomponent
<anchor-badge type="highlight" mode="on-dark">New message</anchor-badge>
<anchor-badge type="helpful" mode="on-dark">New message</anchor-badge>
<anchor-badge type="neutral" mode="on-dark">New message</anchor-badge>

Accessibility

It's not advisable to depend on the badge's content for accurate announcement. Instead, consider supplying a comprehensive description, such as using aria-label.

API

anchor-badge

Properties

PropertyAttributeDescriptionTypeDefault
modemodeGive the badge a mode to specify use on light or dark backgrounds."on-dark" | "on-light"'on-light'
sizesizeGive the badge a size"normal" | "small"'normal'
typetypeGive the badge a type to change its appearance"helpful" | "highlight" | "neutral"'neutral'
uuiduuidGive this instance of badge a custom ID, default generated by uuidV4.stringuuidv4()

CSS Custom Properties

NameDescription
--badge-bg-color-helpful-on-darkBackground color for helpful badge in dark mode
--badge-bg-color-helpful-on-lightBackground color for helpful badge in light mode
--badge-bg-color-highlight-on-darkBackground color for highlight badge in dark mode
--badge-bg-color-highlight-on-lightBackground color for highlight badge in light mode
--badge-bg-color-neutral-on-darkBackground color for neutral badge in dark mode
--badge-bg-color-neutral-on-lightBackground color for neutral badge in light mode
--badge-border-color-neutral-on-darkBorder color for neutral badge in light mode
--badge-text-color-helpful-on-darkText color for helpful badge in dark mode
--badge-text-color-helpful-on-lightText color for helpful badge in light mode
--badge-text-color-highlight-on-darkText color for highlight badge in dark mode
--badge-text-color-highlight-on-lightText color for highlight badge in light mode
--badge-text-color-neutral-on-darkText color for neutral badge in dark mode
--badge-text-color-neutral-on-lightText color for neutral badge in light mode
--badge-text-line-height-normalLine height for normal badge
--badge-text-line-height-smallLine height for small badge
--badge-text-size-normalFont size for normal badge
--badge-text-size-smallFont size for small badge

Built with StencilJS

Anchor versionStatusNotes
3.0Ready for ImplementationThis component is in sync with Figma.

On this page