Button
A button component that can be rendered as another tag or focusable when disabled.
Measured from the Mintlify dashboard's login page buttons, primary and secondary with hover, light and dark. The destructive red comes from the standard Radix scale, not the dashboard.
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="tertiary">Tertiary</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="destructive">Destructive</Button>
<Button variant="brand">Brand</Button>Sizes
<Button size="base">Base</Button>
<Button size="small">Small</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 Mintlify style: the measured tokens, the CSS and the structure.
Show Prompt
# Mintlify 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 Mintlify's. Measured from the running Mintlify app (mintlify.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 Mintlify dashboard's login page buttons, primary and secondary with hover, light and dark. The destructive red comes from the standard Radix scale, not the dashboard.
## Variants
- `variant`: `primary`, `secondary`, `tertiary`, `ghost`, `destructive`, `brand`
- `size`: `base`, `small`
## Tokens
| Token | Light | Dark |
| --- | --- | --- |
| `--mint-brand-base` | `#16433c` | `color(display-p3 0.104 0.275 0.264)` |
| `--mint-on-brand` | `#f9fefd` | `#eeeeee` |
| `--mint-surface-2` | `#ffffff` | `#2a2a2a` |
| `--mint-inverse` | `#111111` | `#fcfcfc` |
| `--mint-on-inverse` | `#fcfcfc` | `#202020` |
| `--mint-hover-base-strong` | `rgb(0 0 0 / 0.05)` | `rgb(255 255 255 / 0.05)` |
| `--mint-special-grey` | `rgb(0 0 0 / 0.05)` | `rgb(255 255 255 / 0.05)` |
| `--mint-text-base` | `#4a4a4a` | `#b4b4b4` |
| `--mint-text-strong` | `#202020` | `#eeeeee` |
| `--mint-destructive-text` | `#ce2c31` | `#ec5d5e` |
| `--mint-shadow-weak` | `var(--mint-shadow-layer-1), var(--mint-shadow-border), var(--mint-shadow-inset)` | `var(--mint-shadow-layer-1), var(--mint-shadow-border), var(--mint-shadow-inset)` |
| `--mint-shadow-weak-focus` | `0 0 0 1px var(--mint-brand-focus), 0 0 0 3px var(--mint-brand-halo), var(--mint-shadow-layer-1), var(--mint-shadow-inset)` | `0 0 0 1px var(--mint-brand-focus), 0 0 0 3px var(--mint-brand-halo), var(--mint-shadow-layer-1), var(--mint-shadow-inset)` |
| `--mint-shadow-weak-destructive` | `0 0 0 1px var(--mint-destructive-stroke), 0 0 0 3px var(--mint-destructive-halo), var(--mint-shadow-layer-1), var(--mint-shadow-inset)` | `0 0 0 1px var(--mint-destructive-stroke), 0 0 0 3px var(--mint-destructive-halo), var(--mint-shadow-layer-1), var(--mint-shadow-inset)` |
| `--button-secondary-bg-hover` | `color-mix(in srgb, #000000 2%, var(--mint-surface-2))` | `color-mix(in srgb, #ffffff 2%, var(--mint-surface-2))` |
| `--font-dashboard` | `"Mintlify Inter", ui-sans-serif, system-ui, -apple-system, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif` | `"Mintlify Inter", ui-sans-serif, system-ui, -apple-system, "system-ui", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-rounded` | `9999px` | `9999px` |
| `--duration-spinner` | `1.2s` | `1.2s` |
| `--duration-spinner-reduced` | `3s` | `3s` |
## CSS
Scoped under `[data-style="mintlify"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.
```css
[data-style="mintlify"] {
.ui-button {
--button-bg: var(--mint-surface-2);
--button-bg-hover: var(--button-secondary-bg-hover);
--button-text: var(--mint-text-strong);
--button-text-hover: var(--button-text);
--button-shadow: var(--mint-shadow-weak);
position: relative;
box-sizing: border-box;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 2px;
height: 32px;
margin: 0;
padding: 6px 10px;
border: 0;
border-radius: 6px;
background-color: var(--button-bg);
box-shadow: var(--button-shadow);
color: var(--button-text);
font-family: var(--font-dashboard);
font-size: 14px;
font-weight: var(--font-weight-medium);
line-height: 20px;
letter-spacing: -0.001em;
white-space: nowrap;
user-select: none;
cursor: pointer;
outline: none;
&::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
}
@media (hover: hover) {
&:hover:not([data-disabled], [data-loading]) {
background-color: var(--button-bg-hover);
color: var(--button-text-hover);
}
}
&:focus-visible {
box-shadow: var(--mint-shadow-weak-focus);
}
&[data-disabled] {
opacity: 0.5;
cursor: default;
}
& svg {
width: 16px;
height: 16px;
flex-shrink: 0;
}
}
.ui-button[data-size="small"] {
height: 28px;
padding: 4px 12px;
}
.ui-button:is([data-size="base"], [data-size="medium"], [data-size="large"]) {
height: 32px;
padding: 6px 10px;
}
.ui-button[data-icon-only] {
width: 32px;
padding: 0;
&[data-size="small"] {
width: 28px;
}
}
.ui-button[data-variant="primary"] {
--button-bg: var(--mint-inverse);
--button-bg-hover: color-mix(in srgb, var(--mint-on-inverse) 8%, var(--mint-inverse));
--button-text: var(--mint-on-inverse);
}
.ui-button:is([data-variant="secondary"], :not([data-variant])) {
--button-bg: var(--mint-surface-2);
--button-bg-hover: var(--button-secondary-bg-hover);
--button-text: var(--mint-text-strong);
}
.ui-button[data-variant="tertiary"] {
--button-bg: var(--mint-special-grey);
--button-bg-hover: color-mix(in srgb, var(--mint-text-strong) 8%, transparent);
--button-text: var(--mint-text-strong);
--button-shadow: none;
}
.ui-button[data-variant="ghost"] {
--button-bg: transparent;
--button-bg-hover: var(--mint-hover-base-strong);
--button-text: var(--mint-text-base);
--button-text-hover: var(--mint-text-strong);
--button-shadow: none;
}
.ui-button[data-variant="destructive"] {
--button-bg: var(--mint-surface-2);
--button-bg-hover: var(--button-secondary-bg-hover);
--button-text: var(--mint-destructive-text);
&:focus-visible {
box-shadow: var(--mint-shadow-weak-destructive);
}
}
.ui-button[data-variant="brand"] {
--button-bg: var(--mint-brand-base);
--button-bg-hover: color-mix(in srgb, var(--mint-on-brand) 8%, var(--mint-brand-base));
--button-text: var(--mint-on-brand);
}
.ui-button[data-loading] {
opacity: 1;
cursor: wait;
}
.ui-button-spinner {
box-sizing: border-box;
width: 14px;
height: 14px;
margin: 1px;
flex-shrink: 0;
border: 1.5px solid color-mix(in srgb, currentColor 25%, transparent);
border-top-color: currentColor;
border-radius: var(--radius-rounded);
animation: mintlify-spinner-spin var(--duration-spinner) linear infinite;
}
@media (prefers-reduced-motion: reduce) {
.ui-button-spinner {
animation-duration: var(--duration-spinner-reduced);
}
}
}
```
## 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 Mintlify style, as a skill: https://replicas.raphaelsalaja.com/skills/mintlify/SKILL.md