Checkbox

Choice Checkboxes

Multi-select as cards: the whole card is the tap target, not a 16-pixel box.

  • checkbox
  • cards
  • multiselect
  • form

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/checkbox-002?lang=en

Add to your orderВыбрано: 1 из 3
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 "checkbox-002" (Choice Checkboxes) 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/checkbox-002.json

Registry item: https://vibeui.ru/r/checkbox-002.json
Installs to: components/vibeui/checkbox-002.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
Multi-select as cards: the whole card is the tap target, not a 16-pixel box.

Multi-select cards: a title, description and price in each, a tick on the selected ones and a counter below. Zero dependencies, one file.

## 3. How to use it
import { Checkbox002 } from "@/components/vibeui/checkbox-002"

<Checkbox002 options={options} defaultValue={["delivery"]} onChange={setExtras} />

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-checkbox-002-* palette — do not swap it for your theme tokens
- the label around the whole card: the target must be card-sized
- real checkboxes: space, Tab and the "checked" announcement come free
- the fieldset with a legend — a group must have a name
- the border and tick on a selected card: colour alone fails colour-blind users
- the selected counter: it confirms the tap registered

## 6. You may change
- the options array: title, description and price
- legend — the group's name
- the onChange handler
- the accent through the accent prop

## 7. Rules
- More than five cards turn into a list: checkbox-004 fits that better.
- The price is a string: summing is the caller's job.
- The component submits nothing: set your own field names for a no-JS POST.
- 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/checkbox-002.json
https://vibeui.ru/r/checkbox-002.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-checkbox-002-*. Клиентский: "use client". Внутри настоящие input type="checkbox", растянутые на карточку и прозрачные; отмеченное состояние стилизуется через :has(input:checked). Группа обёрнута в fieldset с legend, счётчик выбранного стоит под списком.

Component source

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

"use client"

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

export type Checkbox002Option = {
  value: string
  title: string
  description: string
  price?: string
}

export type Checkbox002Props = Omit<
  ComponentPropsWithoutRef<"fieldset">,
  "children" | "onChange"
> & {
  legend?: string
  options?: Checkbox002Option[]
  defaultValue?: string[]
  onChange?: (value: string[]) => void
  accent?: string
}

// Идея компонента: множественный выбор карточками. Внутри настоящие checkbox,
// поэтому пробел, Tab и объявление «отмечено» работают сами. Вся карточка —
// label: попасть надо в неё, а не в квадратик 16 пикселей. Галочка нарисована
// бордюрами и появляется только у отмеченного.
const STYLES = `
:where([data-vibeui-block="checkbox-002"]){
--vibeui-checkbox-002-bg:oklch(1 0 0);
--vibeui-checkbox-002-surface:oklch(0.975 0.002 265);
--vibeui-checkbox-002-fg:oklch(0.22 0.014 265);
--vibeui-checkbox-002-muted:oklch(0.56 0.014 265);
--vibeui-checkbox-002-border:oklch(0.91 0.006 265);
--vibeui-checkbox-002-accent:oklch(0.55 0.17 265);
--vibeui-checkbox-002-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="checkbox-002"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:20rem;box-sizing:border-box;
margin:0;padding:0.875rem;
border:1px solid var(--vibeui-checkbox-002-border);border-radius:1rem;
background:var(--vibeui-checkbox-002-surface);
font-family:var(--vibeui-checkbox-002-font);color:var(--vibeui-checkbox-002-fg);
}
/* legend у fieldset садится на рамку и обрезается — float возвращает
   его в поток обычной строкой. */
[data-vibeui-block="checkbox-002"] legend{float:left;width:100%;padding:0;margin-bottom:0.375rem;font-size:0.8125rem;font-weight:650}
/* Вся карточка — label: цель нажатия размером с карточку, а не с квадратик. */
[data-vibeui-block="checkbox-002"] label{
position:relative;display:grid;grid-template-columns:auto 1fr auto;
align-items:start;gap:0.125rem 0.625rem;
padding:0.75rem;cursor:pointer;
border:1px solid var(--vibeui-checkbox-002-border);border-radius:0.75rem;
background:var(--vibeui-checkbox-002-bg);
}
[data-vibeui-block="checkbox-002"] input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}
[data-vibeui-block="checkbox-002"] [data-part="box"]{
grid-row:span 2;display:flex;align-items:center;justify-content:center;flex:none;
width:1.125rem;height:1.125rem;margin-top:0.125rem;box-sizing:border-box;
border:1.5px solid var(--vibeui-checkbox-002-border);border-radius:0.3125rem;
background:var(--vibeui-checkbox-002-bg);
}
[data-vibeui-block="checkbox-002"] [data-part="tick"]{
width:0.25rem;height:0.4375rem;margin-top:-0.0625rem;opacity:0;
border-right:2px solid oklch(0.99 0.01 265);border-bottom:2px solid oklch(0.99 0.01 265);
transform:rotate(45deg);
}
[data-vibeui-block="checkbox-002"] label:has(input:checked){
border-color:var(--vibeui-checkbox-002-accent);
box-shadow:inset 0 0 0 1px var(--vibeui-checkbox-002-accent);
}
[data-vibeui-block="checkbox-002"] label:has(input:checked) [data-part="box"]{
border-color:transparent;background:var(--vibeui-checkbox-002-accent);
}
[data-vibeui-block="checkbox-002"] label:has(input:checked) [data-part="tick"]{opacity:1}
[data-vibeui-block="checkbox-002"] label:has(input:focus-visible){outline:2px solid var(--vibeui-checkbox-002-accent);outline-offset:2px}
[data-vibeui-block="checkbox-002"] [data-part="title"]{font-size:0.875rem;font-weight:650;line-height:1.3}
[data-vibeui-block="checkbox-002"] [data-part="price"]{grid-column:3;grid-row:span 2;justify-self:end;font-size:0.875rem;font-weight:680;font-variant-numeric:tabular-nums}
[data-vibeui-block="checkbox-002"] [data-part="description"]{grid-column:2;font-size:0.8125rem;line-height:1.4;color:var(--vibeui-checkbox-002-muted)}
[data-vibeui-block="checkbox-002"] [data-part="count"]{font-size:0.75rem;color:var(--vibeui-checkbox-002-muted)}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="checkbox-002"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_OPTIONS: Checkbox002Option[] = [
  {
    value: "delivery",
    title: "Доставка курьером",
    description: "Привезём завтра с 10:00 до 14:00.",
    price: "390 ₽",
  },
  {
    value: "assembly",
    title: "Сборка на месте",
    description: "Соберём и заберём упаковку с собой.",
    price: "1 200 ₽",
  },
  {
    value: "insurance",
    title: "Страховка на год",
    description: "Замена при поломке без экспертизы.",
    price: "590 ₽",
  },
]

/**
 * Множественный выбор карточками на настоящих checkbox.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Checkbox002({
  legend = "Дополнительно к заказу",
  options = DEFAULT_OPTIONS,
  defaultValue = ["delivery"],
  onChange,
  accent,
  className,
  style,
  ...props
}: Checkbox002Props) {
  const id = useId()
  const [value, setValue] = useState<string[]>(defaultValue)

  const palette = {
    ...(accent ? { "--vibeui-checkbox-002-accent": accent } : null),
    ...style,
  } as CSSProperties

  const toggle = (option: string) => {
    const next = value.includes(option)
      ? value.filter((item) => item !== option)
      : [...value, option]
    setValue(next)
    onChange?.(next)
  }

  return (
    <>
      <style href="vibeui-checkbox-002" precedence="medium">
        {STYLES}
      </style>
      <fieldset
        {...props}
        data-vibeui-block="checkbox-002"
        className={className}
        style={palette}
      >
        <legend>{legend}</legend>
        {options.map((option) => (
          <label key={option.value}>
            <input
              type="checkbox"
              name={`${id}-${option.value}`}
              checked={value.includes(option.value)}
              onChange={() => toggle(option.value)}
            />
            <span data-part="box" aria-hidden="true">
              <span data-part="tick" />
            </span>
            <span data-part="title">{option.title}</span>
            {option.price ? (
              <span data-part="price">{option.price}</span>
            ) : null}
            <span data-part="description">{option.description}</span>
          </label>
        ))}
        <span data-part="count">
          Выбрано: {value.length} из {options.length}
        </span>
      </fieldset>
    </>
  )
}