Charts

Stacked Bar

One bar split into shares: "what the whole is made of" in a single line, where a donut would eat a third of the card.

  • chart
  • stacked
  • share
  • breakdown

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/chart-005?lang=en

Monthly spend
$14,200
46%24%18%8%4%
  • Разработка46%
  • Дизайн24%
  • Поддержка18%
  • Инфраструктура8%
  • Прочее4%
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 "chart-005" (Stacked Bar) 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/chart-005.json

Registry item: https://vibeui.ru/r/chart-005.json
Installs to: components/vibeui/chart-005.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
One bar split into shares: "what the whole is made of" in a single line, where a donut would eat a third of the card.

A stacked share bar: percentages inside the wide parts, a legend with every value and the total beside the heading. Zero dependencies, one file, no client JS.

## 3. How to use it
import { Chart005 } from "@/components/vibeui/chart-005"

<Chart005 parts={[{ label: "Engineering", value: 46 }]} total="$14,200" />

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-chart-005-* palette — do not swap it for your theme tokens
- one line instead of a donut: a breakdown is not worth a third of the card
- hiding labels in narrow shares — the text does not fit anyway
- the legend with every value: narrow shares are otherwise lost
- role="img" with the percentage on every share
- the light divider between shares instead of a gap

## 6. You may change
- the parts array: label, value and hue
- title and total
- the bar height
- the accent through the accent prop

## 7. Rules
- The caller sets the order: usually largest first with "other" last.
- Beyond six shares the bar stops reading: the colours blur together.
- Percentages are rounded: the labels may not add up to exactly 100.
- 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/chart-005.json
https://vibeui.ru/r/chart-005.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-chart-005-*. Серверный: хуков нет. Полоса — флекс, ширина каждой доли задаётся flex-basis в процентах. Доли уже восьми процентов не подписываются внутри: подпись в них не помещается, для них есть легенда. У каждой доли своё role="img" с процентом.

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 Chart005Part = {
  label: string
  value: number
  hue?: number
}

export type Chart005Props = Omit<
  ComponentPropsWithoutRef<"figure">,
  "children" | "title"
> & {
  title?: string
  parts?: Chart005Part[]
  total?: string
  accent?: string
}

// Идея компонента: одна полоса, разложенная на доли. Она отвечает на вопрос
// «из чего состоит целое» и занимает одну строку — там, где кольцо съело бы
// треть карточки. Доли меньше пяти процентов не подписываются внутри: текст
// в них всё равно не помещается, для них есть легенда.
const STYLES = `
:where([data-vibeui-block="chart-005"]){
--vibeui-chart-005-bg:oklch(1 0 0);
--vibeui-chart-005-fg:oklch(0.22 0.014 265);
--vibeui-chart-005-muted:oklch(0.56 0.014 265);
--vibeui-chart-005-border:oklch(0.91 0.006 265);
--vibeui-chart-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="chart-005"]{
display:flex;flex-direction:column;gap:0.625rem;
width:100%;max-width:24rem;box-sizing:border-box;margin:0;padding:0.875rem;
background:var(--vibeui-chart-005-bg);
border:1px solid var(--vibeui-chart-005-border);border-radius:0.875rem;
color:var(--vibeui-chart-005-fg);font-family:var(--vibeui-chart-005-font);
}
[data-vibeui-block="chart-005"] [data-part="head"]{display:flex;align-items:baseline;justify-content:space-between;gap:0.75rem}
[data-vibeui-block="chart-005"] [data-part="title"]{margin:0;font-size:0.875rem;font-weight:650}
[data-vibeui-block="chart-005"] [data-part="total"]{font-size:0.875rem;font-weight:680;font-variant-numeric:tabular-nums}
/* Полоса — флекс с долями: ширина каждой части задаётся её значением. */
[data-vibeui-block="chart-005"] [data-part="bar"]{
display:flex;height:1.5rem;overflow:hidden;border-radius:0.5rem;
}
[data-vibeui-block="chart-005"] [data-part="part"]{
display:flex;align-items:center;justify-content:center;min-width:0;
background:oklch(0.62 0.15 var(--vibeui-chart-005-hue,250));
color:oklch(0.99 0.01 265);
font-size:0.6875rem;font-weight:650;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="chart-005"] [data-part="part"] + [data-part="part"]{box-shadow:inset 1px 0 0 oklch(1 0 0 / 55%)}
/* Доля меньше пяти процентов не подписывается: текст в неё не влезает. */
[data-vibeui-block="chart-005"] [data-part="part"][data-narrow="true"] span{display:none}
[data-vibeui-block="chart-005"] ul{display:flex;flex-wrap:wrap;gap:0.375rem 0.875rem;margin:0;padding:0;list-style:none}
[data-vibeui-block="chart-005"] li{display:inline-flex;align-items:center;gap:0.375rem;font-size:0.75rem;color:var(--vibeui-chart-005-muted)}
[data-vibeui-block="chart-005"] [data-part="dot"]{
width:0.5rem;height:0.5rem;border-radius:0.1875rem;
background:oklch(0.62 0.15 var(--vibeui-chart-005-hue,250));
}
[data-vibeui-block="chart-005"] [data-part="legend-value"]{color:var(--vibeui-chart-005-fg);font-weight:650;font-variant-numeric:tabular-nums}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="chart-005"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_PARTS: Chart005Part[] = [
  { label: "Разработка", value: 46, hue: 250 },
  { label: "Дизайн", value: 24, hue: 150 },
  { label: "Поддержка", value: 18, hue: 30 },
  { label: "Инфраструктура", value: 8, hue: 300 },
  { label: "Прочее", value: 4, hue: 200 },
]

/**
 * Полоса, разложенная на доли: «из чего состоит целое» в одну строку.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Chart005({
  title = "Расходы месяца",
  parts = DEFAULT_PARTS,
  total = "1 240 000 ₽",
  accent,
  className,
  style,
  ...props
}: Chart005Props) {
  const sum = parts.reduce((value, part) => value + part.value, 0) || 1

  const palette = {
    ...(accent ? { "--vibeui-chart-005-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-chart-005" precedence="medium">
        {STYLES}
      </style>
      <figure
        {...props}
        data-vibeui-block="chart-005"
        className={className}
        style={palette}
      >
        <div data-part="head">
          <figcaption data-part="title">{title}</figcaption>
          <span data-part="total">{total}</span>
        </div>
        <div data-part="bar">
          {parts.map((part) => {
            const percent = Math.round((part.value / sum) * 100)

            return (
              <span
                key={part.label}
                data-part="part"
                data-narrow={percent < 8}
                role="img"
                aria-label={`${part.label}: ${percent}%`}
                style={
                  {
                    "--vibeui-chart-005-hue": part.hue ?? 250,
                    flexBasis: `${percent}%`,
                  } as CSSProperties
                }
              >
                <span>{percent}%</span>
              </span>
            )
          })}
        </div>
        <ul>
          {parts.map((part) => (
            <li key={part.label}>
              <span
                data-part="dot"
                aria-hidden="true"
                style={
                  { "--vibeui-chart-005-hue": part.hue ?? 250 } as CSSProperties
                }
              />
              {part.label}
              <span data-part="legend-value">
                {Math.round((part.value / sum) * 100)}%
              </span>
            </li>
          ))}
        </ul>
      </figure>
    </>
  )
}