Button Group

Chart Step Links

Chart granularity built on links rather than buttons: middle click, "open in a new tab" and the back button all work, and the choice survives a reload.

  • buttongroup
  • links
  • chart
  • aria-current

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-030?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-030" (Chart Step Links) 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-030.json

Registry item: https://vibeui.ru/r/buttongroup-030.json
Installs to: components/vibeui/buttongroup-030.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
Chart granularity built on links rather than buttons: middle click, "open in a new tab" and the back button all work, and the choice survives a reload.

A chart step switcher on links: the state lives in the URL. Zero dependencies, one file, a server component.

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

<Buttongroup030
  steps={[{ label: "Day", href: "?step=day", points: "24 points" }]}
  current="Week"
  label="Chart step"
/>

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-030-* palette — do not swap it for your theme tokens
- links instead of buttons: middle click, a new tab and "back" would otherwise not work
- aria-current="page" as the source of both state and style — they then cannot drift apart
- the current step as a link rather than a span: coming back from history needs somewhere to focus
- the nav with aria-label — a step switcher belongs in the landmark list
- the point count on the second line: "week" does not say how detailed the chart will be

## 6. You may change
- the steps, their hrefs and captions through steps
- the active step through current
- the accessible navigation name through label
- the focus ring colour through accent

## 7. Rules
- current is matched against a step's label: a typo silently unhighlights every link.
- The hrefs are passed through as is: plug your router's URLs in.
- Links do not block client-side navigation, but the move is still made by the router, not the component.
- 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-030.json
https://vibeui.ru/r/buttongroup-030.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-030-*. Серверный: состояние живёт в адресе страницы, а не в React. Группа собрана из li со ссылками внутри nav с aria-label; текущий шаг помечен aria-current="page", и стиль выбирается тем же атрибутом, поэтому подсветка не может разойтись с объявленным состоянием. Текущая ссылка остаётся ссылкой, а не превращается в span: иначе фокус на ней теряется при возврате из истории. Рамка одна — на списке, разделители рисует li + li {border-inline-start}, углы обрезает overflow: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 Buttongroup030Step = {
  label: string
  href: string
  points: string
}

export type Buttongroup030Props = Omit<
  ComponentPropsWithoutRef<"nav">,
  "children"
> & {
  steps?: Buttongroup030Step[]
  current?: string
  label?: string
  accent?: string
}

// Идея компонента: шаг графика живёт в адресе страницы, поэтому группа
// собрана из ссылок, а не из кнопок. Это меняет всё поведение: работает
// средняя кнопка мыши, «открыть в новой вкладке» и кнопка «назад», а
// состояние переживает перезагрузку. Текущий шаг помечен aria-current="page"
// — им же выбирается стиль, так что подсветка не может разойтись с тем,
// что объявлено вслух. Текущая ссылка остаётся ссылкой, а не превращается
// в span: иначе фокус на ней теряется при возврате из истории.
const STYLES = `
:where([data-vibeui-block="buttongroup-030"]){
--vibeui-buttongroup-030-surface:oklch(1 0 0);
--vibeui-buttongroup-030-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-030-muted:oklch(0.57 0.014 265);
--vibeui-buttongroup-030-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-030-on:oklch(0.24 0.02 265);
--vibeui-buttongroup-030-accent:oklch(0.55 0.15 200);
--vibeui-buttongroup-030-radius:0.625rem;
--vibeui-buttongroup-030-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-030"]{
box-sizing:border-box;display:inline-block;
font-family:var(--vibeui-buttongroup-030-font);
}
[data-vibeui-block="buttongroup-030"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-030"] ul{
display:flex;isolation:isolate;margin:0;padding:0;list-style:none;
border:1px solid var(--vibeui-buttongroup-030-border);
border-radius:var(--vibeui-buttongroup-030-radius);
background:var(--vibeui-buttongroup-030-surface);
overflow:hidden;
}
[data-vibeui-block="buttongroup-030"] li + li{
border-inline-start:1px solid var(--vibeui-buttongroup-030-border);
}
[data-vibeui-block="buttongroup-030"] a{
position:relative;z-index:0;
display:flex;flex-direction:column;align-items:center;gap:0.125rem;
min-width:4.25rem;padding:0.4375rem 0.75rem;
color:var(--vibeui-buttongroup-030-muted);text-decoration:none;
transition:background-color .16s ease,color .16s ease;
}
[data-vibeui-block="buttongroup-030"] [data-part="name"]{
font-size:0.8125rem;font-weight:650;line-height:1.1;
}
[data-vibeui-block="buttongroup-030"] [data-part="points"]{
font-size:0.625rem;font-weight:600;line-height:1.1;opacity:.75;
font-variant-numeric:tabular-nums;
}
[data-vibeui-block="buttongroup-030"] a:hover{
background:oklch(0.97 0.004 265);color:var(--vibeui-buttongroup-030-fg);
}
/* Стиль выбирается тем же атрибутом, что объявляет состояние. */
[data-vibeui-block="buttongroup-030"] a[aria-current="page"]{
z-index:1;
background:var(--vibeui-buttongroup-030-on);
color:oklch(0.99 0.002 265);
}
[data-vibeui-block="buttongroup-030"] a:focus-visible{
z-index:2;outline:2px solid var(--vibeui-buttongroup-030-accent);outline-offset:-2px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-030"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_STEPS: Buttongroup030Step[] = [
  { label: "День", href: "?step=day", points: "24 точки" },
  { label: "Неделя", href: "?step=week", points: "7 точек" },
  { label: "Месяц", href: "?step=month", points: "30 точек" },
]

/**
 * Шаг графика ссылками: состояние живёт в адресе и переживает перезагрузку.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Buttongroup030({
  steps = DEFAULT_STEPS,
  current = "Неделя",
  label = "Шаг графика",
  accent,
  className,
  style,
  ...props
}: Buttongroup030Props) {
  const palette = {
    ...(accent ? { "--vibeui-buttongroup-030-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-buttongroup-030" precedence="medium">
        {STYLES}
      </style>
      <nav
        {...props}
        data-vibeui-block="buttongroup-030"
        className={className}
        style={palette}
        aria-label={label}
      >
        <ul>
          {steps.map((step) => (
            <li key={step.label}>
              <a
                href={step.href}
                aria-current={step.label === current ? "page" : undefined}
              >
                <span data-part="name">{step.label}</span>
                <span data-part="points">{step.points}</span>
              </a>
            </li>
          ))}
        </ul>
      </nav>
    </>
  )
}