Badge

Priority Badge

Priority as strokes: the level reads from the bars' shape in black-and-white print and for colour-blind readers.

  • badge
  • priority
  • a11y
  • issue

Preview

1440pxHost theme

Use it with AI

  1. 1. Copy the link.
  2. 2. Write to your agent in your own words and drop the link into the sentence.
  3. 3. The agent opens the link and installs the component from the registry.

put this in the header: https://vibeui.ru/c/badge-010?lang=en

Show the full instructions

What the link says, spelled out. Use it when your agent cannot open links — paste this text instead.

# Install and place "badge-010" (Priority Badge) from VibeUI

## 1. Install first — do not skip, do not recreate
Run this exact command before writing any code:
npx shadcn@latest add https://vibeui.ru/r/badge-010.json

Registry item: https://vibeui.ru/r/badge-010.json
Installs to: components/vibeui/badge-010.tsx (the exact path follows this project's components.json aliases).
npm dependencies: none.
Registry dependencies: none.

Install it from the registry. Do not recreate it from the description,
do not substitute a similar component from another library, and do not
rewrite it to match the project's existing style.

## 2. What it is
Priority as strokes: the level reads from the bars' shape in black-and-white print and for colour-blind readers.

A priority badge: a column of four bars plus a word. The level reads from shape rather than colour. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Badge010 } from "@/components/vibeui/badge-010"

<Badge010 level={2} />

Read the installed file for the full prop list.

## 4. Where to place it
This is a small inline component. Put it exactly where the user asked,
inside the existing markup. Do not create a new page, section or
wrapper for it. If a similar control already sits in that spot,
replace it instead of adding a second one.

Placement: ___
(The user fills this line in. If it is still blank, ask where to put it
instead of guessing.)

## 5. Keep exactly as installed
- the local --vibeui-badge-010-* palette — do not swap it for your theme tokens
- the bars as the primary cue: red and orange are indistinguishable down a long list
- the word next to them — bars qualify the level, they do not name it
- the rule that level one is the highest: reversing it confuses readers
- the aria-label carrying the level and the total number of steps
- the rising bar heights: equal bars read as signal strength, not priority

## 6. You may change
- level — 1 to 4
- label — your own wording
- total — how many steps exist
- the level colours for your palette

## 7. Rules
- People cannot tell more than four steps apart: five bars read as four.
- Priority and status are different things: do not substitute one for the other.
- Bar heights are written for four positions; add nth-child rules for more.
- Do not lift the CSS variables into globals.css: the component has to stay a single file.

## 8. Verify
- it renders with no console errors;
- it looks like the preview on the VibeUI page you copied this from;
- if it does not, you changed something listed in section 5 — put it back.

For developers

npx shadcn@latest add https://vibeui.ru/r/badge-010.json
https://vibeui.ru/r/badge-010.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-badge-010-*. Серверный: хуков нет. Полоски растут по высоте, число залитых считается как total − level + 1, поэтому первый уровень самый заметный. Уровень окрашивается через data-level, но цвет только усиливает форму. Полное значение уходит в aria-label, полоски и подпись помечены aria-hidden.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Badge010Props = Omit<
  ComponentPropsWithoutRef<"span">,
  "children"
> & {
  /** 1 — самый высокий приоритет. */
  level?: 1 | 2 | 3 | 4
  label?: string
  total?: number
}

// Идея компонента: приоритет штрихами, а не цветом. Три залитых полоски из
// четырёх читаются в чёрно-белой печати, при дальтонизме и краем глаза в
// длинном списке, где красный от оранжевого не отличить. Подпись остаётся
// словом: полоски уточняют степень, а не заменяют название.
const STYLES = `
:where([data-vibeui-block="badge-010"]){
--vibeui-badge-010-bg:oklch(0.96 0.004 265);
--vibeui-badge-010-fg:oklch(0.32 0.014 265);
--vibeui-badge-010-border:oklch(0.89 0.006 265);
--vibeui-badge-010-track:oklch(0.87 0.008 265);
--vibeui-badge-010-mark:oklch(0.45 0.014 265);
--vibeui-badge-010-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="badge-010"]{
display:inline-flex;align-items:center;gap:0.4375rem;
height:1.5rem;padding:0 0.625rem 0 0.5rem;
border:1px solid var(--vibeui-badge-010-border);border-radius:0.4375rem;
background:var(--vibeui-badge-010-bg);color:var(--vibeui-badge-010-fg);
font-family:var(--vibeui-badge-010-font);font-size:0.75rem;font-weight:600;
line-height:1;white-space:nowrap;vertical-align:middle;
}
[data-vibeui-block="badge-010"][data-level="1"]{--vibeui-badge-010-mark:oklch(0.55 0.19 25)}
[data-vibeui-block="badge-010"][data-level="2"]{--vibeui-badge-010-mark:oklch(0.62 0.16 55)}
[data-vibeui-block="badge-010"][data-level="3"]{--vibeui-badge-010-mark:oklch(0.6 0.1 230)}
/* Полоски: степень видно формой, цвет только усиливает. */
[data-vibeui-block="badge-010"] [data-part="bars"]{display:inline-flex;align-items:flex-end;gap:0.125rem;flex:none}
[data-vibeui-block="badge-010"] [data-part="bar"]{
width:0.1875rem;border-radius:9999px;background:var(--vibeui-badge-010-track);
}
[data-vibeui-block="badge-010"] [data-part="bar"][data-on="true"]{background:var(--vibeui-badge-010-mark)}
[data-vibeui-block="badge-010"] [data-part="bar"]:nth-child(1){height:0.375rem}
[data-vibeui-block="badge-010"] [data-part="bar"]:nth-child(2){height:0.5625rem}
[data-vibeui-block="badge-010"] [data-part="bar"]:nth-child(3){height:0.75rem}
[data-vibeui-block="badge-010"] [data-part="bar"]:nth-child(4){height:0.9375rem}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="badge-010"] *{animation:none!important;transition:none!important}}
`

const LEVEL_TEXT: Record<number, string> = {
  1: "Критический",
  2: "Высокий",
  3: "Обычный",
  4: "Низкий",
}

/**
 * Приоритет штрихами: степень читается формой, а не цветом.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Badge010({
  level = 1,
  label,
  total = 4,
  className,
  style,
  ...props
}: Badge010Props) {
  // Первый уровень — самый высокий, поэтому полосок у него больше всех.
  const filled = total - level + 1
  const text = label ?? LEVEL_TEXT[level] ?? `Уровень ${level}`

  return (
    <>
      <style href="vibeui-badge-010" precedence="medium">
        {STYLES}
      </style>
      <span
        {...props}
        data-vibeui-block="badge-010"
        data-level={level}
        className={className}
        style={style as CSSProperties}
        aria-label={`Приоритет: ${text}, ${filled} из ${total}`}
      >
        <span data-part="bars" aria-hidden="true">
          {Array.from({ length: total }, (_, index) => (
            <span key={index} data-part="bar" data-on={index < filled} />
          ))}
        </span>
        <span aria-hidden="true">{text}</span>
      </span>
    </>
  )
}