Feedback

Colour Picker

A label colour picker where a colour is a radio button, not a div with a handler: arrow keys work, the value reaches the form, and no JS is needed.

  • popover
  • color
  • radio
  • swatches

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/popover-005?lang=en

Label colour

Цвет применится ко всем задачам с этой меткой.

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 "popover-005" (Colour Picker) 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/popover-005.json

Registry item: https://vibeui.ru/r/popover-005.json
Installs to: components/vibeui/popover-005.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 label colour picker where a colour is a radio button, not a div with a handler: arrow keys work, the value reaches the form, and no JS is needed.

A colour popover: a grid of swatches built on hidden radio buttons. Zero dependencies, one file, the browser owns the state.

## 3. How to use it
import { Popover005 } from "@/components/vibeui/popover-005"

<Popover005
  label="Label colour"
  selected="Синий"
  swatches={[{ name: "Синий", value: "oklch(0.6 0.17 255)" }]}
/>

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-popover-005-* palette — do not swap it for your theme tokens
- the panel layout only inside the :popover-open rule — display in the plain rule overrides the browser's display:none and the panel stays open forever
- radio buttons instead of divs with handlers: only then do arrow keys work and the value reach the form
- hiding the radio with clip-path rather than display:none — otherwise the swatches leave the focus order
- the colour name in every swatch label: a single hue cannot be spoken aloud
- clear:both on the grid: a floated legend makes the following children wrap around it

## 6. You may change
- the trigger caption through label and the current colour through selected
- the palette through swatches
- the number of columns in the grid rule
- the focus accent through the --vibeui-popover-005-accent variable

## 7. Rules
- The selection is not lifted up: the caller attaches the change handler.
- The ring on the selected swatch relies on :has(): in older browsers it simply will not appear.
- Ten swatches in two rows is the readability ceiling; a long palette is better split into sections.
- 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/popover-005.json
https://vibeui.ru/r/popover-005.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-popover-005-*. Серверный: панель на HTML popover, имя группы разводит useId. Раскладка объявлена только в :popover-open. Кружки — это label с визуально скрытым radio внутри; выбранный обведён кольцом через :has(input:checked), а фокус ловится через :has(input:focus-visible). Цвет каждого кружка приходит в собственной переменной --vibeui-popover-005-swatch. Legend с float:left требует clear:both у сетки.

Component source

The same file your agent installs. Here in case you would rather copy it by hand.

import { useId } from "react"
import type { ComponentPropsWithoutRef, CSSProperties } from "react"

export type Popover005Props = Omit<
  ComponentPropsWithoutRef<"div">,
  "children"
> & {
  label?: string
  /** Палитра меток: каждый цвет — отдельная радиокнопка с подписью. */
  swatches?: { name: string; value: string }[]
  /** Имя выбранного по умолчанию цвета. */
  selected?: string
}

// Идея компонента: выбор цвета метки, где цвет — это radio, а не div с
// обработчиком. Кружки нарисованы из спрятанных радиокнопок, поэтому выбор
// работает стрелками, попадает в форму и не требует ни строчки JS.
const STYLES = `
:where([data-vibeui-block="popover-005"]){
--vibeui-popover-005-bg:oklch(1 0 0);
--vibeui-popover-005-fg:oklch(0.23 0.014 265);
--vibeui-popover-005-muted:oklch(0.54 0.014 265);
--vibeui-popover-005-border:oklch(0.89 0.006 265);
--vibeui-popover-005-accent:oklch(0.55 0.17 265);
--vibeui-popover-005-swatch:oklch(0.6 0.17 255);
--vibeui-popover-005-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="popover-005"]{
position:relative;display:inline-block;
font-family:var(--vibeui-popover-005-font);color:var(--vibeui-popover-005-fg);
}
[data-vibeui-block="popover-005"] [data-part="trigger"]{
appearance:none;cursor:pointer;
display:inline-flex;align-items:center;gap:0.5rem;
height:2.25rem;padding:0 0.875rem 0 0.625rem;border-radius:0.625rem;
border:1px solid var(--vibeui-popover-005-border);
background:var(--vibeui-popover-005-bg);color:inherit;
font:inherit;font-size:0.8125rem;font-weight:620;
anchor-name:--vibeui-popover-005-anchor;
}
[data-vibeui-block="popover-005"] [data-part="chip"]{
width:1rem;height:1rem;border-radius:0.3125rem;flex:none;
box-shadow:inset 0 0 0 1px oklch(0 0 0 / 12%);
}
[data-vibeui-block="popover-005"] [data-part="trigger"]:focus-visible{outline:2px solid var(--vibeui-popover-005-accent);outline-offset:2px}
/* Раскладка панели — только под :popover-open, иначе display перебьёт
   собственный display:none браузера и панель не закроется никогда. */
[data-vibeui-block="popover-005"] [data-part="panel"]{
position:fixed;margin:0;padding:0.75rem;
width:min(14.5rem,100vw - 2rem);box-sizing:border-box;
border:1px solid var(--vibeui-popover-005-border);border-radius:0.875rem;
background:var(--vibeui-popover-005-bg);color:inherit;
box-shadow:0 24px 50px -30px oklch(0.2 0.02 265 / 60%);
position-anchor:--vibeui-popover-005-anchor;
top:anchor(bottom);left:anchor(left);margin-top:0.5rem;
}
[data-vibeui-block="popover-005"] [data-part="panel"]:popover-open{display:flex;flex-direction:column;gap:0.625rem}
@supports not (anchor-name: --a){
[data-vibeui-block="popover-005"] [data-part="panel"]{position:absolute;inset:auto;top:calc(100% + 0.5rem);left:0}
}
[data-vibeui-block="popover-005"] fieldset{margin:0;padding:0;border:0;min-width:0}
[data-vibeui-block="popover-005"] legend{
padding:0;margin-bottom:0.5rem;float:left;width:100%;
font-size:0.6875rem;font-weight:700;letter-spacing:0.05em;text-transform:uppercase;
color:var(--vibeui-popover-005-muted);
}
/* legend с float:left ломает поток следующих детей — обязательный clear. */
[data-vibeui-block="popover-005"] [data-part="grid"]{
clear:both;display:grid;grid-template-columns:repeat(5,1fr);gap:0.375rem;
}
[data-vibeui-block="popover-005"] [data-part="swatch"]{
position:relative;display:block;cursor:pointer;
aspect-ratio:1;border-radius:0.5rem;
background:var(--vibeui-popover-005-swatch);
box-shadow:inset 0 0 0 1px oklch(0 0 0 / 12%);
transition:transform .14s ease;
}
[data-vibeui-block="popover-005"] [data-part="swatch"]:hover{transform:scale(1.08)}
[data-vibeui-block="popover-005"] [data-part="swatch"] input{
position:absolute;width:1px;height:1px;margin:-1px;padding:0;
overflow:hidden;clip-path:inset(50%);border:0;
}
/* Выбранный кружок обведён кольцом того же цвета: :has() вместо класса. */
[data-vibeui-block="popover-005"] [data-part="swatch"]:has(input:checked){
box-shadow:inset 0 0 0 1px oklch(0 0 0 / 12%),0 0 0 2px var(--vibeui-popover-005-bg),0 0 0 4px var(--vibeui-popover-005-swatch);
}
[data-vibeui-block="popover-005"] [data-part="swatch"]:has(input:focus-visible){outline:2px solid var(--vibeui-popover-005-accent);outline-offset:3px}
[data-vibeui-block="popover-005"] [data-part="sr"]{
position:absolute;width:1px;height:1px;margin:-1px;padding:0;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="popover-005"] [data-part="hint"]{
margin:0;font-size:0.75rem;line-height:1.4;color:var(--vibeui-popover-005-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="popover-005"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_SWATCHES = [
  { name: "Графит", value: "oklch(0.45 0.02 265)" },
  { name: "Синий", value: "oklch(0.6 0.17 255)" },
  { name: "Бирюзовый", value: "oklch(0.7 0.13 195)" },
  { name: "Зелёный", value: "oklch(0.68 0.16 150)" },
  { name: "Жёлтый", value: "oklch(0.83 0.15 90)" },
  { name: "Оранжевый", value: "oklch(0.7 0.17 55)" },
  { name: "Красный", value: "oklch(0.62 0.2 25)" },
  { name: "Розовый", value: "oklch(0.68 0.18 350)" },
  { name: "Фиолетовый", value: "oklch(0.58 0.19 300)" },
  { name: "Лавандовый", value: "oklch(0.75 0.09 290)" },
]

/**
 * Поповер выбора цвета метки: сетка кружков на спрятанных радиокнопках.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Popover005({
  label = "Цвет метки",
  swatches = DEFAULT_SWATCHES,
  selected = "Синий",
  className,
  style,
  ...props
}: Popover005Props) {
  const id = useId().replace(/:/g, "")
  const current =
    swatches.find((swatch) => swatch.name === selected) ?? swatches[0]

  return (
    <>
      <style href="vibeui-popover-005" precedence="medium">
        {STYLES}
      </style>
      <div
        {...props}
        data-vibeui-block="popover-005"
        className={className}
        style={style as CSSProperties}
      >
        <button type="button" data-part="trigger" popoverTarget={`${id}-panel`}>
          <span
            data-part="chip"
            style={{ background: current?.value }}
            aria-hidden="true"
          />
          {label}
        </button>
        <div
          data-part="panel"
          id={`${id}-panel`}
          popover="auto"
          aria-label={label}
        >
          <fieldset>
            <legend>{label}</legend>
            <div data-part="grid">
              {swatches.map((swatch) => (
                <label
                  data-part="swatch"
                  key={swatch.name}
                  title={swatch.name}
                  style={
                    {
                      "--vibeui-popover-005-swatch": swatch.value,
                    } as CSSProperties
                  }
                >
                  <input
                    type="radio"
                    name={`${id}-color`}
                    value={swatch.name}
                    defaultChecked={swatch.name === current?.name}
                  />
                  <span data-part="sr">{swatch.name}</span>
                </label>
              ))}
            </div>
          </fieldset>
          <p data-part="hint">Цвет применится ко всем задачам с этой меткой.</p>
        </div>
      </div>
    </>
  )
}