Button Group

Grouped Toolbar

One toolbar split into meaningful clusters: buttons sit flush inside a cluster, a line and a gap separate the clusters, and each one is named for screen readers.

  • buttongroup
  • toolbar
  • grouping
  • dividers

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-055?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-055" (Grouped Toolbar) 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-055.json

Registry item: https://vibeui.ru/r/buttongroup-055.json
Installs to: components/vibeui/buttongroup-055.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 toolbar split into meaningful clusters: buttons sit flush inside a cluster, a line and a gap separate the clusters, and each one is named for screen readers.

A toolbar divided into named, meaningful clusters. Zero dependencies, one file, a server component.

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

<Buttongroup055
  clusters={[{ title: "History", tools: [{ id: "undo", label: "Undo" }] }]}
  label="Editor toolbar"
/>

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-055-* palette — do not swap it for your theme tokens
- the difference in gaps inside and between clusters: proximity is the message about kinship
- role="group" with a name on every cluster — the division has to exist for screen readers too
- the divider as its own node: the line belongs to the gap, not to the neighbouring button
- aria-label on every button: a bare icon has no accessible name
- aria-hidden on the dividers so they are not announced as toolbar items

## 6. You may change
- the clusters and their titles through clusters
- the accessible name of the whole toolbar through label
- the focus ring colour through accent
- the button size through your own width and height values in the CSS

## 7. Rules
- Cluster titles are invisible on screen — they exist for screen readers only.
- More than three clusters do not fit a phone: the toolbar has to collapse.
- Icons live as paths in ICONS: an unknown id silently falls back to the copy glyph.
- 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-055.json
https://vibeui.ru/r/buttongroup-055.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-055-*. Серверный: хуков нет. Близость сама сообщает родство: внутри [data-part="cluster"] gap:0, между блоками — gap:0.5rem и разделитель. Деление существует не только для глаз: каждый блок объявлен своим role="group" с aria-label, поэтому скринридер скажет «История, группа» перед первой кнопкой. Разделитель — отдельный span с aria-hidden, а не border у соседней кнопки: линия принадлежит промежутку, а не соседу, и при перестановке блоков ничего не ломается. У кнопок нет подписей, поэтому у каждой есть aria-label.

Component source

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

import { Fragment } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Buttongroup055Cluster = {
  title: string
  tools: { id: string; label: string }[]
}

export type Buttongroup055Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  clusters?: Buttongroup055Cluster[]
  label?: string
  accent?: string
}

// Идея компонента: одна сцепка, разделённая на смысловые блоки. Внутри блока
// кнопки стоят вплотную, между блоками — линия и удвоенный зазор: близость
// сама сообщает, что «отменить/повторить» и «вырезать/копировать» — разные
// семьи. Каждый блок объявлен своим role="group" с именем, поэтому деление
// существует не только для глаз: скринридер объявит «История, группа» перед
// первой кнопкой. Разделитель — span с aria-hidden, а не border у кнопки:
// линия принадлежит промежутку, а не соседу.
const STYLES = `
:where([data-vibeui-block="buttongroup-055"]){
--vibeui-buttongroup-055-surface:oklch(1 0 0);
--vibeui-buttongroup-055-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-055-muted:oklch(0.58 0.014 265);
--vibeui-buttongroup-055-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-055-accent:oklch(0.5 0.16 265);
--vibeui-buttongroup-055-radius:0.5rem;
--vibeui-buttongroup-055-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-055"]{
box-sizing:border-box;display:inline-flex;align-items:center;gap:0.5rem;
padding:0.25rem;
border:1px solid var(--vibeui-buttongroup-055-border);
border-radius:calc(var(--vibeui-buttongroup-055-radius) + 0.25rem);
background:var(--vibeui-buttongroup-055-surface);
font-family:var(--vibeui-buttongroup-055-font);
}
[data-vibeui-block="buttongroup-055"] *{box-sizing:border-box}
/* Внутри блока — вплотную, между блоками — линия и зазор. */
[data-vibeui-block="buttongroup-055"] [data-part="cluster"]{display:flex;gap:0}
[data-vibeui-block="buttongroup-055"] button{
appearance:none;cursor:pointer;font:inherit;
display:inline-flex;align-items:center;justify-content:center;
width:2rem;height:2rem;
border:0;border-radius:var(--vibeui-buttongroup-055-radius);
background:transparent;
color:var(--vibeui-buttongroup-055-muted);
transition:background-color .14s ease,color .14s ease;
}
[data-vibeui-block="buttongroup-055"] svg{
width:0.9375rem;height:0.9375rem;
stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;stroke-linejoin:round;
}
[data-vibeui-block="buttongroup-055"] button:hover{
background:oklch(0.96 0.005 265);color:var(--vibeui-buttongroup-055-fg);
}
[data-vibeui-block="buttongroup-055"] button:focus-visible{
outline:2px solid var(--vibeui-buttongroup-055-accent);outline-offset:1px;
color:var(--vibeui-buttongroup-055-accent);
}
[data-vibeui-block="buttongroup-055"] [data-part="rule"]{
width:1px;height:1.25rem;flex:none;
background:var(--vibeui-buttongroup-055-border);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-055"] *{animation:none!important;transition:none!important}}
`

const ICONS: Record<string, string> = {
  undo: "M9 7 5 11l4 4M5 11h9a5 5 0 0 1 0 10h-3",
  redo: "m15 7 4 4-4 4M19 11h-9a5 5 0 0 0 0 10h3",
  cut: "M6 4l12 14M18 4 6 18M6 20a2 2 0 1 0 0-4 2 2 0 0 0 0 4M18 20a2 2 0 1 0 0-4 2 2 0 0 0 0 4",
  copy: "M9 9h11v11H9zM5 15H4V4h11v1",
  paste: "M9 4h6v3H9zM7 5H5v15h14V5h-2",
  zoomIn: "M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14M20 20l-4-4M8 11h6M11 8v6",
  zoomOut: "M11 4a7 7 0 1 0 0 14 7 7 0 0 0 0-14M20 20l-4-4M8 11h6",
}

const DEFAULT_CLUSTERS: Buttongroup055Cluster[] = [
  {
    title: "История",
    tools: [
      { id: "undo", label: "Отменить" },
      { id: "redo", label: "Повторить" },
    ],
  },
  {
    title: "Буфер обмена",
    tools: [
      { id: "cut", label: "Вырезать" },
      { id: "copy", label: "Копировать" },
      { id: "paste", label: "Вставить" },
    ],
  },
  {
    title: "Масштаб",
    tools: [
      { id: "zoomIn", label: "Приблизить" },
      { id: "zoomOut", label: "Отдалить" },
    ],
  },
]

/**
 * Панель, разделённая на смысловые блоки: линия и зазор вместо сплошного ряда.
 * Один файл, ноль зависимостей, серверный компонент.
 */
export function Buttongroup055({
  clusters = DEFAULT_CLUSTERS,
  label = "Панель редактора",
  accent,
  className,
  style,
  ...props
}: Buttongroup055Props) {
  const palette = {
    ...(accent ? { "--vibeui-buttongroup-055-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-buttongroup-055" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="buttongroup-055"
        className={className}
        style={palette}
        role="group"
        aria-label={label}
      >
        {clusters.map((cluster, index) => (
          <Fragment key={cluster.title}>
            {index > 0 ? <span data-part="rule" aria-hidden="true" /> : null}
            <div data-part="cluster" role="group" aria-label={cluster.title}>
              {cluster.tools.map((tool) => (
                <button key={tool.id} type="button" aria-label={tool.label}>
                  <svg viewBox="0 0 24 24" aria-hidden="true">
                    <path d={ICONS[tool.id] ?? ICONS.copy} />
                  </svg>
                </button>
              ))}
            </div>
          </Fragment>
        ))}
      </div>
    </>
  )
}