Checkbox

Addon Cards

Checkbox cards with prices: selection is drawn as an inset ring so the card never shifts, and the prices add up to a total below.

  • checkbox
  • cards
  • pricing
  • multiselect

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-010?lang=en

Add-ons

Дополнения: 1300 $/mo

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-010" (Addon Cards) 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-010.json

Registry item: https://vibeui.ru/r/checkbox-010.json
Installs to: components/vibeui/checkbox-010.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
Checkbox cards with prices: selection is drawn as an inset ring so the card never shifts, and the prices add up to a total below.

Checkbox cards for order add-ons: a title, a note, a price and a "recommended" flag. A selected card gets an inset ring and a round tick, and the total is summed underneath. Zero dependencies, one file.

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

<Checkbox010
  legend="Add-ons"
  addons={addons}
  currency="$/mo"
  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-010-* palette — do not swap it for your theme tokens
- the selection ring via inset box-shadow: changing the border changes the size and shifts the neighbours
- the hidden but real input: Tab, space and the "checked" announcement rest on it
- the round tick beside the title — background colour alone fails colour-blind users
- the total under the list: picking add-ons is pointless without a sum
- clear:both on the cards — otherwise they wrap around the floated legend

## 6. You may change
- the addons array: title, note, price and the recommended flag
- legend — the group's name
- currency — the unit shown next to the numbers
- the onChange handler and the accent through the accent prop

## 7. Rules
- Prices are numbers: rounding and tax are the caller's job, the component only adds up.
- Beyond five cards a list reads better: use checkbox-004 or checkbox-016.
- Keep a single "recommended" flag: two recommendations recommend nothing.
- 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-010.json
https://vibeui.ru/r/checkbox-010.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-checkbox-010-*. Клиентский: "use client". Настоящий input спрятан визуально (clip-path: inset(50%)), состояние карточки берётся через :has(input:checked). Выбор показан box-shadow inset в два пикселя вместо смены border — геометрия карточки не меняется и соседи не съезжают. Группа обёрнута в fieldset с legend, у legend стоит float и clear:both у карточек.

Component source

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

"use client"

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

export type Checkbox010Addon = {
  id: string
  title: string
  note: string
  price: number
  recommended?: boolean
}

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

// Идея компонента: карточка-чекбокс, у которой выбор рисуется вложенной
// рамкой через box-shadow inset, а не толщиной border, — карточка не дёргается
// на ширину пикселя при отметке. Цены складываются в итог под списком, поэтому
// выбор сразу отвечает на вопрос «сколько всего».
const STYLES = `
:where([data-vibeui-block="checkbox-010"]){
--vibeui-checkbox-010-bg:oklch(1 0 0);
--vibeui-checkbox-010-fg:oklch(0.21 0.014 265);
--vibeui-checkbox-010-muted:oklch(0.55 0.014 265);
--vibeui-checkbox-010-border:oklch(0.9 0.006 265);
--vibeui-checkbox-010-surface:oklch(0.985 0.002 265);
--vibeui-checkbox-010-accent:oklch(0.52 0.15 168);
--vibeui-checkbox-010-soft:oklch(0.96 0.03 168);
--vibeui-checkbox-010-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="checkbox-010"]{
display:flex;flex-direction:column;gap:0.5rem;
width:100%;max-width:24rem;box-sizing:border-box;
margin:0;padding:0.875rem;border:1px solid var(--vibeui-checkbox-010-border);border-radius:1rem;
background:var(--vibeui-checkbox-010-bg);
font-family:var(--vibeui-checkbox-010-font);color:var(--vibeui-checkbox-010-fg);
}
/* legend у fieldset садится на рамку: float возвращает его в поток, а
   clear:both не даёт следующим карточкам обтекать его. */
[data-vibeui-block="checkbox-010"] legend{float:left;width:100%;padding:0 0 0.25rem;font-size:0.8125rem;font-weight:650}
[data-vibeui-block="checkbox-010"] [data-part="card"]{
clear:both;display:grid;grid-template-columns:1fr auto;column-gap:0.75rem;row-gap:0.25rem;
padding:0.75rem;border-radius:0.75rem;cursor:pointer;
background:var(--vibeui-checkbox-010-surface);
box-shadow:inset 0 0 0 1px var(--vibeui-checkbox-010-border);
transition:box-shadow .16s ease,background-color .16s ease;
}
[data-vibeui-block="checkbox-010"] [data-part="card"]:hover{background:var(--vibeui-checkbox-010-bg)}
/* Выбор — вложенная рамка в два пикселя вместо смены border: геометрия
   карточки не меняется, соседи не съезжают. */
[data-vibeui-block="checkbox-010"] [data-part="card"]:has(input:checked){
background:var(--vibeui-checkbox-010-soft);
box-shadow:inset 0 0 0 2px var(--vibeui-checkbox-010-accent);
}
[data-vibeui-block="checkbox-010"] [data-part="card"]:has(input:focus-visible){
outline:2px solid var(--vibeui-checkbox-010-accent);outline-offset:2px;
}
[data-vibeui-block="checkbox-010"] input{
appearance:none;position:absolute;width:1px;height:1px;margin:0;padding:0;
overflow:hidden;clip-path:inset(50%);white-space:nowrap;
}
[data-vibeui-block="checkbox-010"] [data-part="head"]{
display:flex;align-items:center;gap:0.375rem;font-size:0.875rem;font-weight:600;
}
[data-vibeui-block="checkbox-010"] [data-part="tick"]{
display:inline-flex;flex:none;width:1rem;height:1rem;border-radius:9999px;position:relative;
box-shadow:inset 0 0 0 1.5px var(--vibeui-checkbox-010-border);
}
[data-vibeui-block="checkbox-010"] [data-part="card"]:has(input:checked) [data-part="tick"]{
background:var(--vibeui-checkbox-010-accent);box-shadow:none;
}
[data-vibeui-block="checkbox-010"] [data-part="card"]:has(input:checked) [data-part="tick"]::after{
content:"";position:absolute;left:50%;top:50%;
width:0.1875rem;height:0.375rem;margin:-0.28125rem 0 0 -0.09375rem;
border-right:2px solid oklch(0.99 0.01 168);border-bottom:2px solid oklch(0.99 0.01 168);
transform:rotate(45deg);
}
[data-vibeui-block="checkbox-010"] [data-part="flag"]{
padding:0.0625rem 0.375rem;border-radius:9999px;
background:var(--vibeui-checkbox-010-accent);color:oklch(0.99 0.01 168);
font-size:0.625rem;font-weight:700;letter-spacing:0.03em;text-transform:uppercase;
}
[data-vibeui-block="checkbox-010"] [data-part="price"]{
grid-row:1;grid-column:2;align-self:center;justify-self:end;
font-size:0.875rem;font-weight:650;font-variant-numeric:tabular-nums;
}
[data-vibeui-block="checkbox-010"] [data-part="note"]{
grid-column:1 / -1;font-size:0.75rem;line-height:1.45;color:var(--vibeui-checkbox-010-muted);
}
[data-vibeui-block="checkbox-010"] [data-part="total"]{
display:flex;align-items:baseline;justify-content:space-between;gap:0.5rem;
margin:0.25rem 0 0;padding-top:0.625rem;
border-top:1px solid var(--vibeui-checkbox-010-border);
font-size:0.8125rem;
}
[data-vibeui-block="checkbox-010"] [data-part="sum"]{font-weight:700;font-variant-numeric:tabular-nums}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="checkbox-010"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_ADDONS: Checkbox010Addon[] = [
  {
    id: "backup",
    title: "Ежедневные бэкапы",
    note: "Копия базы каждую ночь, хранится месяц.",
    price: 300,
    recommended: true,
  },
  {
    id: "domain",
    title: "Свой домен",
    note: "Подключение и сертификат без доплаты.",
    price: 150,
  },
  {
    id: "support",
    title: "Поддержка 24/7",
    note: "Ответ в течение часа в любой день.",
    price: 900,
  },
]

/**
 * Карточки-чекбоксы с рамкой выбора и итоговой суммой.
 * Один файл, ноль зависимостей, собственная палитра.
 */
export function Checkbox010({
  legend = "Дополнения к тарифу",
  addons = DEFAULT_ADDONS,
  defaultValue = ["backup"],
  currency = "₽/мес",
  onChange,
  accent,
  className,
  style,
  ...props
}: Checkbox010Props) {
  const [value, setValue] = useState<string[]>(defaultValue)

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

  const total = addons
    .filter((addon) => value.includes(addon.id))
    .reduce((sum, addon) => sum + addon.price, 0)

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

    setValue(next)
    onChange?.(next)
  }

  return (
    <>
      <style href="vibeui-checkbox-010" precedence="medium">
        {STYLES}
      </style>
      <fieldset
        {...props}
        data-vibeui-block="checkbox-010"
        className={className}
        style={palette}
      >
        <legend>{legend}</legend>
        {addons.map((addon) => (
          <label data-part="card" key={addon.id}>
            <input
              type="checkbox"
              checked={value.includes(addon.id)}
              onChange={() => toggle(addon.id)}
            />
            <span data-part="head">
              <span data-part="tick" aria-hidden="true" />
              {addon.title}
              {addon.recommended ? (
                <span data-part="flag">советуем</span>
              ) : null}
            </span>
            <span data-part="price">
              {addon.price} {currency}
            </span>
            <span data-part="note">{addon.note}</span>
          </label>
        ))}
        <p data-part="total" role="status">
          <span>Дополнения: {value.length}</span>
          <span data-part="sum">
            {total} {currency}
          </span>
        </p>
      </fieldset>
    </>
  )
}