Button Group

Chart Kind

A chart type picker where every segment is a small chart of its own kind: bars made of divs, a line in SVG and a share on a conic-gradient.

  • buttongroup
  • chart
  • glyph
  • radio

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/buttongroup-048?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-048" (Chart Kind) 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-048.json

Registry item: https://vibeui.ru/r/buttongroup-048.json
Installs to: components/vibeui/buttongroup-048.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
A chart type picker where every segment is a small chart of its own kind: bars made of divs, a line in SVG and a share on a conic-gradient.

A chart type picker whose samples are drawn with three different techniques. Zero dependencies, one file, a server component.

## 3. How to use it
import { Buttongroup048 } from "@/components/vibeui/buttongroup-048"

<Buttongroup048
  barsLabel="Bars"
  lineLabel="Line"
  pieLabel="Share"
  defaultValue="bars"
  name="chart"
/>

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-048-* palette — do not swap it for your theme tokens
- the glyph colour variable: one rule recolours all three shapes at once
- samples instead of icons — a chart type is recognised by the shape of the data, not a pictogram
- the caption under each sample: people call "share" and "donut" different things
- the z-index on the selected and focused segment with collapsed borders
- radios inside a fieldset, so the chart type reaches the form and works with arrows

## 6. You may change
- the option captions through barsLabel, lineLabel and pieLabel
- the initial type through defaultValue
- the accessible group name through label
- the form field name through name and the sample colour through accent

## 7. Rules
- There are exactly three options: a fourth sample has to be drawn by hand.
- The samples are decorative and aria-hidden: no data is fed into them.
- The component draws no chart: redrawing is your code's job once the value changes.
- 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-048.json
https://vibeui.ru/r/buttongroup-048.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-048-*. Серверный: выбор держат radio внутри fieldset. Три образца нарисованы тремя разными приёмами: столбики — flex с align-items:flex-end и процентными высотами, линия — polyline в SVG, доля — conic-gradient. Свести их к одному набору путей можно, но честнее рисовать каждую фигуру тем, чем она рисуется естественно. Цвет образцов вынесен в переменную --vibeui-buttongroup-048-glyph, и выбранный сегмент переопределяет её на акцент — одно правило перекрашивает все три образца сразу. Границы схлопнуты, скругления только крайним, фокус поднимает 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 Buttongroup048Props = Omit<
  ComponentPropsWithoutRef<"fieldset">,
  "children"
> & {
  barsLabel?: string
  lineLabel?: string
  pieLabel?: string
  defaultValue?: string
  label?: string
  name?: string
  accent?: string
}

// Идея компонента: выбор вида графика, где каждый сегмент — маленький
// график, а не значок. Столбики собраны из трёх div разной высоты, линия —
// polyline в SVG, доля — conic-gradient с круглой маской: три разных приёма,
// потому что три разные фигуры честнее рисовать по-разному, чем сводить к
// одному набору путей. Образцы серые в покое и окрашиваются в акцент у
// выбранного, поэтому активный сегмент читается формой и цветом сразу.
const STYLES = `
:where([data-vibeui-block="buttongroup-048"]){
--vibeui-buttongroup-048-surface:oklch(1 0 0);
--vibeui-buttongroup-048-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-048-muted:oklch(0.58 0.014 265);
--vibeui-buttongroup-048-glyph:oklch(0.78 0.01 265);
--vibeui-buttongroup-048-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-048-on:oklch(0.97 0.025 195);
--vibeui-buttongroup-048-accent:oklch(0.5 0.13 195);
--vibeui-buttongroup-048-radius:0.75rem;
--vibeui-buttongroup-048-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-048"]{
box-sizing:border-box;display:block;width:100%;max-width:21rem;
margin:0;padding:0;border:0;
font-family:var(--vibeui-buttongroup-048-font);
}
[data-vibeui-block="buttongroup-048"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-048"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-048"] [data-part="track"]{
display:grid;grid-template-columns:repeat(3,1fr);isolation:isolate;
}
[data-vibeui-block="buttongroup-048"] [data-part="segment"]{
position:relative;z-index:0;
display:flex;flex-direction:column;align-items:center;gap:0.5rem;
padding:0.75rem 0.5rem 0.625rem;margin-inline-start:-1px;
border:1px solid var(--vibeui-buttongroup-048-border);
background:var(--vibeui-buttongroup-048-surface);
color:var(--vibeui-buttongroup-048-muted);
font-size:0.75rem;font-weight:650;line-height:1;cursor:pointer;
transition:background-color .16s ease,border-color .16s ease,color .16s ease;
}
[data-vibeui-block="buttongroup-048"] [data-part="segment"]:first-child{
margin-inline-start:0;
border-start-start-radius:var(--vibeui-buttongroup-048-radius);
border-end-start-radius:var(--vibeui-buttongroup-048-radius);
}
[data-vibeui-block="buttongroup-048"] [data-part="segment"]:last-child{
border-start-end-radius:var(--vibeui-buttongroup-048-radius);
border-end-end-radius:var(--vibeui-buttongroup-048-radius);
}
[data-vibeui-block="buttongroup-048"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
/* Столбики: три полосы разной высоты, выровненные по низу. */
[data-vibeui-block="buttongroup-048"] [data-part="bars"]{
display:flex;align-items:flex-end;gap:3px;height:1.5rem;
}
[data-vibeui-block="buttongroup-048"] [data-part="bars"] i{
width:5px;border-radius:1.5px;background:var(--vibeui-buttongroup-048-glyph);
transition:background-color .16s ease;
}
[data-vibeui-block="buttongroup-048"] [data-part="bars"] i:nth-child(1){height:45%}
[data-vibeui-block="buttongroup-048"] [data-part="bars"] i:nth-child(2){height:100%}
[data-vibeui-block="buttongroup-048"] [data-part="bars"] i:nth-child(3){height:70%}
[data-vibeui-block="buttongroup-048"] [data-part="line"]{
width:1.75rem;height:1.5rem;
stroke:var(--vibeui-buttongroup-048-glyph);fill:none;stroke-width:2.2;
stroke-linecap:round;stroke-linejoin:round;
transition:stroke .16s ease;
}
/* Доля: conic-gradient с круглой маской вместо дуги в SVG. */
[data-vibeui-block="buttongroup-048"] [data-part="pie"]{
width:1.5rem;height:1.5rem;border-radius:9999px;
background:conic-gradient(var(--vibeui-buttongroup-048-glyph) 0 0.62turn,oklch(0.91 0.006 265) 0);
transition:background .16s ease;
}
[data-vibeui-block="buttongroup-048"] [data-part="segment"]:hover{color:var(--vibeui-buttongroup-048-fg)}
[data-vibeui-block="buttongroup-048"] [data-part="segment"]:has(input:checked){
z-index:1;
background:var(--vibeui-buttongroup-048-on);
border-color:var(--vibeui-buttongroup-048-accent);
color:var(--vibeui-buttongroup-048-accent);
--vibeui-buttongroup-048-glyph:var(--vibeui-buttongroup-048-accent);
}
[data-vibeui-block="buttongroup-048"] [data-part="segment"]:has(input:focus-visible){
z-index:2;outline:2px solid var(--vibeui-buttongroup-048-accent);outline-offset:1px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-048"] *{animation:none!important;transition:none!important}}
`

/**
 * Вид графика: каждый сегмент нарисован как маленький график своего типа.
 * Один файл, ноль зависимостей, серверный компонент.
 */
export function Buttongroup048({
  barsLabel = "Столбики",
  lineLabel = "Линия",
  pieLabel = "Доли",
  defaultValue = "bars",
  label = "Вид графика",
  name = "buttongroup-048",
  accent,
  className,
  style,
  ...props
}: Buttongroup048Props) {
  const palette = {
    ...(accent ? { "--vibeui-buttongroup-048-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-buttongroup-048" precedence="medium">
        {STYLES}
      </style>
      <fieldset
        {...props}
        data-vibeui-block="buttongroup-048"
        className={className}
        style={palette}
      >
        <legend>{label}</legend>
        <div data-part="track">
          <label data-part="segment">
            <input
              type="radio"
              name={name}
              value="bars"
              defaultChecked={defaultValue === "bars"}
            />
            <span data-part="bars" aria-hidden="true">
              <i />
              <i />
              <i />
            </span>
            <span>{barsLabel}</span>
          </label>
          <label data-part="segment">
            <input
              type="radio"
              name={name}
              value="line"
              defaultChecked={defaultValue === "line"}
            />
            <svg data-part="line" viewBox="0 0 28 24" aria-hidden="true">
              <polyline points="2,19 9,11 16,15 26,4" />
            </svg>
            <span>{lineLabel}</span>
          </label>
          <label data-part="segment">
            <input
              type="radio"
              name={name}
              value="pie"
              defaultChecked={defaultValue === "pie"}
            />
            <span data-part="pie" aria-hidden="true" />
            <span>{pieLabel}</span>
          </label>
        </div>
      </fieldset>
    </>
  )
}