# Aave Pro Input Group

An input with leading or trailing addons such as icons, units and buttons.

Build a Input Group 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 primitives if it has none.

Fidelity: Partly measured from Aave Pro's inputs, light and dark. No reference has been captured yet.

## Variants

- `size`: `sm`, `md`, `lg`, `xl`

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--fg-3` | `#7d7d7d` | `#8f8e8e` |
| `--fg-4` | `#a8a8a8` | `#636161` |
| `--bg-2` | `#fcfcfc` | `#1a1919` |
| `--bg-3` | `#fff` | `#1f1e1e` |
| `--sunken-1` | `#f2f2f2` | `#0006` |
| `--duration-quick` | `0.1s` | `0.1s` |
| `--input-bg` | `transparent` | `transparent` |
| `--input-border` | `#00000014` | `#ffffff14` |
| `--input-border-hover` | `#0000001a` | `#ffffff1f` |
| `--input-text` | `#000` | `#fff` |
| `--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-size-regular` | `1rem` | `1rem` |
| `--font-weight-normal` | `400` | `400` |
| `--radius-control` | `10px` | `10px` |
| `--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-input-group {
    --input-ring: var(--input-border);

    box-sizing: border-box;
    display: flex;
    align-items: center;
    width: 100%;
    height: 36px;
    padding: 0 12px;
    border-radius: var(--radius-control);
    background-color: var(--input-bg);
    box-shadow: 0 0 0 1px var(--input-ring);
    color: var(--input-text);
    font-family: var(--font-regular);
    font-size: var(--font-size-small);
    transition:
      box-shadow var(--duration-quick),
      background-color var(--duration-quick);

    @media (hover: hover) {
      &:hover:not(:focus-within) {
        --input-ring: var(--input-border-hover);
      }
    }

    &:focus-within {
      --input-ring: var(--input-border-hover);

      background-color: var(--bg-2);
    }

    &:has(.ui-input-group-input[data-disabled]) {
      background-color: var(--bg-3);
      opacity: 0.6;
    }
  }

  .ui-input-group:is([data-size="sm"], [data-size="small"]) {
    height: 32px;
    padding: 0 14px;
    border-radius: var(--radius-rounded);
    background-color: var(--sunken-1);
    box-shadow: none;

    &:focus-within {
      box-shadow: 0 0 0 1px var(--input-ring);
    }
  }

  .ui-input-group:is([data-size="md"], [data-size="medium"]) {
    height: 36px;
  }

  .ui-input-group:is([data-size="lg"], [data-size="large"]) {
    height: 40px;
  }

  .ui-input-group[data-size="xl"] {
    height: 44px;
    padding: 0 17px;
    border-radius: 12px;
    font-size: var(--font-size-regular);
  }

  .ui-input-group-addon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    gap: 6px;
    margin-right: 8px;
    color: var(--fg-3);
    white-space: nowrap;

    &:last-child {
      margin-right: 0;
      margin-left: 8px;
    }

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

  .ui-input-group-input {
    box-sizing: border-box;
    flex: 1;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background-color: transparent;
    color: inherit;
    font: inherit;
    font-weight: var(--font-weight-normal);
    outline: none;

    &::placeholder {
      color: var(--fg-4);
    }

    .ui-input-group-addon + & {
      padding-left: 0;
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Input as BaseInput } from "@base-ui/react/input";
import type { ComponentProps } from "react";
import { join } from "./utils";

function Root({ className, size, ...props }: ComponentProps<"div"> & { size?: string }) {
  return <div className={join("ui-input-group", className)} data-size={size} {...props} />;
}

function Addon({ className, ...props }: ComponentProps<"span">) {
  return <span className={join("ui-input-group-addon", className)} {...props} />;
}

function Input({ className, ...props }: Omit<BaseInput.Props, "className"> & { className?: string }) {
  return <BaseInput className={join("ui-input-group-input", className)} {...props} />;
}

export const InputGroup = { Root, Addon, Input };
```

## Example

```tsx
import { InputGroup } from "@replicas/ui";

export default function InputGroupDemo() {
  return (
    <InputGroup.Root style={{ width: 280 }}>
      <InputGroup.Addon>
        <svg viewBox="0 0 16 16" fill="none" width="16" height="16" aria-hidden>
          <circle cx="7" cy="7" r="4.5" stroke="currentColor" strokeWidth="1.5" />
          <path d="M10.5 10.5L13.5 13.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
        </svg>
      </InputGroup.Addon>
      <InputGroup.Input placeholder="Search files" aria-label="Search files" />
      <InputGroup.Addon>⌘F</InputGroup.Addon>
    </InputGroup.Root>
  );
}
```

## Foundations

The rest of the Aave Pro style, as a skill: https://replicas.raphaelsalaja.com/skills/aave/SKILL.md