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="quaternary">Quaternary</Button>
<Button variant="text">Text</Button>

Sizes

<Button size="sm">Sm</Button>
<Button size="md">Md</Button>
<Button size="lg">Lg</Button>
<Button size="xl">Xl</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 Aave Pro style: the measured tokens, the CSS and the structure.

Show Prompt
# Aave Pro 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 Aave Pro's. Measured from the running Aave Pro app (pro.aave.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 Aave Pro's header, cookie banner, Preferences and Watch Address buttons, light and dark. Padding for the lg size is derived; its height is measured.

## Variants

- `variant`: `primary`, `secondary`, `tertiary`, `quaternary`, `text`
- `size`: `sm`, `md`, `lg`, `xl`

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--fg-1` | `#000` | `#fff` |
| `--fg-2` | `#666` | `#bcbbbb` |
| `--fg-3` | `#7d7d7d` | `#8f8e8e` |
| `--selected` | `#0000000a` | `#ffffff0f` |
| `--button-fg-1` | `#fff` | `#000` |
| `--button-fg-2` | `#000` | `#fff` |
| `--button-fg-3` | `#7d7d7d` | `#8f8e8e` |
| `--button-bg-1` | `#000` | `#fff` |
| `--button-bg-2` | `#fff` | `#1f1e1e` |
| `--button-bg-3` | `#fff` | `#2a2828` |
| `--button-bg-4` | `#f2f2f2` | `#2a2828` |
| `--button-hover-1` | `#ffffff29` | `#00000029` |
| `--button-hover-2` | `#00000008` | `#ffffff0a` |
| `--button-hover-3` | `#0000000a` | `#ffffff0f` |
| `--border-secondary-btn` | `#00000014` | `#ffffff1a` |
| `--shadow-secondary-btn` | `#00000008` | `#fff0` |
| `--duration-button` | `0.18s` | `0.18s` |
| `--font-regular` | `"Aave Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif` | `"Aave Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif` |
| `--font-size-small` | `0.875rem` | `0.875rem` |
| `--font-weight-medium` | `500` | `500` |
| `--radius-rounded` | `9999px` | `9999px` |

## CSS

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

```css
[data-style="aave"] {
  .ui-button {
    --button-color: var(--button-fg-2);
    --button-background: var(--button-bg-2);
    --button-background-hover: var(--button-hover-2);
    --button-shadow: 0 2px 4px 0 var(--shadow-secondary-btn), 0 0 0 1px var(--border-secondary-btn);

    position: relative;
    isolation: isolate;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    margin: 0;
    padding: 0 14px;
    border: 0;
    border-radius: 10rem;
    overflow: hidden;
    background: var(--button-background);
    box-shadow: var(--button-shadow);
    color: var(--button-color);
    font-family: var(--font-regular);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    line-height: 1;
    white-space: nowrap;
    user-select: none;
    cursor: pointer;
    -webkit-font-smoothing: antialiased;
    transition:
      box-shadow var(--duration-button),
      background-color var(--duration-button),
      transform var(--duration-button);

    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      border-radius: inherit;
      background-color: var(--button-background-hover);
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.1s;
    }

    @media (hover: hover) {
      &:hover:not([data-disabled])::before {
        opacity: 1;
      }
    }

    &:active:not([data-disabled]) {
      transform: scale(0.99);
      transition-duration: 0.1s;
    }

    &:focus-visible {
      outline: 2px solid var(--fg-3);
      outline-offset: 2px;
    }

    &[data-disabled] {
      opacity: 0.3;
      cursor: not-allowed;
    }

    & svg {
      width: 20px;
      height: 20px;
      flex-shrink: 0;
      color: var(--button-fg-3);
    }
  }

  .ui-button:is([data-variant="primary"]) {
    --button-color: var(--button-fg-1);
    --button-background: var(--button-bg-1);
    --button-background-hover: var(--button-hover-1);
    --button-shadow: none;

    & svg {
      color: currentColor;
    }
  }

  .ui-button[data-variant="tertiary"] {
    --button-background: var(--button-bg-3);
    --button-background-hover: var(--button-hover-3);
  }

  .ui-button[data-variant="quaternary"] {
    --button-background: var(--button-bg-4);
    --button-background-hover: var(--button-hover-3);
    --button-shadow: none;

    gap: 6px;
  }

  .ui-button:is([data-variant="text"], [data-variant="ghost"]) {
    --button-color: var(--fg-2);
    --button-background: transparent;
    --button-shadow: none;

    gap: 6px;
    padding-inline: 0;
    border-radius: 0;
    overflow: visible;
    transition:
      box-shadow var(--duration-button),
      background-color var(--duration-button),
      color 0.2s,
      transform var(--duration-button);

    &::before {
      display: none;
    }

    @media (hover: hover) {
      &:hover:not([data-disabled]) {
        --button-color: var(--fg-1);
      }
    }
  }

  .ui-button:is([data-size="sm"], [data-size="small"]) {
    gap: 2px;
    height: 28px;
    padding: 0 10px;

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

  .ui-button:is([data-size="md"], [data-size="medium"]) {
    height: 36px;
    padding: 0 14px;
  }

  .ui-button:is([data-size="lg"], [data-size="large"]) {
    height: 36px;
    padding: 0 21px;
  }

  .ui-button[data-size="xl"] {
    height: 40px;
    padding: 20px 18px;
  }

  .ui-button:is([data-variant="text"], [data-variant="ghost"]):not([data-icon-only]) {
    padding-inline: 0;
  }

  .ui-button[data-icon-only] {
    aspect-ratio: 1;
    padding: 0;
  }

  .ui-button[data-icon-only]:is([data-variant="text"], [data-variant="ghost"]) {
    width: 32px;
    height: 32px;
    border-radius: 6px;

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

  .ui-button[data-loading] {
    opacity: 1;
    cursor: wait;
    pointer-events: none;
  }

  .ui-button-spinner {
    box-sizing: border-box;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    border: 1.6px solid color-mix(in srgb, currentColor 25%, transparent);
    border-top-color: currentColor;
    border-radius: var(--radius-rounded);
    animation: aave-spinner-spin 0.8s linear infinite;
  }

  @media (prefers-reduced-motion: reduce) {
    .ui-button-spinner {
      animation-duration: 2s;
    }
  }
}
```

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