Button Group
Theme Swatches
A theme picker made of interface swatches instead of a sun and a moon: "system" is cut diagonally with clip-path — half light, half dark.
- buttongroup
- theme
- swatch
- settings
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-029?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-029" (Theme Swatches) 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-029.json
Registry item: https://vibeui.ru/r/buttongroup-029.json
Installs to: components/vibeui/buttongroup-029.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 theme picker made of interface swatches instead of a sun and a moon: "system" is cut diagonally with clip-path — half light, half dark.
A theme picker built from interface thumbnails, including a half-and-half "system" swatch. Zero dependencies, one file, a server component.
## 3. How to use it
import { Buttongroup029 } from "@/components/vibeui/buttongroup-029"
<Buttongroup029
lightLabel="Light"
darkLabel="Dark"
systemLabel="System"
defaultValue="system"
/>
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-029-* palette — do not swap it for your theme tokens
- the swatches' own colours: a thumbnail inheriting the page theme vanishes into its own background
- the diagonal cut on "system" — it explains the option without a caption
- the caption under every swatch: not everyone tells "system" from "dark" at a glance
- the box-shadow matching the selected border: a single border looks thinner than its neighbours
- radios inside a fieldset — a theme choice must work with arrows and reach the form
## 6. You may change
- the option captions through lightLabel, darkLabel and systemLabel
- the initial theme through defaultValue
- the accessible group name through label
- the form field name through name and the selection colour through accent
## 7. Rules
- There are exactly three options: a fourth swatch has to be drawn by hand.
- The component does not switch the theme: your code applies it after submit.
- The swatch stripes are aria-hidden decoration — there is no point adding text to them.
- 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-029.jsonhttps://vibeui.ru/r/buttongroup-029.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-029-*. Серверный: выбор держат radio внутри fieldset. Каждый сегмент несёт миниатюру интерфейса: рамка, три полоски «текста» на абсолютных позициях и заливка. Тёмный образец меняет и фон, и цвет полосок; «системная» получает ::after с clip-path:polygon(100% 0,100% 100%,0 100%) — диагональ объясняет «как в системе» без слов. Образцы держат собственные цвета, не зависящие от темы страницы: иначе светлая миниатюра исчезла бы на светлом фоне. Сегменты не сцеплены, они стоят карточками в grid с gap; выбранный получает рамку и box-shadow в тот же цвет, чтобы линия не выглядела тоньше соседних.
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 Buttongroup029Props = Omit<
ComponentPropsWithoutRef<"fieldset">,
"children"
> & {
lightLabel?: string
darkLabel?: string
systemLabel?: string
defaultValue?: string
label?: string
name?: string
accent?: string
}
// Идея компонента: выбор темы, где каждый сегмент показывает не значок
// солнца или луны, а сам образец — миниатюру интерфейса с полосками текста.
// «Системная» нарисована диагональным разрезом clip-path: одна половина
// светлая, другая тёмная, и это честно объясняет «как в системе» без слов.
// Образцы держат собственные цвета, не зависящие от темы страницы: иначе
// светлая миниатюра исчезла бы на светлом фоне.
const STYLES = `
:where([data-vibeui-block="buttongroup-029"]){
--vibeui-buttongroup-029-surface:oklch(1 0 0);
--vibeui-buttongroup-029-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-029-muted:oklch(0.57 0.014 265);
--vibeui-buttongroup-029-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-029-accent:oklch(0.52 0.16 285);
--vibeui-buttongroup-029-light:oklch(0.98 0.003 265);
--vibeui-buttongroup-029-dark:oklch(0.29 0.02 265);
--vibeui-buttongroup-029-radius:0.75rem;
--vibeui-buttongroup-029-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-029"]{
box-sizing:border-box;display:block;width:100%;max-width:23rem;
margin:0;padding:0;border:0;
font-family:var(--vibeui-buttongroup-029-font);
}
[data-vibeui-block="buttongroup-029"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-029"] legend{
position:absolute;width:1px;height:1px;padding:0;margin:-1px;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="buttongroup-029"] [data-part="track"]{
display:grid;grid-template-columns:repeat(3,1fr);gap:0.5rem;
}
[data-vibeui-block="buttongroup-029"] [data-part="option"]{
position:relative;
display:flex;flex-direction:column;align-items:center;gap:0.4375rem;
padding:0.5rem 0.375rem 0.625rem;
border:1px solid var(--vibeui-buttongroup-029-border);
border-radius:var(--vibeui-buttongroup-029-radius);
background:var(--vibeui-buttongroup-029-surface);
color:var(--vibeui-buttongroup-029-muted);
font-size:0.75rem;font-weight:650;line-height:1;cursor:pointer;
transition:border-color .16s ease,color .16s ease,box-shadow .16s ease;
}
[data-vibeui-block="buttongroup-029"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
/* Миниатюра интерфейса вместо значка. */
[data-vibeui-block="buttongroup-029"] [data-part="swatch"]{
position:relative;display:block;width:100%;height:3rem;
border:1px solid oklch(0.86 0.008 265);border-radius:0.5rem;overflow:hidden;
background:var(--vibeui-buttongroup-029-light);
}
[data-vibeui-block="buttongroup-029"] [data-part="swatch"] i{
position:absolute;left:0.4375rem;height:0.25rem;border-radius:2px;
background:oklch(0.72 0.01 265);
}
[data-vibeui-block="buttongroup-029"] [data-part="swatch"] i:nth-child(1){top:0.5rem;width:55%}
[data-vibeui-block="buttongroup-029"] [data-part="swatch"] i:nth-child(2){top:1.125rem;width:75%}
[data-vibeui-block="buttongroup-029"] [data-part="swatch"] i:nth-child(3){top:1.75rem;width:40%}
[data-vibeui-block="buttongroup-029"] [data-theme="dark"]{background:var(--vibeui-buttongroup-029-dark)}
[data-vibeui-block="buttongroup-029"] [data-theme="dark"] i{background:oklch(0.62 0.014 265)}
/* Диагональный разрез: половина светлая, половина тёмная. */
[data-vibeui-block="buttongroup-029"] [data-theme="system"]::after{
content:"";position:absolute;inset:0;
background:var(--vibeui-buttongroup-029-dark);
clip-path:polygon(100% 0,100% 100%,0 100%);
}
[data-vibeui-block="buttongroup-029"] [data-part="option"]:hover{color:var(--vibeui-buttongroup-029-fg)}
[data-vibeui-block="buttongroup-029"] [data-part="option"]:has(input:checked){
border-color:var(--vibeui-buttongroup-029-accent);
color:var(--vibeui-buttongroup-029-accent);
box-shadow:0 0 0 1px var(--vibeui-buttongroup-029-accent);
}
[data-vibeui-block="buttongroup-029"] [data-part="option"]:has(input:focus-visible){
outline:2px solid var(--vibeui-buttongroup-029-accent);outline-offset:2px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-029"] *{animation:none!important;transition:none!important}}
`
/**
* Выбор темы образцами интерфейса: светлая, тёмная и разрезанная «системная».
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Buttongroup029({
lightLabel = "Светлая",
darkLabel = "Тёмная",
systemLabel = "Системная",
defaultValue = "system",
label = "Тема оформления",
name = "buttongroup-029",
accent,
className,
style,
...props
}: Buttongroup029Props) {
const options = [
{ id: "light", label: lightLabel },
{ id: "dark", label: darkLabel },
{ id: "system", label: systemLabel },
]
const palette = {
...(accent ? { "--vibeui-buttongroup-029-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-buttongroup-029" precedence="medium">
{STYLES}
</style>
<fieldset
{...props}
data-vibeui-block="buttongroup-029"
className={className}
style={palette}
>
<legend>{label}</legend>
<div data-part="track">
{options.map((option) => (
<label key={option.id} data-part="option">
<input
type="radio"
name={name}
value={option.id}
defaultChecked={option.id === defaultValue}
/>
<span
data-part="swatch"
data-theme={option.id}
aria-hidden="true"
>
<i />
<i />
<i />
</span>
<span>{option.label}</span>
</label>
))}
</div>
</fieldset>
</>
)
}