import { Badge, Spinner, Subagent } from "@replicas/ui";

const bot = (
  <svg viewBox="0 0 16 16" fill="none">
    <rect x="3" y="5" width="10" height="8" rx="2" stroke="currentColor" strokeWidth="1.25" />
    <path d="M8 2.5V5M6 9h.01M10 9h.01" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
  </svg>
);

const check = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M4 8.5l2.5 2.5L12 5.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

export default function SubagentDemo() {
  return (
    <Subagent.Root defaultOpen status="running" style={{ width: "100%", maxWidth: 420 }}>
      <Subagent.Trigger icon={bot} description="18s">
        Running the research agent
      </Subagent.Trigger>
      <Subagent.Content>
        <Subagent.Prompt>Find where the image cache key is built and what it depends on.</Subagent.Prompt>
        <Subagent.Meta>
          <Badge>Fast model</Badge>
          <Badge>Read only</Badge>
        </Subagent.Meta>
        <Subagent.Steps>
          <Subagent.Step icon={check}>Searched for cacheKey in scripts</Subagent.Step>
          <Subagent.Step icon={check}>Read scripts/optimize-images.ts</Subagent.Step>
          <Subagent.Step icon={<Spinner size="small" />} status="running">
            Reading next.config.ts
          </Subagent.Step>
        </Subagent.Steps>
      </Subagent.Content>
    </Subagent.Root>
  );
}

Prompt

Copy Prompt hands your agent everything it needs to build the Subagent in the Geist style: the measured tokens, the CSS and the structure.

Show Prompt
# Geist Subagent

A subagent run, with the task it was given, its steps and its result.

Build a Subagent in this project that looks and behaves like Geist's. Measured from the running Geist app (vercel.com/geist). 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: Derived from the Tool card, the Task steps and Geist's Badge. No Vercel AI surface shows a subagent.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--ds-background-100` | `hsl(0 0% 100%)` | `hsl(0 0% 4%)` |
| `--ds-gray-100` | `hsl(0 0% 95%)` | `hsl(0 0% 10%)` |
| `--ds-gray-200` | `hsl(0 0% 92%)` | `hsl(0 0% 12%)` |
| `--ds-gray-900` | `hsl(0 0% 30%)` | `hsl(0 0% 63%)` |
| `--ds-gray-1000` | `hsl(0 0% 9%)` | `hsl(0 0% 93%)` |
| `--ds-gray-alpha-400` | `#00000014` | `#ffffff24` |
| `--ds-red-900` | `oklch(54.99% 0.232 25.29)` | `oklch(69.96% 0.2136 22.03)` |
| `--ds-focus-ring` | `0 0 0 2px var(--ds-background-100), 0 0 0 4px var(--ds-focus-color)` | `0 0 0 2px var(--ds-background-100), 0 0 0 4px var(--ds-focus-color)` |
| `--ds-shimmer-spread` | `40px` | `40px` |
| `--ease-in-out` | `cubic-bezier(0.4, 0, 0.2, 1)` | `cubic-bezier(0.4, 0, 0.2, 1)` |
| `--default-transition-duration` | `0.15s` | `0.15s` |
| `--duration-shimmer` | `2s` | `2s` |
| `--font-size-micro` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.875rem` | `0.875rem` |
| `--font-weight-medium` | `500` | `500` |

## CSS

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

```css
@keyframes geist-subagent-shimmer {
  from {
    background-position: 100% 0, 0 0;
  }

  to {
    background-position: 0% 0, 0 0;
  }
}

[data-style="geist"] {
  .ui-subagent {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--ds-gray-alpha-400);
    border-radius: 8px;
    background-color: var(--ds-background-100);
    color: var(--ds-gray-1000);
    font-family: inherit;
    font-size: var(--font-size-small);
    line-height: 20px;
  }

  .ui-subagent-trigger {
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 12px;
    border: none;
    border-radius: 7px;
    background-color: transparent;
    color: var(--ds-gray-1000);
    font: inherit;
    text-align: start;
    user-select: none;
    cursor: pointer;

    &:focus-visible {
      outline: none;
      box-shadow: var(--ds-focus-ring);
    }
  }

  .ui-subagent-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: var(--ds-gray-900);

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

  .ui-subagent-title {
    min-width: 0;
    overflow: hidden;
    font-weight: var(--font-weight-medium);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-subagent-description {
    flex-shrink: 0;
    color: var(--ds-gray-900);
    font-size: var(--font-size-micro);
    line-height: 16px;
    font-variant-numeric: tabular-nums;
  }

  .ui-subagent-chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-left: auto;
    color: var(--ds-gray-900);
    rotate: 90deg;
    transition: rotate var(--default-transition-duration) var(--ease-in-out);

    [data-panel-open] > & {
      rotate: -90deg;
    }
  }

  .ui-subagent[data-status="running"] > .ui-subagent-trigger .ui-subagent-title {
    background-image:
      linear-gradient(
        90deg,
        transparent calc(50% - var(--ds-shimmer-spread)),
        var(--ds-background-100),
        transparent calc(50% + var(--ds-shimmer-spread))
      ),
      linear-gradient(var(--ds-gray-1000), var(--ds-gray-1000));
    background-size: 250% 100%, auto;
    background-repeat: no-repeat, repeat;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: geist-subagent-shimmer var(--duration-shimmer) linear infinite;
  }

  .ui-subagent[data-status="error"] .ui-subagent-icon {
    color: var(--ds-red-900);
  }

  .ui-subagent-content {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: var(--collapsible-panel-height);
    padding: 0 12px 12px;
    overflow: hidden;
    transition:
      height var(--default-transition-duration) var(--ease-in-out),
      padding-block var(--default-transition-duration) var(--ease-in-out),
      opacity var(--default-transition-duration) var(--ease-in-out);

    &[data-starting-style],
    &[data-ending-style] {
      height: 0;
      padding-block: 0;
      opacity: 0;
    }
  }

  .ui-subagent-prompt {
    margin: 0;
    padding: 8px 12px;
    border-radius: 8px;
    background-color: var(--ds-gray-100);
    color: var(--ds-gray-1000);
  }

  .ui-subagent-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;

    & .ui-badge {
      text-transform: none;
    }
  }

  .ui-subagent-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-left: 14px;
    margin-left: 7px;
    border-left: 2px solid var(--ds-gray-200);
  }

  .ui-subagent-step {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    color: var(--ds-gray-900);
  }

  .ui-subagent-step-icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 20px;

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

  .ui-subagent-step-label {
    min-width: 0;
  }

  .ui-subagent-step[data-status="running"] {
    color: var(--ds-gray-1000);

    & .ui-subagent-step-label {
      background-image:
        linear-gradient(
          90deg,
          transparent calc(50% - var(--ds-shimmer-spread)),
          var(--ds-background-100),
          transparent calc(50% + var(--ds-shimmer-spread))
        ),
        linear-gradient(var(--ds-gray-1000), var(--ds-gray-1000));
      background-size: 250% 100%, auto;
      background-repeat: no-repeat, repeat;
      -webkit-background-clip: text;
      background-clip: text;
      color: transparent;
      animation: geist-subagent-shimmer var(--duration-shimmer) linear infinite;
    }
  }

  .ui-subagent-step[data-status="error"] .ui-subagent-step-icon {
    color: var(--ds-red-900);
  }

  .ui-subagent-result {
    color: var(--ds-gray-1000);
  }

  @media (prefers-reduced-motion: reduce) {
    .ui-subagent-chevron,
    .ui-subagent-content {
      transition: none;
    }

    .ui-subagent[data-status="running"] > .ui-subagent-trigger .ui-subagent-title,
    .ui-subagent-step[data-status="running"] .ui-subagent-step-label {
      animation: none;
      background: none;
      color: var(--ds-gray-1000);
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { Collapsible as BaseCollapsible } from "@base-ui/react/collapsible";
import type { ComponentProps, ReactNode } from "react";
import { join } from "./utils";

type RootProps = Omit<BaseCollapsible.Root.Props, "className"> & {
  className?: string;
  status?: string;
};

function Root({ className, status, ...props }: RootProps) {
  return <BaseCollapsible.Root className={join("ui-subagent", className)} data-status={status} {...props} />;
}

type TriggerProps = Omit<BaseCollapsible.Trigger.Props, "className"> & {
  className?: string;
  icon?: ReactNode;
  description?: ReactNode;
};

function Trigger({ className, icon, description, children, ...props }: TriggerProps) {
  return (
    <BaseCollapsible.Trigger className={join("ui-subagent-trigger", className)} {...props}>
      {icon ? <span className="ui-subagent-icon" aria-hidden>{icon}</span> : null}
      <span className="ui-subagent-title">{children}</span>
      {description ? <span className="ui-subagent-description">{description}</span> : null}
      <svg className="ui-subagent-chevron" viewBox="0 0 16 16" fill="none" aria-hidden>
        <path d="M6 4l4 4-4 4" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
      </svg>
    </BaseCollapsible.Trigger>
  );
}

function Content({ className, ...props }: Omit<BaseCollapsible.Panel.Props, "className"> & { className?: string }) {
  return <BaseCollapsible.Panel className={join("ui-subagent-content", className)} {...props} />;
}

function Prompt({ className, ...props }: ComponentProps<"p">) {
  return <p className={join("ui-subagent-prompt", className)} {...props} />;
}

function Meta({ className, ...props }: ComponentProps<"div">) {
  return <div className={join("ui-subagent-meta", className)} {...props} />;
}

function Steps({ className, ...props }: ComponentProps<"div">) {
  return <div className={join("ui-subagent-steps", className)} {...props} />;
}

type StepProps = ComponentProps<"div"> & { icon?: ReactNode; status?: string };

function Step({ className, icon, status, children, ...props }: StepProps) {
  return (
    <div className={join("ui-subagent-step", className)} data-status={status} {...props}>
      {icon ? <span className="ui-subagent-step-icon" aria-hidden>{icon}</span> : null}
      <span className="ui-subagent-step-label">{children}</span>
    </div>
  );
}

function Result({ className, ...props }: ComponentProps<"div">) {
  return <div className={join("ui-subagent-result", className)} {...props} />;
}

export const Subagent = {
  Root,
  Trigger,
  Content,
  Prompt,
  Meta,
  Steps,
  Step,
  Result,
};
```

## Example

```tsx
import { Badge, Spinner, Subagent } from "@replicas/ui";

const bot = (
  <svg viewBox="0 0 16 16" fill="none">
    <rect x="3" y="5" width="10" height="8" rx="2" stroke="currentColor" strokeWidth="1.25" />
    <path d="M8 2.5V5M6 9h.01M10 9h.01" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
  </svg>
);

const check = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M4 8.5l2.5 2.5L12 5.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

export default function SubagentDemo() {
  return (
    <Subagent.Root defaultOpen status="running" style={{ width: "100%", maxWidth: 420 }}>
      <Subagent.Trigger icon={bot} description="18s">
        Running the research agent
      </Subagent.Trigger>
      <Subagent.Content>
        <Subagent.Prompt>Find where the image cache key is built and what it depends on.</Subagent.Prompt>
        <Subagent.Meta>
          <Badge>Fast model</Badge>
          <Badge>Read only</Badge>
        </Subagent.Meta>
        <Subagent.Steps>
          <Subagent.Step icon={check}>Searched for cacheKey in scripts</Subagent.Step>
          <Subagent.Step icon={check}>Read scripts/optimize-images.ts</Subagent.Step>
          <Subagent.Step icon={<Spinner size="small" />} status="running">
            Reading next.config.ts
          </Subagent.Step>
        </Subagent.Steps>
      </Subagent.Content>
    </Subagent.Root>
  );
}
```

## Foundations

The rest of the Geist style, as a skill: https://replicas.raphaelsalaja.com/skills/geist/SKILL.md