Button Group
Text Align Bar
Text alignment marked with an underline instead of a fill: the bar grows from the centre and never fights the text below the toolbar.
- buttongroup
- editor
- align
- underline
Preview
Use it with AI
- 1. Copy the link.
- 2. Write to your agent in your own words and drop the link into the sentence.
- 3. The agent opens the link and installs the component from the registry.
put this in the header: https://vibeui.ru/c/buttongroup-023?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-023" (Text Align 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/buttongroup-023.json
Registry item: https://vibeui.ru/r/buttongroup-023.json
Installs to: components/vibeui/buttongroup-023.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
Text alignment marked with an underline instead of a fill: the bar grows from the centre and never fights the text below the toolbar.
An alignment toolbar with an underline on the selected segment. Zero dependencies, one file, a server component.
## 3. How to use it
import { Buttongroup023 } from "@/components/vibeui/buttongroup-023"
<Buttongroup023
defaultValue="start"
label="Paragraph alignment"
name="align"
/>
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-023-* palette — do not swap it for your theme tokens
- the underline instead of a fill: the toolbar sits above the text and a coloured block competes with it
- the bar growing via scaleX from the centre — that is what makes the switch read as movement
- the text names under clip-path instead of aria-label: find-in-page can reach them
- radios inside a fieldset: alignment is a single choice and the browser supplies the keyboard
- the distinct icon silhouettes: four identical stacks differ only by the edge they hug
## 6. You may change
- the initial alignment through defaultValue
- the accessible group name through label
- the form field name through name
- the bar and ring colour through accent
## 7. Rules
- The four options are hard-coded: your own set goes into the ALIGNMENTS array.
- The bar rests on the toolbar's bottom border — remove border-bottom and it floats.
- The component aligns nothing: applying it to the text is your editor's job.
- 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-023.jsonhttps://vibeui.ru/r/buttongroup-023.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-023-*. Серверный: выбор держат radio внутри fieldset. Выбранный сегмент помечен псевдоэлементом ::after — полосой на нижней границе панели, которая появляется через transform:scaleX(0) → scaleX(1) с transform-origin:center, поэтому переключение читается как движение, а не как вспышка. Заливки у активного сегмента нет сознательно: панель стоит над текстом, и цветной прямоугольник спорил бы с ним за внимание. Значки нарисованы «строками текста»: короткая и длинная линии прижаты к нужному краю. Имена вариантов лежат настоящим текстом под clip-path, а не в aria-label — их находит поиск по странице.
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 Buttongroup023Props = Omit<
ComponentPropsWithoutRef<"fieldset">,
"children"
> & {
defaultValue?: string
label?: string
name?: string
accent?: string
}
// Идея компонента: выбор выравнивания помечается не заливкой, а подчёркивающей
// полосой под значком — так группа не спорит с текстом, над которым стоит.
// Полоса растёт из центра через scaleX, поэтому переключение читается как
// движение, а не как вспышка. Значки нарисованы «строками текста»: короткая
// и длинная линии прижаты к нужному краю, и по силуэту видно результат.
// Имена вариантов лежат настоящим текстом под clip-path — их находит поиск
// по странице, в отличие от aria-label.
const STYLES = `
:where([data-vibeui-block="buttongroup-023"]){
--vibeui-buttongroup-023-surface:oklch(1 0 0);
--vibeui-buttongroup-023-fg:oklch(0.24 0.016 265);
--vibeui-buttongroup-023-muted:oklch(0.6 0.014 265);
--vibeui-buttongroup-023-border:oklch(0.9 0.006 265);
--vibeui-buttongroup-023-accent:oklch(0.5 0.17 300);
--vibeui-buttongroup-023-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-023"]{
box-sizing:border-box;display:inline-block;
margin:0;padding:0.25rem 0.375rem 0;border:0;
border-bottom:1px solid var(--vibeui-buttongroup-023-border);
background:var(--vibeui-buttongroup-023-surface);
font-family:var(--vibeui-buttongroup-023-font);
}
[data-vibeui-block="buttongroup-023"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-023"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-023"] [data-part="track"]{display:flex;gap:0.125rem}
[data-vibeui-block="buttongroup-023"] [data-part="segment"]{
position:relative;
display:inline-flex;align-items:center;justify-content:center;
width:2.25rem;height:2.25rem;border-radius:0.375rem 0.375rem 0 0;
color:var(--vibeui-buttongroup-023-muted);cursor:pointer;
transition:color .16s ease,background-color .16s ease;
}
[data-vibeui-block="buttongroup-023"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
[data-vibeui-block="buttongroup-023"] svg{
width:1.125rem;height:1.125rem;
stroke:currentColor;fill:none;stroke-width:1.9;stroke-linecap:round;
}
[data-vibeui-block="buttongroup-023"] [data-part="name"]{
position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);
}
/* Полоса живёт на псевдоэлементе и растёт из центра. */
[data-vibeui-block="buttongroup-023"] [data-part="segment"]::after{
content:"";position:absolute;left:0.25rem;right:0.25rem;bottom:-1px;height:2px;
border-radius:2px 2px 0 0;
background:var(--vibeui-buttongroup-023-accent);
transform:scaleX(0);transform-origin:center;
transition:transform .18s cubic-bezier(.2,.7,.3,1);
}
[data-vibeui-block="buttongroup-023"] [data-part="segment"]:hover{
color:var(--vibeui-buttongroup-023-fg);background:oklch(0.97 0.004 265);
}
[data-vibeui-block="buttongroup-023"] [data-part="segment"]:has(input:checked){
color:var(--vibeui-buttongroup-023-accent);
}
[data-vibeui-block="buttongroup-023"] [data-part="segment"]:has(input:checked)::after{transform:scaleX(1)}
[data-vibeui-block="buttongroup-023"] [data-part="segment"]:has(input:focus-visible){
outline:2px solid var(--vibeui-buttongroup-023-accent);outline-offset:-2px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-023"] *{animation:none!important;transition:none!important}}
`
const ALIGNMENTS = [
{ id: "start", label: "По левому краю", path: "M4 6h16M4 12h10M4 18h13" },
{ id: "center", label: "По центру", path: "M4 6h16M7 12h10M6 18h12" },
{ id: "end", label: "По правому краю", path: "M4 6h16M10 12h10M7 18h13" },
{ id: "justify", label: "По ширине", path: "M4 6h16M4 12h16M4 18h16" },
]
/**
* Выравнивание текста с подчёркивающей полосой вместо заливки.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Buttongroup023({
defaultValue = "start",
label = "Выравнивание абзаца",
name = "buttongroup-023",
accent,
className,
style,
...props
}: Buttongroup023Props) {
const palette = {
...(accent ? { "--vibeui-buttongroup-023-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-buttongroup-023" precedence="medium">
{STYLES}
</style>
<fieldset
{...props}
data-vibeui-block="buttongroup-023"
className={className}
style={palette}
>
<legend>{label}</legend>
<div data-part="track">
{ALIGNMENTS.map((alignment) => (
<label key={alignment.id} data-part="segment">
<input
type="radio"
name={name}
value={alignment.id}
defaultChecked={alignment.id === defaultValue}
/>
<svg viewBox="0 0 24 24" aria-hidden="true">
<path d={alignment.path} />
</svg>
<span data-part="name">{alignment.label}</span>
</label>
))}
</div>
</fieldset>
</>
)
}