Button Group
Priority Levels
Priority as a ladder of bars: the ordinal value is carried by height, not by hue — red and yellow never say which one is higher.
- buttongroup
- priority
- scale
- a11y
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/buttongroup-051?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 "buttongroup-051" (Priority Levels) 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/buttongroup-051.json
Registry item: https://vibeui.ru/r/buttongroup-051.json
Installs to: components/vibeui/buttongroup-051.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 a ladder of bars: the ordinal value is carried by height, not by hue — red and yellow never say which one is higher.
A priority picker where the level is shown by bar height and colour only assists. Zero dependencies, one file, a server component.
## 3. How to use it
import { Buttongroup051 } from "@/components/vibeui/buttongroup-051"
<Buttongroup051
levels={[{ id: "high", label: "High", bars: 3, hue: 65 }]}
defaultValue="high"
label="Task priority"
name="priority"
/>
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-buttongroup-051-* palette — do not swap it for your theme tokens
- the ladder of bars: an ordinal value cannot be carried by colour, red is not "higher" than yellow
- the hue as a number inside oklch formulas — fill, border and text then agree at any colour
- the level caption next to the bars: bare bars need a legend that is not on screen
- the equal segment shares, so the levels are targets of one size
- the z-index on the selected and focused segment with collapsed borders
## 6. You may change
- the levels, bar counts and hues through levels
- the initial level through defaultValue
- the accessible group name through label
- the form field name through name and the ring colour through accent
## 7. Rules
- There are exactly four bars: a fifth level needs its own height in the CSS.
- The hues rise in "temperature": arbitrary colours destroy the sense of a scale.
- The component sorts nothing: applying the priority is your code's job.
- 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/buttongroup-051.jsonhttps://vibeui.ru/r/buttongroup-051.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-051-*. Серверный: выбор держат radio внутри fieldset. Значок — четыре полосы возрастающей высоты, из которых закрашены первые N: порядковая величина требует порядкового признака, а цвет остаётся вторым каналом. Оттенок приходит числом и подставляется инлайновой переменной --vibeui-buttongroup-051-hue, все цвета сегмента собираются из неё формулами oklch — заливка, рамка и текст выбранного уровня остаются согласованными на любом оттенке. Границы схлопнуты через margin-inline-start:-1px, сегменты равной ширины (flex:1 1 0), фокус поднимает z-index:2.
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 Buttongroup051Level = {
id: string
label: string
bars: number
hue: number
}
export type Buttongroup051Props = Omit<
ComponentPropsWithoutRef<"fieldset">,
"children"
> & {
levels?: Buttongroup051Level[]
defaultValue?: string
label?: string
name?: string
accent?: string
}
// Идея компонента: приоритет читается не по цвету, а по высоте столбиков —
// один, два, три, четыре. Порядковая величина требует порядкового признака:
// красный и жёлтый не говорят, какой из них выше, а лесенка говорит. Цвет
// остаётся вторым каналом и приходит оттенком в oklch через переменную.
// Столбики нарисованы флексом с align-items:flex-end, высота задаётся в
// процентах от общей высоты значка, поэтому шкалу можно продлить данными,
// не трогая CSS.
const STYLES = `
:where([data-vibeui-block="buttongroup-051"]){
--vibeui-buttongroup-051-surface:oklch(1 0 0);
--vibeui-buttongroup-051-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-051-muted:oklch(0.58 0.014 265);
--vibeui-buttongroup-051-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-051-accent:oklch(0.45 0.03 265);
--vibeui-buttongroup-051-hue:265;
--vibeui-buttongroup-051-radius:0.625rem;
--vibeui-buttongroup-051-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-051"]{
box-sizing:border-box;display:block;width:100%;max-width:26rem;
margin:0;padding:0;border:0;
font-family:var(--vibeui-buttongroup-051-font);
}
[data-vibeui-block="buttongroup-051"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-051"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-051"] [data-part="track"]{display:flex;isolation:isolate}
[data-vibeui-block="buttongroup-051"] [data-part="level"]{
position:relative;z-index:0;flex:1 1 0;min-width:0;
display:inline-flex;align-items:center;justify-content:center;gap:0.4375rem;
height:2.5rem;padding:0 0.5rem;margin-inline-start:-1px;
border:1px solid var(--vibeui-buttongroup-051-border);
background:var(--vibeui-buttongroup-051-surface);
color:var(--vibeui-buttongroup-051-muted);
font-size:0.78125rem;font-weight:650;line-height:1;white-space:nowrap;cursor:pointer;
transition:background-color .16s ease,color .16s ease,border-color .16s ease;
}
[data-vibeui-block="buttongroup-051"] [data-part="level"]:first-child{
margin-inline-start:0;
border-start-start-radius:var(--vibeui-buttongroup-051-radius);
border-end-start-radius:var(--vibeui-buttongroup-051-radius);
}
[data-vibeui-block="buttongroup-051"] [data-part="level"]:last-child{
border-start-end-radius:var(--vibeui-buttongroup-051-radius);
border-end-end-radius:var(--vibeui-buttongroup-051-radius);
}
[data-vibeui-block="buttongroup-051"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
/* Лесенка: порядковую величину показывает высота, а не оттенок. */
[data-vibeui-block="buttongroup-051"] [data-part="bars"]{
display:flex;align-items:flex-end;gap:2px;height:0.9375rem;flex:none;
}
[data-vibeui-block="buttongroup-051"] [data-part="bars"] i{
width:3px;border-radius:1.5px;
background:oklch(0.82 0.02 var(--vibeui-buttongroup-051-hue));
}
[data-vibeui-block="buttongroup-051"] [data-part="bars"] i[data-on="true"]{
background:oklch(0.62 0.17 var(--vibeui-buttongroup-051-hue));
}
[data-vibeui-block="buttongroup-051"] [data-part="bars"] i:nth-child(1){height:35%}
[data-vibeui-block="buttongroup-051"] [data-part="bars"] i:nth-child(2){height:55%}
[data-vibeui-block="buttongroup-051"] [data-part="bars"] i:nth-child(3){height:78%}
[data-vibeui-block="buttongroup-051"] [data-part="bars"] i:nth-child(4){height:100%}
[data-vibeui-block="buttongroup-051"] [data-part="level"]:hover{color:var(--vibeui-buttongroup-051-fg)}
[data-vibeui-block="buttongroup-051"] [data-part="level"]:has(input:checked){
z-index:1;
background:oklch(0.97 0.03 var(--vibeui-buttongroup-051-hue));
border-color:oklch(0.62 0.17 var(--vibeui-buttongroup-051-hue));
color:oklch(0.42 0.16 var(--vibeui-buttongroup-051-hue));
}
[data-vibeui-block="buttongroup-051"] [data-part="level"]:has(input:focus-visible){
z-index:2;outline:2px solid var(--vibeui-buttongroup-051-accent);outline-offset:1px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-051"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_LEVELS: Buttongroup051Level[] = [
{ id: "low", label: "Низкий", bars: 1, hue: 230 },
{ id: "normal", label: "Обычный", bars: 2, hue: 160 },
{ id: "high", label: "Высокий", bars: 3, hue: 65 },
{ id: "urgent", label: "Срочный", bars: 4, hue: 25 },
]
/**
* Приоритет лесенкой из столбиков: порядок виден высотой, а не только цветом.
* Один файл, ноль зависимостей, серверный компонент.
*/
export function Buttongroup051({
levels = DEFAULT_LEVELS,
defaultValue = "high",
label = "Приоритет задачи",
name = "buttongroup-051",
accent,
className,
style,
...props
}: Buttongroup051Props) {
const palette = {
...(accent ? { "--vibeui-buttongroup-051-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-buttongroup-051" precedence="medium">
{STYLES}
</style>
<fieldset
{...props}
data-vibeui-block="buttongroup-051"
className={className}
style={palette}
>
<legend>{label}</legend>
<div data-part="track">
{levels.map((level) => (
<label
key={level.id}
data-part="level"
style={
{ "--vibeui-buttongroup-051-hue": level.hue } as CSSProperties
}
>
<input
type="radio"
name={name}
value={level.id}
defaultChecked={level.id === defaultValue}
/>
<span data-part="bars" aria-hidden="true">
{[1, 2, 3, 4].map((step) => (
<i key={step} data-on={step <= level.bars} />
))}
</span>
<span>{level.label}</span>
</label>
))}
</div>
</fieldset>
</>
)
}