# Aave Pro Scroll Area

A native scroll container with custom scrollbars.

Build a Scroll Area 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/scroll-area) if it has none.

Fidelity: Partly measured from Aave Pro's CSS and computed styles. No reference has been captured yet.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--fg-4` | `#a8a8a8` | `#636161` |
| `--focus-color` | `#007aff80` | `#007aff80` |
| `--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-scroll-area {
    box-sizing: border-box;
  }

  .ui-scroll-area-viewport {
    box-sizing: border-box;
    height: 100%;
    border-radius: inherit;
    outline: none;

    &:focus-visible {
      outline: 2px solid var(--focus-color);
    }
  }

  .ui-scroll-area-scrollbar {
    box-sizing: border-box;
    display: flex;
    padding: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;

    &[data-orientation="vertical"] {
      width: 10px;
    }

    &[data-orientation="horizontal"] {
      height: 10px;
    }

    &[data-hovering],
    &[data-scrolling] {
      opacity: 1;
      pointer-events: auto;
    }

    &[data-scrolling] {
      transition-duration: 0s;
    }
  }

  .ui-scroll-area-thumb {
    border-radius: var(--radius-rounded);
    background-color: var(--fg-4);
    opacity: 0.6;
    transition: opacity 0.2s;

    &[data-orientation="vertical"] {
      width: 100%;
    }

    &[data-orientation="horizontal"] {
      height: 100%;
    }

    &:hover,
    &:active {
      opacity: 1;
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { ScrollArea as BaseScrollArea } from "@base-ui/react/scroll-area";

const join = (base: string, extra?: string) => (extra ? `${base} ${extra}` : base);

function Root({ className, ...props }: Omit<BaseScrollArea.Root.Props, "className"> & { className?: string }) {
  return <BaseScrollArea.Root className={join("ui-scroll-area", className)} {...props} />;
}

function Viewport({ className, ...props }: Omit<BaseScrollArea.Viewport.Props, "className"> & { className?: string }) {
  return <BaseScrollArea.Viewport className={join("ui-scroll-area-viewport", className)} {...props} />;
}

function Scrollbar({
  className,
  ...props
}: Omit<BaseScrollArea.Scrollbar.Props, "className" | "children"> & { className?: string }) {
  return (
    <BaseScrollArea.Scrollbar className={join("ui-scroll-area-scrollbar", className)} {...props}>
      <BaseScrollArea.Thumb className="ui-scroll-area-thumb" />
    </BaseScrollArea.Scrollbar>
  );
}

export const ScrollArea = {
  Root,
  Viewport,
  Content: BaseScrollArea.Content,
  Scrollbar,
  Corner: BaseScrollArea.Corner,
};
```

## Example

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

const activity = [
  ["09:41", "Alex Rivera shared Quarterly report with you"],
  ["09:12", "Jordan Lee commented on Launch plan"],
  ["08:57", "Morgan Chen uploaded 12 photos to Brand assets"],
  ["08:30", "Sam Patel renamed Budget draft to Budget 2027"],
  ["Mon", "Taylor Kim joined the Marketing team"],
  ["Mon", "Alex Rivera moved Invoices to Finance"],
  ["Sun", "Jordan Lee restored Meeting notes from the bin"],
  ["Sat", "Morgan Chen created the folder Client work"],
  ["Fri", "Sam Patel changed the workspace name"],
  ["Thu", "Taylor Kim invited two guests to Website redesign"],
];

export default function ScrollAreaDemo() {
  return (
    <ScrollArea.Root style={{ width: 320, height: 200 }}>
      <ScrollArea.Viewport>
        <ScrollArea.Content style={{ minWidth: 0, padding: "4px 0" }}>
          {activity.map(([time, title]) => (
            <div
              key={title}
              style={{
                display: "flex",
                alignItems: "center",
                gap: 10,
                height: 36,
                padding: "0 12px",
                fontSize: "var(--font-size-small)",
              }}
            >
              <span style={{ flexShrink: 0, width: 64, color: "var(--text-tertiary)", whiteSpace: "nowrap" }}>{time}</span>
              <span
                style={{
                  overflow: "hidden",
                  color: "var(--text-primary)",
                  textOverflow: "ellipsis",
                  whiteSpace: "nowrap",
                }}
              >
                {title}
              </span>
            </div>
          ))}
        </ScrollArea.Content>
      </ScrollArea.Viewport>
      <ScrollArea.Scrollbar />
    </ScrollArea.Root>
  );
}
```

## Foundations

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