Button Group

Icon Label Segments

Segments with the icon above the caption: the icon carries recognition at a distance, the caption carries precision, and neither fights for the same line.

  • buttongroup
  • segmented
  • icons
  • 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-013?lang=en

Data view
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-013" (Icon Label Segments) 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-013.json

Registry item: https://vibeui.ru/r/buttongroup-013.json
Installs to: components/vibeui/buttongroup-013.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
Segments with the icon above the caption: the icon carries recognition at a distance, the caption carries precision, and neither fights for the same line.

A segmented control with the icon stacked above the caption and equal-width columns. Zero dependencies, one file, a server component.

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

<Buttongroup013
  options={[{ id: "list", label: "List" }, { id: "grid", label: "Grid" }]}
  defaultValue="grid"
  label="Data view"
  name="view"
/>

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-013-* palette — do not swap it for your theme tokens
- radios inside a fieldset instead of buttons: arrows, Home/End and "2 of 3 selected" would otherwise be hand-written
- the equal track columns: with auto widths a long caption skews the group and the segments stop being equal targets
- the caption next to the icon — not everyone tells "grid" from "chart" by silhouette
- the z-index on the selected and focused segment: with collapsed borders a neighbour clips both the border and the ring
- the legend hidden with clip-path: display:none strips the fieldset of its accessible name

## 6. You may change
- the segments and their icons through options
- the initially selected segment through defaultValue
- the accessible group name through label
- the form field name through name and the accent through accent

## 7. Rules
- Icons live as paths in ICONS: an unknown id silently falls back to the "list" path.
- Beyond four segments the captions wrap and the group doubles in height.
- The component is uncontrolled: the value lives in the form and is read via FormData or a ref.
- 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-013.json
https://vibeui.ru/r/buttongroup-013.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-013-*. Серверный: состояние держат radio внутри fieldset, обработчиков нет. Трек — grid с grid-auto-columns:1fr, поэтому «Диаграмма» и «Лист» получают одинаковую колонку; сегмент выложен колонкой (flex-direction:column), значок сверху, подпись снизу. Границы схлопнуты через margin-inline-start:-1px, скругления логическими свойствами достаются только крайним сегментам. Выбранный сегмент поднят z-index:1, сфокусированный — z-index:2, иначе сосед срезает акцентную рамку и обводку. Значки — инлайновые SVG с stroke="currentColor", пути лежат в объекте ICONS и выбираются по id. Legend спрятан clip-path, а не display:none: иначе fieldset теряет доступное имя.

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 Buttongroup013Option = {
  id: string
  label: string
}

export type Buttongroup013Props = Omit<
  ComponentPropsWithoutRef<"fieldset">,
  "children"
> & {
  options?: Buttongroup013Option[]
  defaultValue?: string
  label?: string
  name?: string
  accent?: string
}

// Идея компонента: сегмент, у которого значок и подпись стоят столбиком.
// Значок отвечает за узнавание с расстояния, подпись — за точность, поэтому
// они не конкурируют за одну строку, а делят высоту. Сегменты равной ширины
// (grid с 1fr), иначе «Диаграмма» растянула бы свою колонку вдвое против
// «Лист». Границы схлопнуты, скругления только у крайних, фокусный сегмент
// поднимается z-index — иначе обводку срезает соседняя рамка.
const STYLES = `
:where([data-vibeui-block="buttongroup-013"]){
--vibeui-buttongroup-013-surface:oklch(1 0 0);
--vibeui-buttongroup-013-fg:oklch(0.26 0.016 265);
--vibeui-buttongroup-013-muted:oklch(0.56 0.014 265);
--vibeui-buttongroup-013-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-013-on:oklch(0.965 0.03 265);
--vibeui-buttongroup-013-accent:oklch(0.53 0.17 265);
--vibeui-buttongroup-013-radius:0.75rem;
--vibeui-buttongroup-013-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-013"]{
box-sizing:border-box;display:block;width:100%;max-width:26rem;
margin:0;padding:0;border:0;
font-family:var(--vibeui-buttongroup-013-font);
}
[data-vibeui-block="buttongroup-013"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-013"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-013"] [data-part="track"]{
display:grid;grid-auto-flow:column;grid-auto-columns:1fr;isolation:isolate;
}
[data-vibeui-block="buttongroup-013"] [data-part="segment"]{
position:relative;z-index:0;
display:flex;flex-direction:column;align-items:center;justify-content:center;gap:0.375rem;
min-height:4.25rem;padding:0.625rem 0.5rem;margin-inline-start:-1px;
border:1px solid var(--vibeui-buttongroup-013-border);
background:var(--vibeui-buttongroup-013-surface);
color:var(--vibeui-buttongroup-013-muted);
font-size:0.75rem;font-weight:600;line-height:1.2;text-align:center;cursor:pointer;
transition:background-color .16s ease,color .16s ease,border-color .16s ease;
}
[data-vibeui-block="buttongroup-013"] [data-part="segment"]:first-child{
margin-inline-start:0;
border-start-start-radius:var(--vibeui-buttongroup-013-radius);
border-end-start-radius:var(--vibeui-buttongroup-013-radius);
}
[data-vibeui-block="buttongroup-013"] [data-part="segment"]:last-child{
border-start-end-radius:var(--vibeui-buttongroup-013-radius);
border-end-end-radius:var(--vibeui-buttongroup-013-radius);
}
[data-vibeui-block="buttongroup-013"] [data-part="segment"]:hover{color:var(--vibeui-buttongroup-013-fg)}
[data-vibeui-block="buttongroup-013"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
[data-vibeui-block="buttongroup-013"] svg{
width:1.25rem;height:1.25rem;flex:none;
stroke:currentColor;fill:none;stroke-width:1.6;
stroke-linecap:round;stroke-linejoin:round;
}
/* Выбранный сегмент поднят: его акцентная рамка иначе уходит под соседнюю. */
[data-vibeui-block="buttongroup-013"] [data-part="segment"]:has(input:checked){
z-index:1;
background:var(--vibeui-buttongroup-013-on);
border-color:var(--vibeui-buttongroup-013-accent);
color:var(--vibeui-buttongroup-013-accent);
}
[data-vibeui-block="buttongroup-013"] [data-part="segment"]:has(input:focus-visible){
z-index:2;
outline:2px solid var(--vibeui-buttongroup-013-accent);outline-offset:1px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-013"] *{animation:none!important;transition:none!important}}
`

const ICONS: Record<string, string> = {
  list: "M8 6h13M8 12h13M8 18h13M3 6h.01M3 12h.01M3 18h.01",
  grid: "M4 4h7v7H4zM13 4h7v7h-7zM4 13h7v7H4zM13 13h7v7h-7z",
  chart: "M4 20V10M10 20V4M16 20v-7M22 20H2",
}

const DEFAULT_OPTIONS: Buttongroup013Option[] = [
  { id: "list", label: "Лист" },
  { id: "grid", label: "Плитка" },
  { id: "chart", label: "Диаграмма" },
]

/**
 * Сегменты со значком над подписью: узнавание значком, точность подписью.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Buttongroup013({
  options = DEFAULT_OPTIONS,
  defaultValue = "grid",
  label = "Представление данных",
  name = "buttongroup-013",
  accent,
  className,
  style,
  ...props
}: Buttongroup013Props) {
  const palette = {
    ...(accent ? { "--vibeui-buttongroup-013-accent": accent } : null),
    ...style,
  } as CSSProperties

  return (
    <>
      <style href="vibeui-buttongroup-013" precedence="medium">
        {STYLES}
      </style>
      <fieldset
        {...props}
        data-vibeui-block="buttongroup-013"
        className={className}
        style={palette}
      >
        <legend>{label}</legend>
        <div data-part="track">
          {options.map((option) => (
            <label key={option.id} data-part="segment">
              <input
                type="radio"
                name={name}
                value={option.id}
                defaultChecked={option.id === defaultValue}
              />
              <svg viewBox="0 0 24 24" aria-hidden="true">
                <path d={ICONS[option.id] ?? ICONS.list} />
              </svg>
              <span>{option.label}</span>
            </label>
          ))}
        </div>
      </fieldset>
    </>
  )
}