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

const page = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M4 1.75h5.5L12.25 4.5v9.75H4z" stroke="currentColor" strokeWidth="1.25" strokeLinejoin="round" />
    <path d="M9.25 1.75V4.75h3" stroke="currentColor" strokeWidth="1.25" strokeLinejoin="round" />
  </svg>
);

export default function InlineCitationDemo() {
  return (
    <p style={{ maxWidth: 460, margin: 0, color: "var(--text-secondary)", lineHeight: 1.6 }}>
      CI installs with a frozen lockfile, so{" "}
      <InlineCitation.Root>
        <InlineCitation.Text>the install stops when package.json and the lockfile disagree</InlineCitation.Text>{" "}
        <InlineCitation.Trigger href="https://pnpm.io/cli/install" icon={page}>
          pnpm.io
        </InlineCitation.Trigger>
        <InlineCitation.Popup>
          <InlineCitation.Source
            url="https://pnpm.io/cli/install"
            title="pnpm install"
            description="In CI, installation fails if the lockfile needs updating."
          />
        </InlineCitation.Popup>
      </InlineCitation.Root>
      . Run the install locally and commit the lockfile.
    </p>
  );
}

Prompt

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

Show Prompt
# Shopify Inline Citation

A source in the sentence that opens on hover.

Build a Inline Citation in this project that looks and behaves like Shopify's. Measured from the running Shopify app (admin.shopify.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 Shopify admin Sidekick tag link and the composer menu surface. The chip is the Sidekick tag link, shortened to sit in a line of text, with a 12px secondary icon. The popup uses the menu surface and spring. No answer with citations was seen live.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--p-border-radius-100` | `.25rem` | `.25rem` |
| `--p-border-radius-200` | `.5rem` | `.5rem` |
| `--p-border-width-025` | `.0625rem` | `.0625rem` |
| `--p-border-width-050` | `.125rem` | `.125rem` |
| `--p-color-bg-surface` | `#fff` | `#1a1a1a` |
| `--p-color-border` | `rgba(221,221,221,1)` | `#ffffff17` |
| `--p-color-border-focus` | `rgba(80,131,240,1)` | `#97adff` |
| `--p-color-border-tertiary` | `rgba(192,192,192,1)` | `#ffffff2e` |
| `--p-color-icon-secondary` | `#606060` | `#aaa` |
| `--p-color-text` | `#101010` | `#eee` |
| `--p-color-text-link` | `rgba(22,80,208,1)` | `#c5d0ff` |
| `--p-color-text-link-hover` | `rgba(19,71,185,1)` | `#d5dcff` |
| `--p-color-text-secondary` | `rgba(74,74,74,1)` | `#aaa` |
| `--p-font-family-sans` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` | `"ShopifyInter", "Noto Sans Arabic", "Noto Sans Hebrew", ui-sans-serif, system-ui, sans-serif` |
| `--p-font-letter-spacing-body-medium` | `-.01em` | `-.01em` |
| `--p-font-line-height-body-small` | `1.125rem` | `1.125rem` |
| `--p-font-size-300` | `.75rem` | `.75rem` |
| `--p-font-size-body-small` | `.75rem` | `.75rem` |
| `--p-font-weight-regular` | `400` | `400` |
| `--p-font-weight-semibold` | `600` | `600` |
| `--p-height-500` | `1.25rem` | `1.25rem` |
| `--p-motion-duration-150` | `150ms` | `150ms` |
| `--p-motion-ease` | `cubic-bezier(.25, .1, .25, 1)` | `cubic-bezier(.25, .1, .25, 1)` |
| `--p-space-025` | `.0625rem` | `.0625rem` |
| `--p-space-050` | `.125rem` | `.125rem` |
| `--p-space-100` | `.25rem` | `.25rem` |
| `--p-space-150` | `.375rem` | `.375rem` |
| `--p-space-200` | `.5rem` | `.5rem` |
| `--p-space-300` | `.75rem` | `.75rem` |
| `--p-border-radius-300` | `.75rem` | `.75rem` |
| `--p-font-size-275` | `.6875rem` | `.6875rem` |
| `--p-font-size-325` | `.8125rem` | `.8125rem` |
| `--p-font-line-height-400` | `1rem` | `1rem` |
| `--p-font-line-height-500` | `1.25rem` | `1.25rem` |
| `--p-color-bg-fill-secondary` | `#ebebeb` | `#373737` |
| `--p-color-bg-fill-secondary-hover` | `#ddd` | `#414141` |
| `--p-shadow-300` | `0rem .5rem 1.5rem -.5rem #00000047, 0rem .5rem 1rem -.25rem #0000000d, 0rem .1875rem .375rem 0rem #0000000d, 0rem .125rem .25rem 0rem #0000000d, 0rem .0625rem .125rem 0rem #0000000d, 0rem 0rem 0rem .0625rem #0000000f` | `0rem 0rem 0rem .0625rem #dcdcdc2e, 0rem .0625rem .125rem 0rem #00000026, 0rem .1875rem .375rem -.3125rem #00000026, 0rem .5rem 1.5rem -.5rem #000000d6` |
| `--sidekick-disclosure-glyph` | `.8125rem` | `.8125rem` |
| `--ease-sidekick-spring` | `cubic-bezier(.34, 2, .64, 1)` | `cubic-bezier(.34, 2, .64, 1)` |
| `--duration-sidekick-popover` | `200ms` | `200ms` |
| `--duration-sidekick-popover-exit` | `150ms` | `150ms` |

## CSS

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

```css
[data-style="shopify"] {
  .ui-inline-citation-text {
    text-decoration: underline dotted;
    text-decoration-color: var(--p-color-border-tertiary);
    text-decoration-thickness: var(--p-border-width-025);
    text-underline-offset: .1875rem;
  }

  .ui-inline-citation-trigger {
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    height: var(--p-height-500);
    padding: 0 var(--p-space-150);
    border-radius: var(--p-border-radius-200);
    background-color: var(--p-color-bg-fill-secondary);
    color: var(--p-color-text);
    font-size: var(--p-font-size-275);
    font-weight: var(--p-font-weight-regular);
    line-height: var(--p-font-line-height-400);
    letter-spacing: normal;
    text-decoration: none;
    vertical-align: .0625rem;
    outline: none;
    cursor: pointer;
    transition: background-color var(--p-motion-duration-150) var(--p-motion-ease);

    &:focus-visible {
      outline: var(--p-border-width-050) solid var(--p-color-border-focus);
      outline-offset: var(--p-space-025);
    }

    @media (hover: hover) {
      &:hover {
        background-color: var(--p-color-bg-fill-secondary-hover);
      }
    }

    &[data-popup-open] {
      background-color: var(--p-color-bg-fill-secondary-hover);
    }
  }

  .ui-inline-citation-trigger-icon {
    display: flex;
    flex-shrink: 0;
    margin-inline-end: var(--p-space-100);
    color: var(--p-color-icon-secondary);

    & :is(svg, img) {
      width: var(--sidekick-disclosure-glyph);
      height: var(--sidekick-disclosure-glyph);
    }
  }

  .ui-inline-citation-positioner {
    outline: none;
  }

  .ui-inline-citation-popup {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--p-space-200);
    width: 17.5rem;
    max-width: var(--available-width);
    padding: var(--p-space-300);
    border-radius: var(--p-border-radius-300);
    background-color: var(--p-color-bg-surface);
    box-shadow: var(--p-shadow-300);
    color: var(--p-color-text);
    font-family: var(--p-font-family-sans);
    font-size: var(--p-font-size-325);
    line-height: var(--p-font-line-height-500);
    letter-spacing: var(--p-font-letter-spacing-body-medium);
    outline: none;
    transform-origin: var(--transform-origin);
    transition:
      opacity var(--duration-sidekick-popover) var(--p-motion-ease),
      transform var(--duration-sidekick-popover) var(--ease-sidekick-spring);

    &[data-starting-style],
    &[data-ending-style] {
      opacity: 0;
      transform: scale(.95);
    }

    &[data-ending-style] {
      transition:
        opacity var(--duration-sidekick-popover-exit) var(--p-motion-ease),
        transform var(--duration-sidekick-popover-exit) var(--p-motion-ease);
    }
  }

  .ui-inline-citation-source {
    display: flex;
    flex-direction: column;
    gap: var(--p-space-050);
  }

  .ui-inline-citation-source .ui-inline-citation-link {
    display: inline-flex;
    align-items: center;
    gap: var(--p-space-150);
    align-self: flex-start;
    border-radius: var(--p-border-radius-100);
    color: var(--p-color-text-link);
    font-size: var(--p-font-size-300);
    line-height: var(--p-font-line-height-400);
    letter-spacing: normal;
    text-decoration: none;
    outline: none;

    &:focus-visible {
      outline: var(--p-border-width-050) solid var(--p-color-border-focus);
      outline-offset: var(--p-space-025);
    }

    @media (hover: hover) {
      &:hover {
        color: var(--p-color-text-link-hover);
        text-decoration: underline;
      }
    }
  }

  .ui-inline-citation-icon {
    display: flex;

    & :is(svg, img) {
      width: var(--p-space-300);
      height: var(--p-space-300);
      border-radius: var(--p-border-radius-100);
    }
  }

  .ui-inline-citation-hint {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .ui-inline-citation-title {
    margin: 0;
    color: var(--p-color-text);
    font-weight: var(--p-font-weight-semibold);
  }

  .ui-inline-citation-description {
    margin: 0;
    color: var(--p-color-text-secondary);
  }

  .ui-inline-citation-quote {
    margin: 0;
    padding-inline-start: var(--p-space-300);
    border-inline-start: var(--p-border-width-050) solid var(--p-color-border);
    color: var(--p-color-text-secondary);
    font-size: var(--p-font-size-body-small);
    line-height: var(--p-font-line-height-body-small);
  }

  @media (prefers-reduced-motion: reduce) {
    .ui-inline-citation-popup,
    .ui-inline-citation-popup[data-ending-style],
    .ui-inline-citation-trigger {
      transition: none;
    }
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import { PreviewCard as BasePreviewCard } from "@base-ui/react/preview-card";
import type { ComponentProps, ReactNode } from "react";
import { usePortalContainer } from "./portal";
import { join } from "./utils";

function Text({ className, ...props }: ComponentProps<"span">) {
  return <span className={join("ui-inline-citation-text", className)} {...props} />;
}

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

function Trigger({ className, delay = 100, icon, children, ...props }: TriggerProps) {
  return (
    <BasePreviewCard.Trigger className={join("ui-inline-citation-trigger", className)} delay={delay} {...props}>
      {icon ? (
        <span className="ui-inline-citation-trigger-icon" aria-hidden>
          {icon}
        </span>
      ) : null}
      {children}
    </BasePreviewCard.Trigger>
  );
}

type PopupProps = Omit<BasePreviewCard.Popup.Props, "className"> & {
  className?: string;
  side?: BasePreviewCard.Positioner.Props["side"];
  align?: BasePreviewCard.Positioner.Props["align"];
  sideOffset?: number;
};

function Popup({ className, side = "top", align = "center", sideOffset = 6, ...props }: PopupProps) {
  return (
    <BasePreviewCard.Portal container={usePortalContainer()}>
      <BasePreviewCard.Positioner className="ui-inline-citation-positioner" side={side} align={align} sideOffset={sideOffset}>
        <BasePreviewCard.Popup className={join("ui-inline-citation-popup", className)} {...props} />
      </BasePreviewCard.Positioner>
    </BasePreviewCard.Portal>
  );
}

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

function Source({ className, title, url, icon, description, children, ...props }: SourceProps) {
  return (
    <div className={join("ui-inline-citation-source", className)} {...props}>
      <a className="ui-inline-citation-link" href={url} target="_blank" rel="noreferrer">
        {icon ? <span className="ui-inline-citation-icon" aria-hidden>{icon}</span> : null}
        <span className="ui-inline-citation-host">{new URL(url).hostname.replace(/^www\./, "")}</span>
        <span className="ui-inline-citation-hint">(opens in a new tab)</span>
      </a>
      <p className="ui-inline-citation-title">{title}</p>
      {description ? <p className="ui-inline-citation-description">{description}</p> : null}
      {children}
    </div>
  );
}

function Quote({ className, ...props }: ComponentProps<"blockquote">) {
  return <blockquote className={join("ui-inline-citation-quote", className)} {...props} />;
}

export const InlineCitation = {
  Root: BasePreviewCard.Root,
  Text,
  Trigger,
  Popup,
  Source,
  Quote,
};
```

## Example

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

const page = (
  <svg viewBox="0 0 16 16" fill="none">
    <path d="M4 1.75h5.5L12.25 4.5v9.75H4z" stroke="currentColor" strokeWidth="1.25" strokeLinejoin="round" />
    <path d="M9.25 1.75V4.75h3" stroke="currentColor" strokeWidth="1.25" strokeLinejoin="round" />
  </svg>
);

export default function InlineCitationDemo() {
  return (
    <p style={{ maxWidth: 460, margin: 0, color: "var(--text-secondary)", lineHeight: 1.6 }}>
      CI installs with a frozen lockfile, so{" "}
      <InlineCitation.Root>
        <InlineCitation.Text>the install stops when package.json and the lockfile disagree</InlineCitation.Text>{" "}
        <InlineCitation.Trigger href="https://pnpm.io/cli/install" icon={page}>
          pnpm.io
        </InlineCitation.Trigger>
        <InlineCitation.Popup>
          <InlineCitation.Source
            url="https://pnpm.io/cli/install"
            title="pnpm install"
            description="In CI, installation fails if the lockfile needs updating."
          />
        </InlineCitation.Popup>
      </InlineCitation.Root>
      . Run the install locally and commit the lockfile.
    </p>
  );
}
```

## Foundations

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