Checkbox
An easily stylable checkbox component.
Partly measured from Geist's Checkbox, light and dark. No reference has been captured yet.
import { Checkbox } from "@replicas/ui";
const label = { display: "flex", alignItems: "center", gap: 8, color: "var(--text-secondary)" };
export default function CheckboxDemo() {
return (
<div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
<label style={label}>
<Checkbox defaultChecked />
Show hidden files
</label>
<label style={label}>
<Checkbox />
Show file extensions
</label>
<label style={label}>
<Checkbox disabled />
Show system files
</label>
</div>
);
}Prompt
Copy Prompt hands your agent everything it needs to build the Checkbox in the Geist style: the measured tokens, the CSS and the structure.
Show Prompt
# Geist Checkbox
An easily stylable checkbox component.
Build a Checkbox in this project that looks and behaves like Geist's. Measured from the running Geist app (vercel.com/geist). Keep every value exact. Map the tokens onto the project's own theme variables instead of hard-coding them. Use the project's own component library for behaviour, or [Base UI](https://base-ui.com/react/components/checkbox) if it has none.
Fidelity: Partly measured from Geist's Checkbox, light and dark. No reference has been captured yet.
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--ds-background-100` | `hsl(0 0% 100%)` | `hsl(0 0% 4%)` |
| `--ds-gray-100` | `hsl(0 0% 95%)` | `hsl(0 0% 10%)` |
| `--ds-gray-200` | `hsl(0 0% 92%)` | `hsl(0 0% 12%)` |
| `--ds-gray-500` | `hsl(0 0% 79%)` | `hsl(0 0% 27%)` |
| `--ds-gray-600` | `hsl(0 0% 66%)` | `hsl(0 0% 53%)` |
| `--ds-gray-700` | `hsl(0 0% 56%)` | `hsl(0 0% 56%)` |
| `--ds-gray-1000` | `hsl(0 0% 9%)` | `hsl(0 0% 93%)` |
| `--ds-focus-ring` | `0 0 0 2px var(--ds-background-100), 0 0 0 4px var(--ds-focus-color)` | `0 0 0 2px var(--ds-background-100), 0 0 0 4px var(--ds-focus-color)` |
| `--ease-in-out` | `cubic-bezier(0.4, 0, 0.2, 1)` | `cubic-bezier(0.4, 0, 0.2, 1)` |
| `--duration-normal` | `0.2s` | `0.2s` |
| `--radius-kbd` | `4px` | `4px` |
## CSS
Scoped under `[data-style="geist"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="geist"] {
.ui-checkbox {
box-sizing: border-box;
display: inline-flex;
flex-shrink: 0;
align-items: center;
justify-content: center;
width: 16px;
height: 16px;
padding: 0;
border: none;
border-radius: var(--radius-kbd);
background-color: var(--ds-background-100);
box-shadow: inset 0 0 0 1px var(--ds-gray-700);
color: var(--ds-background-100);
cursor: pointer;
transition:
background-color var(--duration-normal) var(--ease-in-out),
box-shadow var(--duration-normal) var(--ease-in-out),
color var(--duration-normal) var(--ease-in-out);
@media (hover: hover) {
&:hover:not([data-disabled], [data-checked], [data-indeterminate]) {
background-color: var(--ds-gray-200);
}
}
&:focus-visible {
outline: none;
box-shadow:
inset 0 0 0 1px var(--ds-gray-700),
var(--ds-focus-ring);
}
&[data-checked] {
background-color: var(--ds-gray-1000);
box-shadow: inset 0 0 0 1px var(--ds-gray-1000);
&:focus-visible {
box-shadow:
inset 0 0 0 1px var(--ds-gray-1000),
var(--ds-focus-ring);
}
}
&[data-indeterminate] {
color: var(--ds-gray-700);
}
&[data-disabled] {
background-color: var(--ds-gray-100);
box-shadow: inset 0 0 0 1px var(--ds-gray-500);
cursor: not-allowed;
&[data-indeterminate] {
color: var(--ds-gray-500);
}
&[data-checked] {
background-color: var(--ds-gray-600);
box-shadow: inset 0 0 0 1px var(--ds-gray-600);
}
}
}
.ui-checkbox-indicator {
display: flex;
& svg {
width: 10.7px;
height: 10.7px;
}
&[data-indeterminate] svg {
width: 16px;
height: 16px;
stroke-width: 1;
}
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { Checkbox as BaseCheckbox } from "@base-ui/react/checkbox";
export function Checkbox({ className, ...props }: Omit<BaseCheckbox.Root.Props, "className"> & { className?: string }) {
return (
<BaseCheckbox.Root className={className ? `${"ui-checkbox"} ${className}` : "ui-checkbox"} {...props}>
<BaseCheckbox.Indicator
className="ui-checkbox-indicator"
render={(indicatorProps, state) => (
<span {...indicatorProps}>
{state.indeterminate ? (
<svg viewBox="0 0 10 10" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round">
<path d="M2.5 5h5" />
</svg>
) : (
<svg
viewBox="0 0 10 10"
fill="none"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
>
<path d="m2 5.25 2 2 4-4.5" />
</svg>
)}
</span>
)}
/>
</BaseCheckbox.Root>
);
}
```
## Example
```tsx
import { Checkbox } from "@replicas/ui";
const label = { display: "flex", alignItems: "center", gap: 8, color: "var(--text-secondary)" };
export default function CheckboxDemo() {
return (
<div style={{ display: "flex", flexDirection: "column", gap: 10 }}>
<label style={label}>
<Checkbox defaultChecked />
Show hidden files
</label>
<label style={label}>
<Checkbox />
Show file extensions
</label>
<label style={label}>
<Checkbox disabled />
Show system files
</label>
</div>
);
}
```
## Foundations
The rest of the Geist style, as a skill: https://replicas.raphaelsalaja.com/skills/geist/SKILL.md