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="subtle">Subtle</Button>
<Button variant="destructive">Destructive</Button>
<Button variant="dashed">Dashed</Button>

Sizes

<Button size="micro">Micro</Button>
<Button size="small">Small</Button>
<Button size="regular">Regular</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>;
}
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 Palermo style: the measured tokens, the CSS and the structure.

Show Prompt
# Palermo 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 Palermo's. Measured from the running Palermo app (palermo.tryprofound.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 Palermo docs /docs/button, primary, secondary and ghost variants with hover, light and dark.

## Variants

- `variant`: `primary`, `secondary`, `tertiary`, `ghost`, `subtle`, `destructive`, `dashed`
- `size`: `micro`, `small`, `regular`, `large`

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--color-bg-secondary` | `#fafafa` | `#1e1d1c` |
| `--color-bg-tertiary` | `#f5f5f5` | `#272625` |
| `--color-bg-quaternary` | `#e8e8e8` | `#31302e` |
| `--color-fill-tertiary` | `#d4d4d8` | `#5a5855` |
| `--color-fill-red` | `#fb2c36` | `#ff6568` |
| `--color-fill-red-hover` | `color-mix(in oklch, #fb2c36 90%, transparent)` | `color-mix(in oklch, #ff6568 90%, #121110 10%)` |
| `--color-text-white` | `#fff` | `#fff` |
| `--color-control-hover` | `#f5f5f5` | `#31302e` |
| `--text-primary` | `#18181a` | `#ecebe9` |
| `--text-secondary` | `#787878` | `#aaa8a5` |
| `--text-quaternary` | `#b4b4b4` | `#676563` |
| `--accent` | `#18181a` | `#f5f4f2` |
| `--accent-hover` | `#2c2c2e` | `#ecebe9` |
| `--accent-text` | `#fff` | `#0f0e0d` |
| `--chip-bg` | `#fff` | `#1e1d1c` |
| `--chip-bg-hover` | `#f5f5f5` | `#252423` |
| `--chip-text` | `#18181a` | `#ecebe9` |
| `--ghost-text` | `#18181a` | `#ecebe9` |
| `--ghost-bg-hover` | `#0000000d` | `#d6d5d412` |
| `--shadow-low` | `var(--surface-shadow-low), var(--shadow-border)` | `var(--surface-shadow-low), var(--shadow-border)` |
| `--focus-ring` | `#006bff` | `#006bff` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--line-height-mini` | `16px` | `16px` |
| `--line-height-small` | `18px` | `18px` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-control` | `8px` | `8px` |
| `--ease-out` | `cubic-bezier(0, 0, 0.2, 1)` | `cubic-bezier(0, 0, 0.2, 1)` |
| `--ease-pulse` | `cubic-bezier(0.4, 0, 0.6, 1)` | `cubic-bezier(0.4, 0, 0.6, 1)` |
| `--duration-fast` | `100ms` | `100ms` |
| `--duration-smooth` | `250ms` | `250ms` |
| `--duration-press` | `300ms` | `300ms` |
| `--duration-button-spin` | `400ms` | `400ms` |
| `--duration-pulse` | `2s` | `2s` |

## CSS

Scoped under `[data-style="palermo"]`; dark rules sit under `[data-theme="dark"]`. The `ui-*` classes and data attributes match the structure below.

```css
[data-style="palermo"] {
  .ui-button {
    box-sizing: border-box;
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin: 0;
    border: none;
    border-radius: var(--radius-control);
    font-family: inherit;
    font-weight: var(--font-weight-medium);
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    outline: none;
    transition: scale var(--duration-press) var(--ease-out);

    &:focus-visible {
      outline: 1px solid var(--focus-ring);
      outline-offset: -1px;
    }

    &:active:not([data-disabled]) {
      scale: 0.97;
    }

    &[data-disabled] {
      background-color: var(--color-bg-secondary);
      color: var(--text-quaternary);
      box-shadow: none;
      cursor: not-allowed;
    }

    & svg {
      width: 16px;
      height: 16px;
      flex-shrink: 0;
    }

    & > svg:first-child {
      margin-inline-start: -2px;
    }

    & > svg:last-child {
      margin-inline-end: -2px;
    }
  }

  .ui-button[data-size="micro"] {
    min-height: 20px;
    min-width: 20px;
    padding: 0 8px;
    font-size: var(--font-size-mini);
    line-height: var(--line-height-mini);

    & svg {
      width: 12px;
      height: 12px;
    }
  }

  .ui-button[data-size="small"] {
    min-height: 24px;
    min-width: 24px;
    padding: 0 8px;
    font-size: var(--font-size-mini);
    line-height: var(--line-height-mini);

    & svg {
      width: 14px;
      height: 14px;
    }
  }

  .ui-button:is([data-size="medium"], [data-size="regular"]) {
    min-height: 28px;
    min-width: 28px;
    padding: 0 8px;
    font-size: var(--font-size-small);
    line-height: var(--line-height-small);
  }

  .ui-button[data-size="large"] {
    min-height: 38px;
    min-width: 38px;
    padding: 0 10px;
    font-size: var(--font-size-small);
    line-height: var(--line-height-small);
  }

  .ui-button[data-icon-only] {
    padding: 0;

    & > svg:first-child,
    & > svg:last-child {
      margin: 0;
    }
  }

  .ui-button[data-variant="primary"]:not([data-disabled]) {
    background-color: var(--accent);
    color: var(--accent-text);
    box-shadow: var(--shadow-low);

    @media (hover: hover) {
      &:hover {
        background-color: var(--accent-hover);
      }
    }
  }

  .ui-button[data-variant="secondary"]:not([data-disabled]) {
    background-color: var(--chip-bg);
    color: var(--chip-text);
    box-shadow: var(--shadow-low);

    @media (hover: hover) {
      &:hover {
        background-color: var(--chip-bg-hover);
      }
    }
  }

  .ui-button[data-variant="ghost"] {
    background-color: transparent;
    color: var(--ghost-text);

    @media (hover: hover) {
      &:hover:not([data-disabled]) {
        background-color: var(--ghost-bg-hover);
      }
    }

    &[data-disabled] {
      background-color: var(--color-bg-tertiary);
      color: var(--text-quaternary);
    }
  }

  .ui-button[data-variant="tertiary"]:not([data-disabled]) {
    background-color: var(--color-bg-tertiary);
    color: var(--text-primary);

    &:active {
      background-color: var(--color-bg-quaternary);
    }
  }

  .ui-button[data-variant="subtle"]:not([data-disabled]) {
    background-color: transparent;
    color: var(--text-secondary);

    @media (hover: hover) {
      &:hover {
        background-color: var(--color-bg-tertiary);
        color: var(--text-primary);
      }
    }

    &:active {
      background-color: var(--color-bg-quaternary);
      color: var(--text-primary);
    }
  }

  .ui-button:is([data-variant="destructive"], [data-variant="danger"]):not([data-disabled]) {
    background-color: var(--color-fill-red);
    color: var(--color-text-white);
    box-shadow: var(--shadow-low);

    @media (hover: hover) {
      &:hover {
        background-color: var(--color-fill-red-hover);
      }
    }
  }

  .ui-button[data-variant="dashed"] {
    box-shadow: none;

    &:not(:focus-visible) {
      outline: 1px dashed var(--color-fill-tertiary);
      outline-offset: 0;
    }

    &:not([data-disabled]) {
      background-color: transparent;
      color: var(--text-secondary);

      @media (hover: hover) {
        &:hover {
          background-color: var(--color-control-hover);
        }
      }
    }
  }

  .ui-button[data-loading] {
    color: transparent;
    cursor: progress;
    transition:
      scale var(--duration-press) var(--ease-out),
      color var(--duration-fast) var(--ease-out);

    & > :not(.ui-button-spinner) {
      opacity: 0;
      transition: opacity var(--duration-fast) var(--ease-out);
    }
  }

  .ui-button > .ui-button-spinner {
    position: absolute;
    inset: 0;
    margin: auto;
    animation:
      palermo-button-spinner-in var(--duration-smooth) var(--ease-out),
      palermo-spinner-spin var(--duration-button-spin) linear infinite;

    @media (prefers-reduced-motion: reduce) {
      animation: palermo-spinner-pulse var(--duration-pulse) var(--ease-pulse) infinite;
    }
  }
}

@keyframes palermo-button-spinner-in {
  from {
    opacity: 0;
    filter: blur(8px);
  }
}
```

## 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 Palermo style, as a skill: https://replicas.raphaelsalaja.com/skills/palermo/SKILL.md