Zubra UI
Code for
GitHub

status-badge

A small label for a status, a count or a category. variant is neutral, primary, success, warning, danger or outline; dot adds a coloured dot before the text. The colour is never the only signal: the text says it.

Paid

This one has no events: it shows what it's given.

Every variant

DraftNewPaidDue soonOverdueArchivedOnline

Source: status-badge.zb, and its registry item.

Install

Compiled (any project)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/status-badge.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/status-badge.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/status-badge.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/status-badge.json
One file, no dependencies (3.3 KB gzipped)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/status-badge.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/status-badge.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/status-badge.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/element/status-badge.json
.zb source (to edit it with Zubra)
npx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/status-badge.jsonpnpm dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/status-badge.jsonyarn dlx shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/status-badge.jsonbunx --bun shadcn@latest add https://zubra-js.github.io/zubra-ui/r/src/status-badge.json
No build: a script tag, straight from this site
HTML
<link rel="stylesheet" href="https://zubra-js.github.io/zubra-ui/themes/default.css">
<script type="module" src="https://zubra-js.github.io/zubra-ui/cdn/status-badge.js"></script>

The compiled install writes src/components/zubra/status-badge.js and the theme, and adds @zubra/runtime to your dependencies. The one-file install writes the same path as a plain custom element that needs nothing installed (or download it and load it with a <script type="module">); it's smaller on a page with one to three components, the shared runtime with more.

Usage

index.html
<status-badge variant="success">
  Paid
</status-badge>

<script type="module">
  import './components/zubra/status-badge.js';

  const element = document.querySelector('status-badge');
  element.dot = true;
</script>
Example.jsx
import './components/zubra/status-badge.js';

const dot = true;

export function StatusBadgeExample() {
  return (
    <status-badge variant="success" dot={dot}>
      Paid
    </status-badge>
  );
}
Example.vue
<script setup>
import './components/zubra/status-badge.js';
const dot = true;
</script>

<template>
  <status-badge variant="success" :dot.prop="dot">
    Paid
  </status-badge>
</template>

<!-- vite.config.js: vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.includes('-') } } }) -->
Example.svelte
<script>
  import './components/zubra/status-badge.js';
  const dot = true;
</script>

<status-badge variant="success" {dot}>
  Paid
</status-badge>
example.component.ts
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import './components/zubra/status-badge.js';

@Component({
  selector: 'app-status-badge-example',
  schemas: [CUSTOM_ELEMENTS_SCHEMA],
  template: `
    <status-badge variant="success" [dot]="dot">
      Paid
    </status-badge>
  `,
})
export class StatusBadgeExample {
  dot = true;
}

API

Properties (each is also an HTML attribute of the same name, unless marked)
PropertyTypeDefault
variant"neutral" | "primary" | "success" | "warning" | "danger" | "outline""neutral"
dotbooleanfalse
Slots
SlotFor
(default)The badge's text.

Size

0.9 KB gzipped for the component, plus the runtime, which every Zubra component on a page shares (up to 22.1 KB, all of it). On its own, with the parts of the runtime it uses, it's 17.1 KB.

Theme

Every component reads shadcn/ui's CSS variables, so any shadcn theme works. Pick a look or a colour, or paste a theme's CSS.

Look: colours, fonts, corners and motion

Accent colour