import { ChainOfThought } from "@replicas/ui";

const search = (
  <svg viewBox="0 0 16 16" fill="none">
    <circle cx="7" cy="7" r="4.25" stroke="currentColor" strokeWidth="1.5" />
    <path d="M10.25 10.25L13 13" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
  </svg>
);

const file = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M4 2.5h5l3 3v8H4zM9 2.5v3h3" stroke="currentColor" strokeWidth="1.25" strokeLinejoin="round" />
  </svg>
);

const check = (
  <svg viewBox="0 0 16 16" fill="none">
    <circle cx="8" cy="8" r="6.25" stroke="currentColor" strokeWidth="1.25" />
    <path d="M5.5 8.25l1.75 1.75 3.25-3.5" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

export default function ChainOfThoughtDemo() {
  return (
    <ChainOfThought.Root defaultOpen style={{ width: "100%", maxWidth: 420 }}>
      <ChainOfThought.Trigger description="3 steps">Researched the image cache</ChainOfThought.Trigger>
      <ChainOfThought.Content>
        <ChainOfThought.Step icon={file} label="Read the build log" description="Image optimisation took 3m 48s." />
        <ChainOfThought.Step icon={search} label="Searched the web for image cache keys">
          <ChainOfThought.SearchResults>
            <ChainOfThought.SearchResult>nextjs.org</ChainOfThought.SearchResult>
            <ChainOfThought.SearchResult>github.com</ChainOfThought.SearchResult>
            <ChainOfThought.SearchResult>vercel.com</ChainOfThought.SearchResult>
          </ChainOfThought.SearchResults>
        </ChainOfThought.Step>
        <ChainOfThought.Step icon={check} label="The cache key includes the commit hash" />
      </ChainOfThought.Content>
    </ChainOfThought.Root>
  );
}

Prompt

Copy Prompt hands your agent everything it needs to build the Chain of Thought in the Family style: the measured tokens, the CSS and the structure.

Show Prompt
# Family Chain of Thought

A summary that expands into the steps an agent took.

Build a Chain of Thought in this project that looks and behaves like Family's. Measured from the running Family app (app.family.co). 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: Concept, not a real feature. Designed from Family's sidebar ghost rows, round icon tiles, badge pills and the OTP loading shimmer.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--body-color` | `#222` | `#fff` |
| `--body-color-muted` | `#17171780` | `#ffffff80` |
| `--icon-color` | `#94979e` | `#666` |
| `--icon-color-hover` | `#171717` | `#fff` |
| `--body-bg-secondary` | `#f9fafb` | `#272727` |
| `--body-bg-tertiary` | `#f0f2f4` | `#333` |
| `--focus-color` | `#007aff80` | `#007aff80` |
| `--input-background-secondary` | `#e8e8ea` | `#ffffff0f` |
| `--input-color` | `#171717` | `#fff` |
| `--input-placeholder` | `#17171733` | `#ffffff4d` |
| `--primary` | `#9896ff` | `#9896ff` |
| `--primary-200` | `#eaeaff` | `#eaeaff` |
| `--primary-600` | `#7a78cc` | `#7a78cc` |
| `--danger` | `#ff3b30` | `#ff3b30` |
| `--danger-100` | `#ffebea` | `#ffebea` |
| `--button-secondary-background` | `#f0f2f4` | `#333` |
| `--font-regular` | `"Family Inter", "Family Inter Fallback"` | `"Family Inter", "Family Inter Fallback"` |
| `--font-size-mini` | `0.8125rem` | `0.8125rem` |
| `--font-size-small` | `0.875rem` | `0.875rem` |
| `--font-weight-medium` | `500` | `500` |
| `--letter-spacing-small` | `-0.00563rem` | `-0.00563rem` |
| `--letter-spacing-regular` | `-0.00813rem` | `-0.00813rem` |
| `--radius-badge` | `0.375rem` | `0.375rem` |
| `--ease-snappy-out` | `cubic-bezier(0.19, 1, 0.22, 1)` | `cubic-bezier(0.19, 1, 0.22, 1)` |
| `--duration-control` | `0.1s` | `0.1s` |
| `--duration-icon` | `0.2s` | `0.2s` |
| `--duration-height` | `0.4s` | `0.4s` |
| `--ease-spring-snappy` | `linear(0, 0.053, 0.1882, 0.3525, 0.537, 0.6988, 0.8378, 0.9543, 1.0327, 1.0832, 1.111, 1.1179, 1.1108, 1.0956, 1.0762, 1.0544, 1.0354, 1.019, 1.0053, 0.9961, 0.9899, 0.9869, 0.9861, 0.9869, 0.9887, 0.991, 0.9936, 0.9958, 0.9979, 0.9994, 1.0005, 1.0012, 1.0015, 1.0016, 1.0015, 1.0013, 1.001, 1.0008, 1.0005, 1.0002, 1)` | `linear(0, 0.053, 0.1882, 0.3525, 0.537, 0.6988, 0.8378, 0.9543, 1.0327, 1.0832, 1.111, 1.1179, 1.1108, 1.0956, 1.0762, 1.0544, 1.0354, 1.019, 1.0053, 0.9961, 0.9899, 0.9869, 0.9861, 0.9869, 0.9887, 0.991, 0.9936, 0.9958, 0.9979, 0.9994, 1.0005, 1.0012, 1.0015, 1.0016, 1.0015, 1.0013, 1.001, 1.0008, 1.0005, 1.0002, 1)` |
| `--duration-spring-snappy` | `615ms` | `615ms` |

## CSS

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

```css
[data-style="family"] {
  .ui-chain-of-thought {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    font-family: var(--font-regular);
  }

  .ui-chain-of-thought-trigger {
    position: relative;
    isolation: isolate;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
    margin: 0 0 0 -0.625rem;
    padding: 0.4375rem 0.5rem 0.4375rem 0.625rem;
    border: 0;
    border-radius: 0.75rem;
    outline: none;
    background: none;
    color: var(--body-color-muted);
    font-family: inherit;
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    line-height: 1.125rem;
    letter-spacing: var(--letter-spacing-small);
    text-align: left;
    cursor: pointer;
    transition: color var(--duration-control);

    &::before {
      content: "";
      position: absolute;
      inset: 0;
      z-index: -1;
      border-radius: inherit;
      background: var(--body-bg-secondary);
      opacity: 0;
      transform: scale(0.75);
      transition:
        opacity var(--duration-icon),
        transform var(--duration-icon);
    }

    @media (hover: hover) {
      &:hover {
        color: var(--body-color);

        &::before {
          opacity: 1;
          transform: none;
          transition-duration: var(--duration-control);
        }
      }
    }

    &:active::before {
      transform: scale(0.97);
    }

    &[data-panel-open] {
      color: var(--body-color);
    }

    &:focus-visible {
      box-shadow: 0 0 0 2px var(--focus-color);
    }
  }

  .ui-chain-of-thought-icon {
    display: inline-flex;
    flex-shrink: 0;
    color: var(--icon-color);

    & svg {
      width: 1rem;
      height: 1rem;
    }
  }

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

  .ui-chain-of-thought-description {
    flex-shrink: 0;
    padding: 0.0625rem 0.375rem 0.125rem;
    border-radius: var(--radius-badge);
    background: var(--button-secondary-background);
    color: var(--body-color-muted);
    font-size: 0.75rem;
    font-weight: var(--font-weight-medium);
    line-height: 1rem;
    font-variant-numeric: tabular-nums;
  }

  .ui-chain-of-thought-chevron {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
    margin-left: -0.125rem;
    color: var(--icon-color);
    transition: transform var(--duration-spring-snappy) var(--ease-spring-snappy);

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

  .ui-chain-of-thought[data-status="running"] .ui-chain-of-thought-title {
    background-image: linear-gradient(
      90deg,
      var(--input-placeholder) 0,
      var(--input-placeholder) 2.5%,
      var(--input-color) 47.5%,
      var(--input-color) 52.5%,
      var(--input-placeholder) 97.5%,
      var(--input-placeholder) 100%
    );
    background-size: 200% 100%;
    background-clip: text;
    color: transparent;
    animation: family-chain-of-thought-shimmer 0.8s linear infinite;
  }

  .ui-chain-of-thought-content {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: var(--collapsible-panel-height);
    padding-top: 0.75rem;
    overflow: hidden;
    transition:
      height var(--duration-height) var(--ease-snappy-out),
      padding-top var(--duration-height) var(--ease-snappy-out),
      opacity var(--duration-icon);

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

  .ui-chain-of-thought-step {
    --chain-of-thought-step-fill: var(--button-secondary-background);
    --chain-of-thought-step-color: var(--icon-color-hover);

    position: relative;
    display: grid;
    grid-template-columns: 1.75rem minmax(0, 1fr);
    column-gap: 0.75rem;
    padding-bottom: 1rem;

    &:last-child {
      padding-bottom: 0;
    }

    &:not(:last-child)::before {
      content: "";
      position: absolute;
      top: 2.125rem;
      bottom: 0.375rem;
      left: calc(0.875rem - 0.75px);
      width: 1.5px;
      border-radius: 1px;
      background: var(--input-background-secondary);
    }

    [data-panel-open] + .ui-chain-of-thought-content > & {
      animation: family-chain-of-thought-step-enter var(--duration-spring-snappy) var(--ease-spring-snappy) both;
    }

    &:nth-child(2) {
      animation-delay: 60ms;
    }

    &:nth-child(3) {
      animation-delay: 120ms;
    }

    &:nth-child(n + 4) {
      animation-delay: 180ms;
    }
  }

  .ui-chain-of-thought-step[data-status="running"],
  .ui-chain-of-thought-step[data-status="active"] {
    --chain-of-thought-step-fill: var(--primary-200);
    --chain-of-thought-step-color: var(--primary-600);
  }

  .ui-chain-of-thought-step[data-status="error"] {
    --chain-of-thought-step-fill: var(--danger-100);
    --chain-of-thought-step-color: var(--danger);
  }

  .ui-chain-of-thought-step[data-status="pending"] {
    opacity: 0.5;
  }

  .ui-chain-of-thought-step-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--chain-of-thought-step-fill);
    color: var(--chain-of-thought-step-color);

    & svg {
      width: 0.875rem;
      height: 0.875rem;
    }

    & .ui-spinner {
      color: inherit;
    }
  }

  .ui-chain-of-thought-step-body {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    min-width: 0;
    padding-top: 0.25rem;
  }

  .ui-chain-of-thought-step-label {
    margin: 0;
    color: var(--body-color);
    font-size: var(--font-size-small);
    font-weight: var(--font-weight-medium);
    line-height: 1.25rem;
    letter-spacing: var(--letter-spacing-small);
  }

  .ui-chain-of-thought-step-description {
    margin: 0;
    color: var(--body-color-muted);
    font-size: var(--font-size-mini);
    line-height: 1.125rem;
    letter-spacing: var(--letter-spacing-regular);
  }

  .ui-chain-of-thought-results {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.375rem;
  }

  .ui-chain-of-thought-result {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem 0.1875rem;
    border-radius: var(--radius-badge);
    background: var(--body-bg-secondary);
    color: var(--body-color-muted);
    font-size: var(--font-size-mini);
    font-weight: var(--font-weight-medium);
    line-height: 1rem;
  }

  &[data-theme="dark"] .ui-chain-of-thought-step {
    &:not(:last-child)::before {
      background: var(--body-bg-tertiary);
    }
  }

  &[data-theme="dark"] .ui-chain-of-thought-step[data-status="running"],
  &[data-theme="dark"] .ui-chain-of-thought-step[data-status="active"] {
    --chain-of-thought-step-fill: color-mix(in srgb, var(--primary) 18%, transparent);
    --chain-of-thought-step-color: var(--primary);
  }

  &[data-theme="dark"] .ui-chain-of-thought-step[data-status="error"] {
    --chain-of-thought-step-fill: color-mix(in srgb, var(--danger) 18%, transparent);
  }

  &[data-theme="dark"] .ui-chain-of-thought-result {
    background: var(--body-bg-tertiary);
  }

  @media (prefers-reduced-motion: reduce) {
    .ui-chain-of-thought-trigger::before,
    .ui-chain-of-thought-chevron,
    .ui-chain-of-thought-content {
      transition: none;
    }

    [data-panel-open] + .ui-chain-of-thought-content > .ui-chain-of-thought-step {
      animation: none;
    }

    .ui-chain-of-thought[data-status="running"] .ui-chain-of-thought-title {
      background: none;
      color: var(--body-color-muted);
      animation: none;
    }
  }
}

@keyframes family-chain-of-thought-shimmer {
  from {
    background-position-x: 0%;
  }

  to {
    background-position-x: -200%;
  }
}

@keyframes family-chain-of-thought-step-enter {
  from {
    opacity: 0;
    transform: translateY(0.375rem);
  }

  to {
    opacity: 1;
    transform: none;
  }
}
```

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

type StepProps = Omit<ComponentProps<"div">, "title"> & {
  icon?: ReactNode;
  label: ReactNode;
  description?: ReactNode;
  status?: string;
};

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

function SearchResults({ className, ...props }: ComponentProps<"div">) {
  return <div className={join("ui-chain-of-thought-results", className)} {...props} />;
}

function SearchResult({ className, ...props }: ComponentProps<"span">) {
  return <span className={join("ui-chain-of-thought-result", className)} {...props} />;
}

export const ChainOfThought = {
  Root,
  Trigger,
  Content,
  Step,
  SearchResults,
  SearchResult,
};
```

## Example

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

const search = (
  <svg viewBox="0 0 16 16" fill="none">
    <circle cx="7" cy="7" r="4.25" stroke="currentColor" strokeWidth="1.5" />
    <path d="M10.25 10.25L13 13" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" />
  </svg>
);

const file = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M4 2.5h5l3 3v8H4zM9 2.5v3h3" stroke="currentColor" strokeWidth="1.25" strokeLinejoin="round" />
  </svg>
);

const check = (
  <svg viewBox="0 0 16 16" fill="none">
    <circle cx="8" cy="8" r="6.25" stroke="currentColor" strokeWidth="1.25" />
    <path d="M5.5 8.25l1.75 1.75 3.25-3.5" stroke="currentColor" strokeWidth="1.25" strokeLinecap="round" strokeLinejoin="round" />
  </svg>
);

export default function ChainOfThoughtDemo() {
  return (
    <ChainOfThought.Root defaultOpen style={{ width: "100%", maxWidth: 420 }}>
      <ChainOfThought.Trigger description="3 steps">Researched the image cache</ChainOfThought.Trigger>
      <ChainOfThought.Content>
        <ChainOfThought.Step icon={file} label="Read the build log" description="Image optimisation took 3m 48s." />
        <ChainOfThought.Step icon={search} label="Searched the web for image cache keys">
          <ChainOfThought.SearchResults>
            <ChainOfThought.SearchResult>nextjs.org</ChainOfThought.SearchResult>
            <ChainOfThought.SearchResult>github.com</ChainOfThought.SearchResult>
            <ChainOfThought.SearchResult>vercel.com</ChainOfThought.SearchResult>
          </ChainOfThought.SearchResults>
        </ChainOfThought.Step>
        <ChainOfThought.Step icon={check} label="The cache key includes the commit hash" />
      </ChainOfThought.Content>
    </ChainOfThought.Root>
  );
}
```

## Foundations

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