Button
A button component that can be rendered as another tag or focusable when disabled.
Measured from the medium default, secondary and tertiary Buttons and their hovers on vercel.com/geist/button, light and dark. The tiny size padding and the dark error and warning hovers are guesses.
import { Button } from "@replicas/ui";
export default function ButtonDemo() {
return (
<>
<Button variant="primary">Save changes</Button>
<Button>Share</Button>
<Button variant="ghost">Cancel</Button>
<Button size="small">Edit</Button>
<Button disabled>Disabled</Button>
</>
);
}Examples
Variants
<Button variant="default">Default</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="tertiary">Tertiary</Button>
<Button variant="error">Error</Button>
<Button variant="warning">Warning</Button>Sizes
<Button size="tiny">Tiny</Button>
<Button size="small">Small</Button>
<Button size="medium">Medium</Button>
<Button size="large">Large</Button>With Icon
function WithIcon() {
return (
<Button variant="primary">
{plus}
New file
</Button>
);
}Icon Only
function IconOnly() {
return (
<Tooltip content="New file">
<Button iconOnly aria-label="New file">
{plus}
</Button>
</Tooltip>
);
}Loading State
function LoadingState() {
return <Button loading>Saving</Button>;
}Disabled State
function DisabledState() {
return <Button disabled>Archive</Button>;
}Link As Button
function LinkAsButton() {
return <Button nativeButton={false} render={<a href="#" />}>Open docs</Button>;
}Prompt
Copy Prompt hands your agent everything it needs to build the Button in the Geist style: the measured tokens, the CSS and the structure.
Show Prompt
# Geist Button
A button component that can be rendered as another tag or focusable when disabled.
Build a Button 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/button) if it has none.
Fidelity: Measured from the medium default, secondary and tertiary Buttons and their hovers on vercel.com/geist/button, light and dark. The tiny size padding and the dark error and warning hovers are guesses.
## Variants
- `variant`: `default`, `secondary`, `tertiary`, `error`, `warning`
- `size`: `tiny`, `small`, `medium`, `large`
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--ds-gray-100` | `hsl(0 0% 95%)` | `hsl(0 0% 10%)` |
| `--ds-gray-400` | `hsl(0 0% 92%)` | `hsl(0 0% 18%)` |
| `--ds-gray-700` | `hsl(0 0% 56%)` | `hsl(0 0% 56%)` |
| `--ds-red-800` | `oklch(58.19% 0.2482 25.15)` | `oklch(58.01% 0.227 25.12)` |
| `--ds-amber-800` | `oklch(77.21% 0.1991 64.28)` | `oklch(77.21% 0.1991 64.28)` |
| `--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)` |
| `--default-transition-duration` | `0.15s` | `0.15s` |
| `--duration-spinner` | `1s` | `1s` |
| `--accent` | `hsl(0 0% 9%)` | `hsl(0 0% 93%)` |
| `--accent-hover` | `hsl(0 0% 22%)` | `hsl(0 0% 80%)` |
| `--accent-text` | `hsl(0 0% 100%)` | `hsl(0 0% 4%)` |
| `--chip-bg` | `hsl(0 0% 100%)` | `hsl(0 0% 4%)` |
| `--chip-bg-hover` | `hsl(0 0% 95%)` | `hsl(0 0% 12%)` |
| `--chip-text` | `hsl(0 0% 9%)` | `hsl(0 0% 93%)` |
| `--chip-ring` | `hsl(0 0% 92%)` | `hsl(0 0% 18%)` |
| `--ghost-text` | `hsl(0 0% 9%)` | `hsl(0 0% 93%)` |
| `--ghost-bg-hover` | `#00000014` | `#ffffff17` |
| `--font-size-micro` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.875rem` | `0.875rem` |
| `--font-size-regular` | `1rem` | `1rem` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-control` | `6px` | `6px` |
## 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-button {
box-sizing: border-box;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
margin: 0;
border: none;
border-radius: var(--radius-control);
font-family: inherit;
font-size: var(--font-size-small);
font-weight: var(--font-weight-medium);
font-feature-settings: inherit;
line-height: 21px;
white-space: nowrap;
user-select: none;
cursor: pointer;
transition: all var(--default-transition-duration) var(--ease-in-out);
&:focus-visible {
outline: none;
box-shadow: var(--ds-focus-ring);
transition: none;
}
& svg {
width: 16px;
height: 16px;
flex-shrink: 0;
}
}
.ui-button[data-size="tiny"] {
height: 24px;
min-width: 24px;
padding: 0 6px;
border-radius: 4px;
font-size: var(--font-size-micro);
line-height: 16px;
}
.ui-button[data-size="small"] {
height: 32px;
min-width: 32px;
padding: 0 12px;
}
.ui-button[data-size="medium"] {
height: 36px;
min-width: 36px;
padding: 0 16px;
}
.ui-button[data-size="large"] {
height: 40px;
min-width: 40px;
padding: 0 20px;
border-radius: 8px;
font-size: var(--font-size-regular);
line-height: 24px;
}
.ui-button[data-icon-only] {
padding: 0;
}
.ui-button:is([data-variant="default"], [data-variant="primary"]) {
background-color: var(--accent);
color: var(--accent-text);
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--accent-hover);
}
}
}
.ui-button[data-variant="secondary"] {
background-color: var(--chip-bg);
color: var(--chip-text);
box-shadow: 0 0 0 1px var(--chip-ring);
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--chip-bg-hover);
}
}
&:focus-visible {
box-shadow:
0 0 0 1px var(--chip-ring),
var(--ds-focus-ring);
}
}
.ui-button:is([data-variant="tertiary"], [data-variant="ghost"]) {
background-color: transparent;
color: var(--ghost-text);
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--ghost-bg-hover);
}
}
}
.ui-button[data-variant="error"] {
background-color: var(--ds-red-800);
color: #f5f5f5;
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: #ae292f;
}
}
}
.ui-button[data-variant="warning"] {
background-color: var(--ds-amber-800);
color: #0a0a0a;
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: #d27504;
}
}
}
.ui-button[data-disabled] {
background-color: var(--ds-gray-100);
color: var(--ds-gray-700);
box-shadow: 0 0 0 1px var(--ds-gray-400);
cursor: not-allowed;
}
.ui-button[data-loading] {
cursor: wait;
}
.ui-button-spinner {
display: inline-block;
flex-shrink: 0;
width: 16px;
height: 16px;
margin-right: 3px;
background-color: currentColor;
mask: var(--geist-spinner-mask) center / 100% 100% no-repeat;
animation: geist-spinner-spin var(--duration-spinner) steps(10) infinite;
}
.ui-button:is([data-size="tiny"], [data-size="small"]) .ui-button-spinner {
width: 12px;
height: 12px;
}
.ui-button[data-size="large"] .ui-button-spinner {
width: 20px;
height: 20px;
}
}
```
## Structure
How Replicas assembles it on Base UI.
```tsx
import { Button as BaseButton } from "@base-ui/react/button";
import { join } from "./utils";
export type ButtonProps = Omit<BaseButton.Props, "className"> & {
className?: string;
variant?: string;
size?: string;
iconOnly?: boolean;
loading?: boolean;
};
export function Button({
className,
variant = "secondary",
size = "medium",
iconOnly = false,
loading = false,
disabled,
children,
...props
}: ButtonProps) {
return (
<BaseButton
className={join("ui-button", className)}
data-variant={variant}
data-size={size}
data-icon-only={iconOnly || undefined}
data-loading={loading || undefined}
aria-busy={loading || undefined}
disabled={disabled || loading}
focusableWhenDisabled={loading}
{...props}
>
{loading ? <span className="ui-button-spinner" aria-hidden /> : null}
{children}
</BaseButton>
);
}
```
## Example
```tsx
import { Button } from "@replicas/ui";
export default function ButtonDemo() {
return (
<>
<Button variant="primary">Save changes</Button>
<Button>Share</Button>
<Button variant="ghost">Cancel</Button>
<Button size="small">Edit</Button>
<Button disabled>Disabled</Button>
</>
);
}
```
## Foundations
The rest of the Geist style, as a skill: https://replicas.raphaelsalaja.com/skills/geist/SKILL.md