Checkbox
Draft Settings
Settings with a description under every label: changed rows get a dot, and the draft is applied with a Save button.
- checkbox
- settings
- draft
- form
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/checkbox-009?lang=en
Notifications
Всё сохранено
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-009" (Draft Settings) 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-009.json
Registry item: https://vibeui.ru/r/checkbox-009.json
Installs to: components/vibeui/checkbox-009.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
Settings with a description under every label: changed rows get a dot, and the draft is applied with a Save button.
A settings panel: every checkbox carries a label, a description and an optional badge. Changes are not applied silently — they collect as a draft, get marked with a dot and go through the Save button. Zero dependencies, one file, its own palette.
## 3. How to use it
import { Checkbox009 } from "@/components/vibeui/checkbox-009"
<Checkbox009
title="Notifications"
options={options}
defaultValue={["digest"]}
onChange={setValue}
/>
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-009-* palette — do not swap it for your theme tokens (bg-primary, border-input and the like)
- the two value sets — saved and draft: without them the Save button has nothing to act on
- the dot on a changed row: it answers "what exactly did I change"
- the description under the label rather than in a hover tooltip — phones have no hover
- the button disabled when nothing changed: an active button with no work to do lies
- role="status" on the unsaved counter — the number of changes has to be announced
## 6. You may change
- the options array: label, description and badge for every row
- title — the panel heading
- the initial defaultValue and the onChange handler
- the accent through the accent prop — it colours the tick, the dot and the button
## 7. Rules
- The component sends nothing: Save merely accepts the draft as the new baseline.
- For settings that apply instantly a draft is overhead — checkbox-001 fits better there.
- A badge is not a description: "beta" on its own explains 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-009.jsonhttps://vibeui.ru/r/checkbox-009.jsonКомпонент самодостаточен: один файл, без зависимостей, собственная палитра в локальных переменных --vibeui-checkbox-009-*. Клиентский: "use client". Держит два набора значений — сохранённый и черновик; их разница даёт точку у изменённой строки и число несохранённого в подвале. Строка — grid из квадрата, подписи с бейджем и пояснения; квадрат занимает обе строки сетки через grid-row: 1 / span 2. Счётчик несохранённого объявлен role="status".
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 Checkbox009Option = {
id: string
label: string
description: string
badge?: string
}
export type Checkbox009Props = Omit<
ComponentPropsWithoutRef<"section">,
"children" | "onChange" | "title"
> & {
title?: string
options?: Checkbox009Option[]
defaultValue?: string[]
onChange?: (value: string[]) => void
accent?: string
}
// Идея компонента: панель настроек, где под каждой подписью живёт пояснение,
// а изменённые с момента сохранения строки помечаются точкой. Черновик виден
// до нажатия «Сохранить»: настройки, применяющиеся молча, невозможно отменить.
const STYLES = `
:where([data-vibeui-block="checkbox-009"]){
--vibeui-checkbox-009-bg:oklch(1 0 0);
--vibeui-checkbox-009-fg:oklch(0.22 0.014 265);
--vibeui-checkbox-009-muted:oklch(0.55 0.014 265);
--vibeui-checkbox-009-border:oklch(0.9 0.006 265);
--vibeui-checkbox-009-hover:oklch(0.975 0.003 265);
--vibeui-checkbox-009-accent:oklch(0.56 0.16 265);
--vibeui-checkbox-009-badge:oklch(0.95 0.03 265);
--vibeui-checkbox-009-font:ui-sans-serif,system-ui,-apple-system,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif;
}
[data-vibeui-block="checkbox-009"]{
display:block;width:100%;max-width:26rem;box-sizing:border-box;
padding:1rem;border:1px solid var(--vibeui-checkbox-009-border);border-radius:1rem;
background:var(--vibeui-checkbox-009-bg);
font-family:var(--vibeui-checkbox-009-font);color:var(--vibeui-checkbox-009-fg);
}
[data-vibeui-block="checkbox-009"] [data-part="title"]{
margin:0 0 0.5rem;font-size:0.9375rem;font-weight:650;letter-spacing:-0.01em;
}
[data-vibeui-block="checkbox-009"] [data-part="list"]{
display:flex;flex-direction:column;margin:0;padding:0;list-style:none;
}
[data-vibeui-block="checkbox-009"] [data-part="row"]+[data-part="row"]{
border-top:1px solid var(--vibeui-checkbox-009-border);
}
[data-vibeui-block="checkbox-009"] label{
display:grid;grid-template-columns:auto 1fr;column-gap:0.625rem;row-gap:0.125rem;
padding:0.625rem 0.5rem;margin:0 -0.5rem;border-radius:0.625rem;cursor:pointer;
transition:background-color .15s ease;
}
[data-vibeui-block="checkbox-009"] label:hover{background:var(--vibeui-checkbox-009-hover)}
[data-vibeui-block="checkbox-009"] input{
appearance:none;position:relative;flex:none;grid-row:1 / span 2;align-self:start;
width:1.0625rem;height:1.0625rem;margin:0.0625rem 0 0;box-sizing:border-box;cursor:inherit;
border:1.5px solid var(--vibeui-checkbox-009-border);border-radius:0.3125rem;
background:var(--vibeui-checkbox-009-bg);
transition:background-color .15s ease,border-color .15s ease;
}
[data-vibeui-block="checkbox-009"] input:checked{border-color:transparent;background:var(--vibeui-checkbox-009-accent)}
[data-vibeui-block="checkbox-009"] input:checked::after{
content:"";position:absolute;left:50%;top:50%;
width:0.25rem;height:0.4375rem;margin:-0.3125rem 0 0 -0.125rem;
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-009"] input:focus-visible{outline:2px solid var(--vibeui-checkbox-009-accent);outline-offset:2px}
[data-vibeui-block="checkbox-009"] [data-part="name"]{
display:flex;align-items:center;gap:0.375rem;font-size:0.875rem;font-weight:550;line-height:1.3;
}
[data-vibeui-block="checkbox-009"] [data-part="badge"]{
padding:0.0625rem 0.375rem;border-radius:9999px;
background:var(--vibeui-checkbox-009-badge);color:var(--vibeui-checkbox-009-accent);
font-size:0.625rem;font-weight:700;text-transform:uppercase;letter-spacing:0.04em;
}
/* Точка изменения: она отличает черновик от сохранённого, и без неё кнопка
«Сохранить» непонятно к чему относится. */
[data-vibeui-block="checkbox-009"] [data-part="dot"]{
width:0.375rem;height:0.375rem;border-radius:9999px;
background:var(--vibeui-checkbox-009-accent);
}
[data-vibeui-block="checkbox-009"] [data-part="hint"]{
font-size:0.75rem;line-height:1.45;color:var(--vibeui-checkbox-009-muted);
}
[data-vibeui-block="checkbox-009"] [data-part="foot"]{
display:flex;align-items:center;justify-content:space-between;gap:0.75rem;
margin-top:0.75rem;padding-top:0.75rem;
border-top:1px solid var(--vibeui-checkbox-009-border);
font-size:0.75rem;color:var(--vibeui-checkbox-009-muted);
}
[data-vibeui-block="checkbox-009"] button{
appearance:none;cursor:pointer;border:0;border-radius:0.5rem;
padding:0.375rem 0.75rem;font:inherit;font-size:0.75rem;font-weight:650;
background:var(--vibeui-checkbox-009-accent);color:oklch(0.99 0.01 265);
transition:opacity .15s ease;
}
[data-vibeui-block="checkbox-009"] button:disabled{cursor:not-allowed;opacity:.45}
[data-vibeui-block="checkbox-009"] button:focus-visible{outline:2px solid var(--vibeui-checkbox-009-accent);outline-offset:2px}
@media (prefers-reduced-motion:reduce){[data-vibeui-block="checkbox-009"] *{animation:none!important;transition:none!important}}
`
const DEFAULT_OPTIONS: Checkbox009Option[] = [
{
id: "digest",
label: "Недельная сводка",
description: "Письмо по понедельникам: что изменилось в проекте.",
},
{
id: "mentions",
label: "Упоминания",
description: "Уведомление, когда вас назвали в комментарии.",
badge: "new",
},
{
id: "deploys",
label: "Отчёты о выкладке",
description: "Каждая выкладка на прод с итогом и временем.",
},
]
/**
* Настройки с пояснениями: изменённые строки помечаются точкой,
* а черновик применяется кнопкой. Один файл, ноль зависимостей.
*/
export function Checkbox009({
title = "Уведомления",
options = DEFAULT_OPTIONS,
defaultValue = ["digest"],
onChange,
accent,
className,
style,
...props
}: Checkbox009Props) {
const [saved, setSaved] = useState<string[]>(defaultValue)
const [draft, setDraft] = useState<string[]>(defaultValue)
const palette = {
...(accent ? { "--vibeui-checkbox-009-accent": accent } : null),
...style,
} as CSSProperties
const changed = options.filter(
(option) => draft.includes(option.id) !== saved.includes(option.id),
)
const toggle = (id: string) => {
const next = draft.includes(id)
? draft.filter((item) => item !== id)
: [...draft, id]
setDraft(next)
onChange?.(next)
}
return (
<>
<style href="vibeui-checkbox-009" precedence="medium">
{STYLES}
</style>
<section
{...props}
data-vibeui-block="checkbox-009"
className={className}
style={palette}
>
<h3 data-part="title">{title}</h3>
<ul data-part="list">
{options.map((option) => {
const isChanged =
draft.includes(option.id) !== saved.includes(option.id)
return (
<li data-part="row" key={option.id}>
<label>
<input
type="checkbox"
checked={draft.includes(option.id)}
onChange={() => toggle(option.id)}
/>
<span data-part="name">
{option.label}
{option.badge ? (
<span data-part="badge">{option.badge}</span>
) : null}
{isChanged ? (
<span data-part="dot" aria-hidden="true" />
) : null}
</span>
<span data-part="hint">{option.description}</span>
</label>
</li>
)
})}
</ul>
<p data-part="foot">
<span role="status">
{changed.length === 0
? "Всё сохранено"
: `Не сохранено: ${changed.length}`}
</span>
<button
type="button"
disabled={changed.length === 0}
onClick={() => setSaved(draft)}
>
Сохранить
</button>
</p>
</section>
</>
)
}