Button Group
Playback Speed
A playback speed control where the selected segment widens and explains itself in a word while the others shrink to a bare multiplier.
- buttongroup
- player
- speed
- elastic
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-026?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-026" (Playback Speed) 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-026.json
Registry item: https://vibeui.ru/r/buttongroup-026.json
Installs to: components/vibeui/buttongroup-026.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 playback speed control where the selected segment widens and explains itself in a word while the others shrink to a bare multiplier.
A speed picker whose active segment widens and reveals a caption. Zero dependencies, one file, a server component.
## 3. How to use it
import { Buttongroup026 } from "@/components/vibeui/buttongroup-026"
<Buttongroup026
speeds={[{ value: "1×", note: "normal" }, { value: "2×", note: "double" }]}
defaultValue="1×"
label="Playback speed"
name="speed"
/>
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-026-* palette — do not swap it for your theme tokens
- animating flex-grow instead of width: the shares always add up to the track and the group never jitters
- flex:1 1 0 with a zero basis — with auto a long caption claims more than half the bar
- hiding the caption with a zero max-width rather than display:none: otherwise there is nothing to animate
- tabular figures on the multipliers: "1.5×" and "1×" would otherwise shift their neighbours
- the prefers-reduced-motion rule — a widening segment is noticeable with vestibular disorders
## 6. You may change
- the speeds and their captions through speeds
- the initial speed through defaultValue
- the accessible group name through label
- the form field name through name and the active text colour through accent
## 7. Rules
- The caption is clipped at max-width:8rem: a long word disappears quietly.
- Beyond five speeds the squeezed segments become narrower than a touch target.
- The component plays nothing: applying the speed is your player'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-026.jsonhttps://vibeui.ru/r/buttongroup-026.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-026-*. Серверный: выбор держат radio внутри fieldset. Приём — анимация flex-grow, а не width: у выбранного сегмента доля растёт до 2.4, сумма долей всегда равна треку, поэтому группа не дрожит и не выезжает за рамку. Пояснение скрыто нулевой max-width с overflow:hidden, а не display:none — так его можно плавно раскрыть. Значения набраны табличными цифрами, все сегменты имеют flex:1 1 0 и min-width:0, иначе «1,5×» забрал бы себе больше «1×». Правило prefers-reduced-motion гасит и переезд, и раскрытие.
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 Buttongroup026Speed = {
value: string
note: string
}
export type Buttongroup026Props = Omit<
ComponentPropsWithoutRef<"fieldset">,
"children"
> & {
speeds?: Buttongroup026Speed[]
defaultValue?: string
label?: string
name?: string
accent?: string
}
// Идея компонента: сегменты не равной ширины — выбранный раздвигается и
// показывает словесное пояснение, остальные ужимаются до множителя. Растёт
// не размер шрифта, а доля во flex: у выбранного flex-grow становится
// больше, и переход анимируется по flex-grow, а не по width, поэтому сумма
// ширин всегда равна треку и группа не дрожит. Пояснение скрыто не
// display:none, а нулевой шириной с overflow:hidden — так его можно плавно
// раскрыть, и оно остаётся в доступном дереве только у выбранного варианта.
const STYLES = `
:where([data-vibeui-block="buttongroup-026"]){
--vibeui-buttongroup-026-surface:oklch(1 0 0);
--vibeui-buttongroup-026-track:oklch(0.96 0.004 265);
--vibeui-buttongroup-026-fg:oklch(0.24 0.016 265);
--vibeui-buttongroup-026-muted:oklch(0.55 0.014 265);
--vibeui-buttongroup-026-border:oklch(0.9 0.006 265);
--vibeui-buttongroup-026-accent:oklch(0.45 0.13 305);
--vibeui-buttongroup-026-radius:0.5rem;
--vibeui-buttongroup-026-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-026"]{
box-sizing:border-box;display:block;width:100%;max-width:22rem;
margin:0;padding:0.375rem;border:1px solid var(--vibeui-buttongroup-026-border);
border-radius:0.875rem;
background:var(--vibeui-buttongroup-026-surface);
font-family:var(--vibeui-buttongroup-026-font);
}
[data-vibeui-block="buttongroup-026"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-026"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-026"] [data-part="track"]{
display:flex;gap:0.1875rem;padding:0.1875rem;
border-radius:calc(var(--vibeui-buttongroup-026-radius) + 0.1875rem);
background:var(--vibeui-buttongroup-026-track);
}
/* Анимируется доля во flex, а не ширина: сумма всегда равна треку. */
[data-vibeui-block="buttongroup-026"] [data-part="segment"]{
position:relative;flex:1 1 0;min-width:0;
display:inline-flex;align-items:center;justify-content:center;gap:0.3125rem;
height:2.125rem;padding:0 0.375rem;
border-radius:var(--vibeui-buttongroup-026-radius);
color:var(--vibeui-buttongroup-026-muted);
font-size:0.8125rem;font-weight:650;line-height:1;white-space:nowrap;cursor:pointer;
font-variant-numeric:tabular-nums;
transition:flex-grow .22s cubic-bezier(.2,.7,.3,1),background-color .18s ease,color .18s ease;
}
[data-vibeui-block="buttongroup-026"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
[data-vibeui-block="buttongroup-026"] [data-part="note"]{
max-width:0;overflow:hidden;opacity:0;
font-size:0.6875rem;font-weight:600;
transition:max-width .22s cubic-bezier(.2,.7,.3,1),opacity .18s ease;
}
[data-vibeui-block="buttongroup-026"] [data-part="segment"]:hover{color:var(--vibeui-buttongroup-026-fg)}
[data-vibeui-block="buttongroup-026"] [data-part="segment"]:has(input:checked){
flex-grow:2.4;
background:var(--vibeui-buttongroup-026-surface);
color:var(--vibeui-buttongroup-026-accent);
box-shadow:0 1px 2px oklch(0.2 0.02 265 / 16%);
}
[data-vibeui-block="buttongroup-026"] [data-part="segment"]:has(input:checked) [data-part="note"]{
max-width:8rem;opacity:1;
}
[data-vibeui-block="buttongroup-026"] [data-part="segment"]:has(input:focus-visible){
outline:2px solid var(--vibeui-buttongroup-026-accent);outline-offset:2px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-026"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_SPEEDS: Buttongroup026Speed[] = [
{ value: "0,5×", note: "медленно" },
{ value: "1×", note: "обычная" },
{ value: "1,5×", note: "быстрее" },
{ value: "2×", note: "вдвое" },
]
/**
* Скорость воспроизведения: выбранный сегмент раздвигается и поясняет себя.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Buttongroup026({
speeds = DEFAULT_SPEEDS,
defaultValue = "1×",
label = "Скорость воспроизведения",
name = "buttongroup-026",
accent,
className,
style,
...props
}: Buttongroup026Props) {
const palette = {
...(accent ? { "--vibeui-buttongroup-026-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-buttongroup-026" precedence="medium">
{STYLES}
</style>
<fieldset
{...props}
data-vibeui-block="buttongroup-026"
className={className}
style={palette}
>
<legend>{label}</legend>
<div data-part="track">
{speeds.map((speed) => (
<label key={speed.value} data-part="segment">
<input
type="radio"
name={name}
value={speed.value}
defaultChecked={speed.value === defaultValue}
/>
<span>{speed.value}</span>
<span data-part="note">{speed.note}</span>
</label>
))}
</div>
</fieldset>
</>
)
}