Button Group
File Type Chips
A file type filter that shows the extension as text instead of an icon: three letters read unambiguously, while a "sheet with a folded corner" is the same for every type.
- buttongroup
- files
- filter
- chips
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-047?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-047" (File Type Chips) 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-047.json
Registry item: https://vibeui.ru/r/buttongroup-047.json
Installs to: components/vibeui/buttongroup-047.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 file type filter that shows the extension as text instead of an icon: three letters read unambiguously, while a "sheet with a folded corner" is the same for every type.
A file type filter with the extension on a coloured plate instead of an icon. Zero dependencies, one file, a server component.
## 3. How to use it
import { Buttongroup047 } from "@/components/vibeui/buttongroup-047"
<Buttongroup047
kinds={[{ id: "pdf", short: "PDF", label: "PDF documents", hue: 25 }]}
defaultValue={["pdf"]}
label="File type"
name="kind"
/>
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-047-* palette — do not swap it for your theme tokens
- the extension as text instead of an icon: the "sheet of paper" silhouette is identical for every type
- the colour passed as a hue into an oklch formula — the text contrast then holds at any hue
- checkboxes instead of radios: file types are filtered together
- letting the chips wrap: the list of extensions grows and a rigid cluster overflows the screen
- the border and inset box-shadow in one colour on the selected chip, so the line does not look thinner
## 6. You may change
- the types, their extensions and hues through kinds
- the initially enabled types through defaultValue
- the accessible group name through label
- the form field prefix through name and the selection colour through accent
## 7. Rules
- Every checkbox gets a name of the form name-id: on the server these are separate fields, not an array.
- The plate is sized for three or four characters: "PPTX" already stretches the chip.
- The component filters nothing: your code queries by the form values.
- 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-047.jsonhttps://vibeui.ru/r/buttongroup-047.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в переменных --vibeui-buttongroup-047-*. Серверный: выбор множественный, внутри checkbox. Цвет плашки приходит числом оттенка и подставляется инлайновой переменной --vibeui-buttongroup-047-hue, а сами цвета собираются формулой oklch(0.94 0.06 hue) и oklch(0.42 0.15 hue): палитра остаётся одной формулой, а не набором хардкодов, и контраст текста к фону держится на всех оттенках. Пилюли не сцеплены, они переносятся по строкам с gap — список расширений растёт, и жёсткая сцепка выехала бы за экран. Выбранная пилюля помечена рамкой и inset 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 Buttongroup047Kind = {
id: string
short: string
label: string
hue: number
}
export type Buttongroup047Props = Omit<
ComponentPropsWithoutRef<"fieldset">,
"children"
> & {
kinds?: Buttongroup047Kind[]
defaultValue?: string[]
label?: string
name?: string
accent?: string
}
// Идея компонента: фильтр по типу файла, где вместо значка стоит расширение
// текстом. Три буквы читаются однозначно, а «лист бумаги с загнутым углом»
// одинаков у всех типов и не различается на 16 пикселях. Цвет плашки
// приходит числом оттенка и подставляется в oklch через одну инлайновую
// переменную: так палитра остаётся одной формулой, а не набором хардкодов.
// Выбор множественный — на checkbox: типы складываются. Пилюли переносятся
// по строкам, поэтому список расширений можно расширять без переделки.
const STYLES = `
:where([data-vibeui-block="buttongroup-047"]){
--vibeui-buttongroup-047-surface:oklch(1 0 0);
--vibeui-buttongroup-047-fg:oklch(0.25 0.016 265);
--vibeui-buttongroup-047-muted:oklch(0.57 0.014 265);
--vibeui-buttongroup-047-border:oklch(0.89 0.008 265);
--vibeui-buttongroup-047-accent:oklch(0.42 0.03 265);
--vibeui-buttongroup-047-hue:265;
--vibeui-buttongroup-047-radius:0.5rem;
--vibeui-buttongroup-047-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="buttongroup-047"]{
box-sizing:border-box;display:block;width:100%;max-width:28rem;
margin:0;padding:0;border:0;
font-family:var(--vibeui-buttongroup-047-font);
}
[data-vibeui-block="buttongroup-047"] *{box-sizing:border-box}
[data-vibeui-block="buttongroup-047"] legend{
padding:0;margin:0 0 0.5rem;float:left;width:100%;clear:both;
color:var(--vibeui-buttongroup-047-muted);
font-size:0.6875rem;font-weight:700;letter-spacing:0.06em;text-transform:uppercase;
}
[data-vibeui-block="buttongroup-047"] [data-part="track"]{
display:flex;flex-wrap:wrap;gap:0.375rem;clear:both;
}
[data-vibeui-block="buttongroup-047"] [data-part="chip"]{
position:relative;
display:inline-flex;align-items:center;gap:0.4375rem;
height:2.125rem;padding:0 0.6875rem 0 0.3125rem;
border:1px solid var(--vibeui-buttongroup-047-border);
border-radius:var(--vibeui-buttongroup-047-radius);
background:var(--vibeui-buttongroup-047-surface);
color:var(--vibeui-buttongroup-047-muted);
font-size:0.8125rem;font-weight:600;line-height:1;white-space:nowrap;cursor:pointer;
transition:border-color .16s ease,color .16s ease,background-color .16s ease;
}
[data-vibeui-block="buttongroup-047"] input{
position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer;
}
/* Плашка расширения: цвет — одна формула от оттенка. */
[data-vibeui-block="buttongroup-047"] [data-part="ext"]{
display:inline-flex;align-items:center;justify-content:center;
min-width:2.0625rem;height:1.5rem;padding:0 0.3125rem;
border-radius:0.3125rem;
background:oklch(0.94 0.06 var(--vibeui-buttongroup-047-hue));
color:oklch(0.42 0.15 var(--vibeui-buttongroup-047-hue));
font-size:0.625rem;font-weight:800;letter-spacing:0.04em;
}
[data-vibeui-block="buttongroup-047"] [data-part="chip"]:hover{
border-color:oklch(0.8 0.01 265);color:var(--vibeui-buttongroup-047-fg);
}
[data-vibeui-block="buttongroup-047"] [data-part="chip"]:has(input:checked){
border-color:var(--vibeui-buttongroup-047-accent);
background:oklch(0.97 0.004 265);
color:var(--vibeui-buttongroup-047-fg);
box-shadow:inset 0 0 0 1px var(--vibeui-buttongroup-047-accent);
}
[data-vibeui-block="buttongroup-047"] [data-part="chip"]:has(input:focus-visible){
outline:2px solid var(--vibeui-buttongroup-047-accent);outline-offset:2px;
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="buttongroup-047"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_KINDS: Buttongroup047Kind[] = [
{ id: "pdf", short: "PDF", label: "Документы PDF", hue: 25 },
{ id: "doc", short: "DOC", label: "Тексты", hue: 250 },
{ id: "xls", short: "XLS", label: "Таблицы", hue: 150 },
{ id: "img", short: "IMG", label: "Изображения", hue: 300 },
{ id: "zip", short: "ZIP", label: "Архивы", hue: 80 },
]
/**
* Фильтр по типу файла: вместо значка — расширение текстом на цветной плашке.
* Один файл, ноль зависимостей, собственная палитра.
*/
export function Buttongroup047({
kinds = DEFAULT_KINDS,
defaultValue = ["pdf", "img"],
label = "Тип файла",
name = "buttongroup-047",
accent,
className,
style,
...props
}: Buttongroup047Props) {
const palette = {
...(accent ? { "--vibeui-buttongroup-047-accent": accent } : null),
...style,
} as CSSProperties
return (
<>
<style href="vibeui-buttongroup-047" precedence="medium">
{STYLES}
</style>
<fieldset
{...props}
data-vibeui-block="buttongroup-047"
className={className}
style={palette}
>
<legend>{label}</legend>
<div data-part="track">
{kinds.map((kind) => (
<label
key={kind.id}
data-part="chip"
style={
{ "--vibeui-buttongroup-047-hue": kind.hue } as CSSProperties
}
>
<input
type="checkbox"
name={`${name}-${kind.id}`}
value={kind.id}
defaultChecked={defaultValue.includes(kind.id)}
/>
<span data-part="ext" aria-hidden="true">
{kind.short}
</span>
<span>{kind.label}</span>
</label>
))}
</div>
</fieldset>
</>
)
}