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.
This one has no events: it shows what it's given.
Every variant
Source: status-badge.zb, and its registry item.
Install
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
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
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
<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
<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>import './components/zubra/status-badge.js';
const dot = true;
export function StatusBadgeExample() {
return (
<status-badge variant="success" dot={dot}>
Paid
</status-badge>
);
}<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('-') } } }) --><script>
import './components/zubra/status-badge.js';
const dot = true;
</script>
<status-badge variant="success" {dot}>
Paid
</status-badge>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
| Property | Type | Default |
|---|---|---|
variant | "neutral" | "primary" | "success" | "warning" | "danger" | "outline" | "neutral" |
dot | boolean | false |
| Slot | For |
|---|---|
(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.