Anchor Design System

Badge3.0

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

Installation

npm i @tryg/vue-ui-library

Usage

Install the component library as a Vue plugin. This globally registers all Anchor components.

main.js
import { createApp } from 'vue';
import { ComponentLibrary } from '@tryg/vue-ui-library';
import App from './App.vue';

const app = createApp(App);
app.use(ComponentLibrary);
app.mount('#app');
YourComponent.vue
<template>
  <anchor-badge>New message</anchor-badge>
</template>

Import only the components you need for optimal bundle size.

YourComponent.vue
<script setup>
import { AnchorBadge } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-badge>New message</anchor-badge>
</template>

Sizes

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

Vue component
<script setup>
import { AnchorBadge } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-badge size="normal">New message</anchor-badge>
  <anchor-badge size="small">New message</anchor-badge>
</template>

Variants

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

Vue component
<script setup>
import { AnchorBadge } from '@tryg/vue-ui-library';
</script>
<template>
  <anchor-badge type="highlight">New message</anchor-badge>
  <anchor-badge type="helpful">New message</anchor-badge>
  <anchor-badge type="neutral">New message</anchor-badge>
</template>

Modes

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

Vue component
<script setup>
import { AnchorBadge } from '@tryg/vue-ui-library';
</script>
<template>
  <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>
</template>

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