Database governance built for humans and agents — controlling changes and access across every major database.
React Checkbox Component — Design
Date: 2026-05-06
Scope: Add a unified Checkbox UI primitive at frontend/src/react/components/ui/checkbox.tsx and migrate the components that currently manipulate indeterminate imperatively.
Background
The React side of frontend/ has 123 <input type="checkbox"> usages across ~50 files. Pain points:
- Inconsistent styling. Some use
accent-accent, some usesize-3.5, most use no class at all and inherit native browser rendering. - Imperative
indeterminate. ~14 places setindeterminateviarefcallback —ref={(el) => { if (el) el.indeterminate = ... }}. There is no declarative way to express tri-state in the current code. - No checkbox in
ui/. Other interactive primitives (Switch,RadioGroup,SegmentedControl,Tabs,Select,Tooltip) all live undercomponents/ui/as Base UI wrappers. Checkbox is the missing peer.
The Vue side uses NCheckbox from naive-ui. With the Vue→React migration ongoing, new React code needs a parallel primitive.
Non-goals
- Not migrating all 123 usages. The ~40 form-only "boolean toggle" usages (sql-editor panels, DataSourceForm, InstanceFormBody, IDPDetailPage, etc.) are out of scope here — they migrate organically.
- Not adding a label / description slot. Form labels in this codebase have too much variation (description text, tooltip, hover-row highlighting) to fit a single API.
- Not adding a lint rule banning
<input type="checkbox">— the remaining ~40 form usages are legitimate.
Component API
File: frontend/src/react/components/ui/checkbox.tsx
type CheckboxSize = "sm" | "md"; // sm = 14px, md = 16px (default)
interface CheckboxProps {
checked: boolean | "indeterminate";
onCheckedChange?: (checked: boolean) => void;
disabled?: boolean;
size?: CheckboxSize; // default "md"
className?: string;
id?: string;
name?: string; // optional, for form integration
"aria-label"?: string;
}
Design notes:
checked: boolean | "indeterminate"rather than separateindeterminateprop. A checkbox cannot be simultaneouslycheckedandindeterminate; the union type forbids the invalid state. This matches Base UI'sCheckbox.Rootand shadcn's official Checkbox.onCheckedChangealways emitsboolean. Base UI's behavior: clicking an indeterminate checkbox transitions totrue(does not return to indeterminate). All 13 existing call sites that usee.target.checkedare equivalent.- No
forwardRef. Callers needing a label wrap the component in<label>themselves — matches theSwitchprecedent and keeps the API minimal.
Visual
Built on @base-ui/react/checkbox. Visual language matches the existing Switch:
Root (the box)
| State | Classes |
|---|---|
Size: md |
size-4 |
Size: sm |
size-3.5 |
| Default | rounded-sm border border-control-border bg-background |
| Checked / indeterminate | bg-accent border-accent |
| Hover (unchecked) | border-accent/60 |
| Focus | focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 |
| Disabled | disabled:opacity-50 disabled:cursor-not-allowed |
| Transition | transition-colors |
Indicator (rendered inside Checkbox.Indicator)
| State | Icon (lucide-react) | Class |
|---|---|---|
checked |
<Check /> |
size-3 text-background (md) / size-2.5 text-background (sm) |
indeterminate |
<Minus /> |
same as above |
text-background is correct because the checked-state fill is bg-accent (dark) — the indicator needs the inverse for contrast.
No manual dark: overrides — bg-background, bg-accent, border-control-border are semantic tokens that handle theming.
Migration scope (this PR)
13 files containing imperative indeterminate manipulation:
components/IssueTable.tsxcomponents/DatabaseResourceSelector.tsxcomponents/ExprEditor.tsxcomponents/database/DatabaseTableView.tsxcomponents/sql-review/RuleTable.tsxcomponents/SchemaEditorLite/Aside/NodeCheckbox.tsxpages/settings/InstancesPage.tsxpages/project/ProjectPlanDashboardPage.tsxpages/project/database-detail/revision/DatabaseRevisionTable.tsxpages/project/database-detail/catalog/SensitiveColumnTable.tsxpages/project/export-center/DataExportPrepSheet.tsxpages/project/plan-detail/components/PlanDetailChangesBranch.tsxpages/project/plan-detail/components/deploy/DeployTaskToolbar.tsx
Plus 3 files with paired row-level checkboxes (so the visual stays consistent within the same surface):
components/ProjectTable.tsxcomponents/release/ReleaseFileTable.tsxpages/settings/MembersPage.tsx
Done state: every if (el) el.indeterminate = ... ref callback in React is gone; all imperative call sites are declarative checked={state.indeterminate ? "indeterminate" : state.checked}.
Explicitly out of scope
The ~40 form-only <input type="checkbox"> usages migrate organically:
components/IAMRemindDialog.tsxcomponents/IssueLabelSelect.tsxcomponents/InstanceAssignmentSheet.tsxcomponents/sql-editor/**(SheetTree, AccessGrantRequestDrawer, ConnectionPane, CodeViewer, IndexesTable, ColumnsTable, SequencesTable, ViewDetail)components/sql-review/Panels.tsxcomponents/sql-review/RuleComponents.tsxcomponents/instance/DataSourceForm.tsxcomponents/instance/InstanceFormBody.tsxcomponents/SchemaEditorLite/Panels/**(TableColumnEditor, IndexesEditor)pages/settings/IDPDetailPage.tsx
Testing
New tests
frontend/src/react/components/ui/checkbox.test.tsx:
- Renders unchecked, checked, indeterminate
- Click triggers
onCheckedChange(boolean):- unchecked →
true - checked →
false - indeterminate →
true
- unchecked →
disabledblocksonCheckedChangesize="sm"/size="md"render the expected dimension class- Keyboard
Spacetoggles
Regression risk in existing tests
Base UI's Checkbox.Root renders <button role="checkbox"> by default. It emits an additional hidden <input type="checkbox"> only when name is set or it's inside a <form>. This changes selector behavior in:
release/ReleaseFileTable.test.tsx— usescontainer.querySelectorAll('input[type="checkbox"]').length. After migration this counts 0 unless rows passname. Action: during ReleaseFileTable migration, change the selector togetAllByRole('checkbox')in the same commit.- Audit
sql-editor/SheetTree.test.tsxandpages/project/database-detail/panels/DatabaseCatalogPanel.test.tsxfor the same pattern; update if found.
Validation gates
pnpm --dir frontend fixpnpm --dir frontend checkpnpm --dir frontend type-checkpnpm --dir frontend test
Open questions
None blocking. The Base UI selector change is the only known regression risk and has a mechanical fix.