Button
A button component that can be rendered as another tag or focusable when disabled.
Measured from the topbar Share button, the Share popover's Invite and Copy link buttons, a page icon button and Settings > Profile's Delete my account. Accent is derived from the blue tinted tokens.
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="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="accent">Accent</Button>
<Button variant="danger">Danger</Button>Sizes
<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 Notion style: the measured tokens, the CSS and the structure.
Show Prompt
# Notion 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 Notion's. Measured from the running Notion app (notion.com). 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 topbar Share button, the Share popover's Invite and Copy link buttons, a page icon button and Settings > Profile's Delete my account. Accent is derived from the blue tinted tokens.
## Variants
- `variant`: `primary`, `secondary`, `ghost`, `accent`, `danger`
- `size`: `small`, `medium`, `large`
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--c-texPri` | `#2c2c2b` | `#f0efed` |
| `--ca-borPriTra` | `#1c13011c` | `#ffffeb1a` |
| `--ca-borSecTra` | `#2a1c0012` | `#fffff315` |
| `--ca-bacIntTra` | `#211b170d` | `#ffffff0e` |
| `--ca-bacIntPre` | `#211b171a` | `#ffffff1c` |
| `--c-bluBacAccPri` | `#2783de` | `#2783de` |
| `--c-bluButHovBac` | `#1f76cc` | `#3d90e1` |
| `--c-bluButPreBac` | `#1c69b6` | `#539ce5` |
| `--c-bluTexAccPri` | `#2783de` | `#2783de` |
| `--c-bluTexInvPri` | `#f3f9fd` | `#f3f9fd` |
| `--ca-bluBacSecTra` | `#007cd718` | `#439bff3d` |
| `--ca-bluBacTerTra` | `#0076d934` | `#51a6ff7e` |
| `--c-redTexAccPri` | `#e56458` | `#e56458` |
| `--ca-redBacSecTra` | `#df160018` | `#ff685c3d` |
| `--ca-redBacSecHov` | `#df160024` | `#ff685c5c` |
| `--c-focSha` | `#2383e291 0px 0px 0px 1px inset, #2383e259 0px 0px 0px 2px` | `#2383e291 0px 0px 0px 1px inset, #2383e259 0px 0px 0px 2px` |
| `--font-size-small` | `14px` | `14px` |
| `--line-height-tight` | `1.2` | `1.2` |
| `--font-weight-normal` | `400` | `400` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-control` | `6px` | `6px` |
| `--radius-rounded` | `9999px` | `9999px` |
| `--duration-hover` | `100ms` | `100ms` |
| `--duration-highlight` | `20ms` | `20ms` |
| `--duration-spin` | `1.2s` | `1.2s` |
| `--ease-hover` | `ease-in-out` | `ease-in-out` |
| `--ease-highlight` | `ease-in` | `ease-in` |
## CSS
Scoped under `[data-style="notion"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="notion"] {
.ui-button {
position: relative;
box-sizing: border-box;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 6px;
height: 28px;
margin: 0;
padding: 0 8px;
border: 0;
border-radius: var(--radius-control);
background-color: transparent;
color: var(--c-texPri);
font-family: inherit;
font-size: var(--font-size-small);
font-weight: var(--font-weight-medium);
line-height: var(--line-height-tight);
white-space: nowrap;
user-select: none;
cursor: pointer;
outline: none;
transition: background var(--duration-hover) var(--ease-hover);
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--ca-bacIntTra);
}
}
&:active:not([data-disabled]) {
background-color: var(--ca-bacIntPre);
}
&:focus-visible {
box-shadow: var(--c-focSha);
}
&[data-disabled] {
opacity: 0.4;
cursor: default;
}
& svg {
width: 16px;
height: 16px;
flex-shrink: 0;
}
}
.ui-button[data-size="small"] {
height: 24px;
padding: 0 6px;
}
.ui-button[data-size="large"] {
gap: 8px;
height: 32px;
padding: 0 12px;
}
.ui-button[data-icon-only] {
aspect-ratio: 1;
padding: 0;
& svg {
width: 20px;
height: 20px;
}
}
.ui-button[data-size="small"][data-icon-only] svg {
width: 16px;
height: 16px;
}
.ui-button[data-variant="primary"] {
background-color: var(--c-bluBacAccPri);
color: var(--c-bluTexInvPri);
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--c-bluButHovBac);
}
}
&:active:not([data-disabled]) {
background-color: var(--c-bluButPreBac);
}
}
.ui-button:is([data-variant="secondary"], [data-variant="default"]) {
border: 1px solid var(--ca-borPriTra);
transition: background var(--duration-highlight) var(--ease-highlight);
}
.ui-button[data-variant="ghost"] {
&:not([data-icon-only]) {
font-weight: var(--font-weight-normal);
}
&[data-size="large"]:not([data-icon-only]) {
padding: 0 8px;
}
}
.ui-button[data-variant="accent"] {
background-color: var(--ca-bluBacSecTra);
color: var(--c-bluTexAccPri);
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--ca-bluBacTerTra);
}
}
}
.ui-button[data-variant="danger"] {
background-color: var(--ca-redBacSecTra);
color: var(--c-redTexAccPri);
@media (hover: hover) {
&:hover:not([data-disabled]) {
background-color: var(--ca-redBacSecHov);
}
}
}
.ui-button[data-loading] {
opacity: 1;
cursor: wait;
}
.ui-button-spinner {
box-sizing: border-box;
width: 14px;
height: 14px;
flex-shrink: 0;
border: 1.5px solid var(--ca-borSecTra);
border-top-color: currentColor;
border-radius: var(--radius-rounded);
animation: notion-spinner-spin var(--duration-spin) linear infinite;
}
@media (prefers-reduced-motion: reduce) {
.ui-button-spinner {
animation-duration: calc(var(--duration-spin) * 3);
}
}
}
```
## 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 Notion style, as a skill: https://replicas.raphaelsalaja.com/skills/notion/SKILL.md