Checkbox

Shape Checkboxes

Checkboxes whose tick is a shape that matches the mark: a star, a flag and a bolt cut out with clip-path.

  • checkbox
  • icons
  • clip-path
  • toggle

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

Card marks

Отметок: 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-018" (Shape 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-018.json

Registry item: https://vibeui.ru/r/checkbox-018.json
Installs to: components/vibeui/checkbox-018.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
Checkboxes whose tick is a shape that matches the mark: a star, a flag and a bolt cut out with clip-path.

A row of checkboxes with shapes instead of ticks: a star, a flag and a bolt cut from a filled square with clip-path. A checked shape fills with the accent and grows slightly; an unchecked one stays visible in grey. Zero dependencies, one file.

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

<Checkbox018
  legend="Card marks"
  options={marks}
  defaultValue={["favorite"]}
  onChange={setMarks}
/>

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-018-* palette — do not swap it for your theme tokens
- the shapes made with clip-path: they need no icon library and take their colour from the palette
- the hidden but real input — Tab, space and the state announcement rest on it
- the muted but visible shape when unchecked: an empty box does not hint at what appears
- the caption under the shape — an icon alone is read differently by everyone
- the focus ring on the whole card via :has(input:focus-visible): the input itself is invisible

## 6. You may change
- the options array: a caption and a shape (star, flag, bolt) per mark
- legend — the group's name
- the initial defaultValue and the onChange handler
- the accent through the accent prop — the checked shape and ring colour

## 7. Rules
- There are exactly three shapes: a new one means another polygon in the CSS, markup cannot invent it.
- An icon does not replace the caption: a star means both "favourite" and "rating".
- For a long list of marks the shape stops helping — use a plain list there.
- 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-018.json
https://vibeui.ru/r/checkbox-018.json

Компонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-checkbox-018-*. Клиентский: "use client". Настоящий input спрятан визуально (clip-path: inset(50%)), карточка реагирует через :has(input:checked). Иконки — квадраты с фоном, обрезанные clip-path: polygon по атрибуту data-shape, поэтому иконочная библиотека не нужна и цвет наследуется из палитры. Невыбранная фигура показана приглушённой, а не пустой рамкой.

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 Checkbox018Shape = "star" | "flag" | "bolt"

export type Checkbox018Option = {
  id: string
  label: string
  shape: Checkbox018Shape
}

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

// Идея компонента: вместо галочки — фигура по смыслу отметки. Звезда,
// флажок и молния вырезаны из залитого квадрата через clip-path, поэтому
// иконочная библиотека не нужна. Невыбранное состояние показывает ту же
// фигуру приглушённой: пустая рамка не подсказала бы, что будет после клика.
const STYLES = `
:where([data-vibeui-block="checkbox-018"]){
--vibeui-checkbox-018-bg:oklch(1 0 0);
--vibeui-checkbox-018-fg:oklch(0.22 0.014 265);
--vibeui-checkbox-018-muted:oklch(0.58 0.014 265);
--vibeui-checkbox-018-border:oklch(0.9 0.006 265);
--vibeui-checkbox-018-idle:oklch(0.87 0.008 265);
--vibeui-checkbox-018-surface:oklch(0.975 0.003 265);
--vibeui-checkbox-018-accent:oklch(0.64 0.16 65);
--vibeui-checkbox-018-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="checkbox-018"]{
display:flex;flex-wrap:wrap;gap:0.5rem;
width:100%;max-width:22rem;box-sizing:border-box;
margin:0;padding:0.875rem;border:1px solid var(--vibeui-checkbox-018-border);border-radius:0.875rem;
background:var(--vibeui-checkbox-018-bg);
font-family:var(--vibeui-checkbox-018-font);color:var(--vibeui-checkbox-018-fg);
}
[data-vibeui-block="checkbox-018"] legend{float:left;width:100%;padding:0 0 0.5rem;font-size:0.8125rem;font-weight:650}
[data-vibeui-block="checkbox-018"] label{
clear:both;flex:1 1 5.5rem;
display:flex;flex-direction:column;align-items:center;gap:0.375rem;
padding:0.625rem 0.5rem;border-radius:0.75rem;cursor:pointer;
background:var(--vibeui-checkbox-018-surface);
box-shadow:inset 0 0 0 1px var(--vibeui-checkbox-018-border);
font-size:0.75rem;text-align:center;
transition:background-color .15s ease,box-shadow .15s ease;
}
[data-vibeui-block="checkbox-018"] label:has(input:checked){
box-shadow:inset 0 0 0 1.5px var(--vibeui-checkbox-018-accent);
background:var(--vibeui-checkbox-018-bg);
}
[data-vibeui-block="checkbox-018"] label:has(input:focus-visible){
outline:2px solid var(--vibeui-checkbox-018-accent);outline-offset:2px;
}
[data-vibeui-block="checkbox-018"] 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-018"] [data-part="icon"]{
display:block;width:1.5rem;height:1.5rem;
background:var(--vibeui-checkbox-018-idle);
transition:background-color .15s ease,transform .15s ease;
}
[data-vibeui-block="checkbox-018"] label:has(input:checked) [data-part="icon"]{
background:var(--vibeui-checkbox-018-accent);transform:scale(1.08);
}
[data-vibeui-block="checkbox-018"] [data-shape="star"]{
clip-path:polygon(50% 2%,62% 36%,98% 36%,69% 58%,80% 94%,50% 72%,20% 94%,31% 58%,2% 36%,38% 36%);
}
[data-vibeui-block="checkbox-018"] [data-shape="flag"]{
clip-path:polygon(12% 2%,88% 2%,88% 98%,50% 72%,12% 98%);
}
[data-vibeui-block="checkbox-018"] [data-shape="bolt"]{
clip-path:polygon(58% 2%,20% 54%,45% 54%,38% 98%,80% 42%,52% 42%);
}
[data-vibeui-block="checkbox-018"] [data-part="name"]{line-height:1.3}
[data-vibeui-block="checkbox-018"] label:has(input:checked) [data-part="name"]{font-weight:650}
[data-vibeui-block="checkbox-018"] [data-part="foot"]{
flex:1 1 100%;margin:0.125rem 0 0;font-size:0.75rem;color:var(--vibeui-checkbox-018-muted);
}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="checkbox-018"] *{animation:none!important;transition:none!important}}
`

const DEFAULT_OPTIONS: Checkbox018Option[] = [
  { id: "favorite", label: "В избранное", shape: "star" },
  { id: "report", label: "Пометить", shape: "flag" },
  { id: "priority", label: "Срочно", shape: "bolt" },
]

/**
 * Чекбоксы с фигурой вместо галочки: звезда, флажок и молния вырезаны
 * через clip-path. Один файл, ноль зависимостей, собственная палитра.
 */
export function Checkbox018({
  legend = "Отметки для карточки",
  options = DEFAULT_OPTIONS,
  defaultValue = ["favorite"],
  onChange,
  accent,
  className,
  style,
  ...props
}: Checkbox018Props) {
  const [value, setValue] = useState<string[]>(defaultValue)

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

  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-018" precedence="medium">
        {STYLES}
      </style>
      <fieldset
        {...props}
        data-vibeui-block="checkbox-018"
        className={className}
        style={palette}
      >
        <legend>{legend}</legend>
        {options.map((option) => (
          <label key={option.id}>
            <input
              type="checkbox"
              checked={value.includes(option.id)}
              onChange={() => toggle(option.id)}
            />
            <span
              data-part="icon"
              data-shape={option.shape}
              aria-hidden="true"
            />
            <span data-part="name">{option.label}</span>
          </label>
        ))}
        <p data-part="foot" role="status">
          {value.length === 0
            ? "Отметок нет"
            : `Отметок: ${value.length} из ${options.length}`}
        </p>
      </fieldset>
    </>
  )
}