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

const terminal = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M3.5 5l3 3-3 3M8 11h4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

export default function ToolDemo() {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: 4, width: "100%", maxWidth: 420 }}>
      <Tool.Root defaultOpen>
        <Tool.Trigger icon={terminal}>Ran node --version</Tool.Trigger>
        <Tool.Content>
          <Tool.Input>{`{ "command": "node --version" }`}</Tool.Input>
          <Tool.Output>v24.18.0</Tool.Output>
        </Tool.Content>
      </Tool.Root>
      <Tool.Root status="error">
        <Tool.Trigger icon={terminal}>Failed to run pnpm --version</Tool.Trigger>
        <Tool.Content>
          <Tool.Output error>command not found: pnpm</Tool.Output>
        </Tool.Content>
      </Tool.Root>
      <Tool.Root status="running">
        <Tool.Trigger icon={<Spinner size="small" />}>Running npm test</Tool.Trigger>
      </Tool.Root>
    </div>
  );
}

Prompt

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

Show Prompt
# Cursor Tool

A tool call the agent makes, from input to output.

Build a Tool in this project that looks and behaves like Cursor's. Measured from the running Cursor app (cursor.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 light screenshots of tool call rows in the Cursor agent transcript. No dark reference. No fidelity reference has been saved yet.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--cursor-text-danger` | `oklch(0.5527 0.199 23.57)` | `oklch(0.628 0.194 8.387)` |
| `--cursor-stroke-tertiary` | `color-mix(in srgb, var(--cursor-base) 8%, transparent)` | `color-mix(in srgb, var(--cursor-base) 8%, transparent)` |
| `--cursor-bg-editor` | `oklch(1 0 0)` | `oklch(0.209 0 0)` |
| `--cursor-shimmer-base` | `color-mix(in srgb, var(--cursor-base) 60%, transparent)` | `color-mix(in srgb, var(--cursor-base) 60%, transparent)` |
| `--cursor-shimmer-highlight` | `oklch(0.2264 0 0)` | `oklch(0.955 0 0)` |
| `--text-secondary` | `color-mix(in srgb, var(--cursor-base) 74%, transparent)` | `color-mix(in srgb, var(--cursor-base) 74%, transparent)` |
| `--text-tertiary` | `color-mix(in srgb, var(--cursor-base) 60%, transparent)` | `color-mix(in srgb, var(--cursor-base) 60%, transparent)` |
| `--text-quaternary` | `color-mix(in srgb, var(--cursor-base) 36%, transparent)` | `color-mix(in srgb, var(--cursor-base) 36%, transparent)` |
| `--focus-ring` | `oklch(0.5435 0.1768 255.46)` | `oklch(0.681 0.131 252.629)` |
| `--cursor-line-height-sm` | `16px` | `16px` |
| `--cursor-line-height-base` | `18px` | `18px` |
| `--cursor-line-height-lg` | `22px` | `22px` |
| `--font-regular` | `"SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif` | `"SF Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif` |
| `--font-monospace` | `"SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace` | `"SF Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace` |
| `--font-size-mini` | `0.75rem` | `0.75rem` |
| `--font-size-small` | `0.8125rem` | `0.8125rem` |
| `--font-size-regular` | `0.875rem` | `0.875rem` |
| `--radius-control` | `8px` | `8px` |
| `--cursor-duration-fast` | `0.1s` | `0.1s` |
| `--cursor-duration-slow` | `0.2s` | `0.2s` |
| `--cursor-duration-2s` | `2s` | `2s` |
| `--ease` | `ease` | `ease` |
| `--ease-linear` | `linear` | `linear` |
| `--ease-sharp` | `cubic-bezier(0.165, 0.84, 0.44, 1)` | `cubic-bezier(0.165, 0.84, 0.44, 1)` |

## CSS

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

```css
[data-style="cursor"] {
  .ui-tool {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-family: var(--font-regular);
    font-size: var(--font-size-regular);
    line-height: var(--cursor-line-height-lg);
    -webkit-font-smoothing: antialiased;
  }

  .ui-tool-trigger {
    display: inline-flex;
    align-items: center;
    align-self: flex-start;
    gap: 4px;
    max-width: 100%;
    min-width: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: none;
    color: var(--text-tertiary);
    font: inherit;
    text-align: start;
    cursor: pointer;
    outline: none;
    transition: color var(--cursor-duration-fast) var(--ease);

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

    @media (hover: hover) {
      &:hover {
        color: var(--text-secondary);
      }

      &:hover .ui-tool-description {
        color: var(--text-tertiary);
      }

      &:hover .ui-tool-chevron {
        opacity: 1;
      }
    }

    &[data-panel-open] .ui-tool-chevron {
      opacity: 1;
      transform: rotate(90deg);
    }
  }

  .ui-tool-icon {
    display: none;
  }

  .ui-tool-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ui-tool-description {
    flex-shrink: 0;
    color: var(--text-quaternary);
    white-space: nowrap;
    transition: color var(--cursor-duration-fast) var(--ease);
  }

  .ui-tool-chevron {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    color: var(--text-tertiary);
    opacity: 0;
    transition:
      opacity var(--cursor-duration-fast) var(--ease),
      transform var(--cursor-duration-slow) var(--ease-sharp);
  }

  .ui-tool[data-status="running"] .ui-tool-title {
    background-image: linear-gradient(
      90deg,
      var(--cursor-shimmer-base) 0%,
      var(--cursor-shimmer-base) 25%,
      var(--cursor-shimmer-highlight) 60%,
      var(--cursor-shimmer-base) 75%,
      var(--cursor-shimmer-base) 100%
    );
    background-size: 200% 100%;
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
    animation: cursor-tool-shimmer var(--cursor-duration-2s) var(--ease-linear) infinite;

    @media (prefers-reduced-motion: reduce) {
      animation: none;
      background-image: none;
      color: var(--text-tertiary);
      -webkit-text-fill-color: currentColor;
    }
  }

  .ui-tool[data-status="error"] .ui-tool-title {
    color: color-mix(in srgb, var(--cursor-text-danger) 78%, transparent);
  }

  .ui-tool-content {
    overflow: hidden;
    height: var(--collapsible-panel-height);
    transition: height var(--cursor-duration-slow) var(--ease-sharp);

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

    @media (prefers-reduced-motion: reduce) {
      transition: none;
    }
  }

  .ui-tool-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    border: 1px solid var(--cursor-stroke-tertiary);
    border-block-width: 0;
    background-color: var(--cursor-bg-editor);

    &:first-child {
      margin-top: 4px;
      border-top-width: 1px;
      border-start-start-radius: var(--radius-control);
      border-start-end-radius: var(--radius-control);
    }

    &:last-child {
      margin-bottom: 2px;
      border-bottom-width: 1px;
      border-end-start-radius: var(--radius-control);
      border-end-end-radius: var(--radius-control);
    }

    & + & {
      border-top-width: 1px;
    }
  }

  .ui-tool-label {
    margin: 0;
    padding: 6px 10px 0;
    color: var(--text-quaternary);
    font-size: var(--font-size-mini);
    line-height: var(--cursor-line-height-sm);
  }

  .ui-tool-code {
    max-height: min(480px, 60vh);
    margin: 0;
    padding: 2px 10px 6px;
    overflow: auto;
    color: var(--text-secondary);
    font-family: var(--font-monospace);
    font-size: var(--font-size-small);
    line-height: var(--cursor-line-height-base);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  .ui-tool-section[data-error] {
    .ui-tool-label,
    .ui-tool-code {
      color: var(--cursor-text-danger);
    }
  }
}

@keyframes cursor-tool-shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}
```

## 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-tool", 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-tool-trigger", className)} {...props}>
      {icon ? <span className="ui-tool-icon" aria-hidden>{icon}</span> : null}
      <span className="ui-tool-title">{children}</span>
      {description ? <span className="ui-tool-description">{description}</span> : null}
      <svg className="ui-tool-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-tool-content", className)} {...props} />;
}

type SectionProps = ComponentProps<"div"> & { label?: ReactNode };

function Input({ className, label = "Input", children, ...props }: SectionProps) {
  return (
    <div className={join("ui-tool-section", className)} {...props}>
      <p className="ui-tool-label">{label}</p>
      <pre className="ui-tool-code">{children}</pre>
    </div>
  );
}

function Output({ className, label, error = false, children, ...props }: SectionProps & { error?: boolean }) {
  return (
    <div className={join("ui-tool-section", className)} data-error={error || undefined} {...props}>
      <p className="ui-tool-label">{label ?? (error ? "Error" : "Output")}</p>
      <pre className="ui-tool-code">{children}</pre>
    </div>
  );
}

export const Tool = {
  Root,
  Trigger,
  Content,
  Input,
  Output,
};
```

## Example

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

const terminal = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M3.5 5l3 3-3 3M8 11h4.5" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

export default function ToolDemo() {
  return (
    <div style={{ display: "flex", flexDirection: "column", gap: 4, width: "100%", maxWidth: 420 }}>
      <Tool.Root defaultOpen>
        <Tool.Trigger icon={terminal}>Ran node --version</Tool.Trigger>
        <Tool.Content>
          <Tool.Input>{`{ "command": "node --version" }`}</Tool.Input>
          <Tool.Output>v24.18.0</Tool.Output>
        </Tool.Content>
      </Tool.Root>
      <Tool.Root status="error">
        <Tool.Trigger icon={terminal}>Failed to run pnpm --version</Tool.Trigger>
        <Tool.Content>
          <Tool.Output error>command not found: pnpm</Tool.Output>
        </Tool.Content>
      </Tool.Root>
      <Tool.Root status="running">
        <Tool.Trigger icon={<Spinner size="small" />}>Running npm test</Tool.Trigger>
      </Tool.Root>
    </div>
  );
}
```

## Foundations

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