# Shopify Card

A surface that groups related content and actions.

Build a Card 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: Measured from Shopify admin Add product form, main section card. Padding is ignored because the admin card is padding-none and its rows pad themselves. The title uses the measured heading type.

## Tokens

| Token | Light | Dark |
| --- | --- | --- |
| `--p-border-radius-container` | `1.25rem` | `1.25rem` |
| `--p-border-radius-corner-shape` | `superellipse(1.333)` | `superellipse(1.333)` |
| `--p-color-bg-surface` | `#fff` | `#1a1a1a` |
| `--p-color-text` | `#101010` | `#eee` |
| `--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-letter-spacing-heading-large` | `-.01em` | `-.01em` |
| `--p-font-line-height-body-medium` | `1.25rem` | `1.25rem` |
| `--p-font-line-height-heading-large` | `1.375rem` | `1.375rem` |
| `--p-font-size-body-medium` | `.8125rem` | `.8125rem` |
| `--p-font-size-heading-large` | `.9375rem` | `.9375rem` |
| `--p-font-weight-heading-large` | `500` | `500` |
| `--p-shadow-section` | `0rem 0rem .125rem 0rem rgba(0,0,0,.24), 0rem .125rem .75rem 0rem #00000005, 0rem .25rem 1rem 0rem #00000005, 0rem .25rem 3rem 0rem #00000005` | `0rem 0rem 0rem .0625rem #dcdcdc24, 0rem .0625rem 0rem 0rem #ffffff08, 0rem .15625rem .03125rem 0rem #00000057, 0rem .25rem .25rem -.09375rem #0000001f, 0rem .3125rem .3125rem -.15625rem #0000003d` |
| `--p-space-050` | `.125rem` | `.125rem` |
| `--p-space-200` | `.5rem` | `.5rem` |
| `--p-space-300` | `.75rem` | `.75rem` |
| `--p-space-400` | `1rem` | `1rem` |

## 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-card {
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--p-space-300);
    padding: var(--p-space-400);
    border-radius: var(--p-border-radius-container);
    corner-shape: var(--p-border-radius-corner-shape);
    background-color: var(--p-color-bg-surface);
    box-shadow: var(--p-shadow-section);
    color: var(--p-color-text);
    font-family: var(--p-font-family-sans);
    font-size: var(--p-font-size-body-medium);
    line-height: var(--p-font-line-height-body-medium);
    letter-spacing: var(--p-font-letter-spacing-body-medium);
  }

  .ui-card-header {
    display: flex;
    flex-direction: column;
    gap: var(--p-space-050);
  }

  .ui-card-title {
    margin: 0;
    color: var(--p-color-text);
    font-size: var(--p-font-size-heading-large);
    font-weight: var(--p-font-weight-heading-large);
    line-height: var(--p-font-line-height-heading-large);
    letter-spacing: var(--p-font-letter-spacing-heading-large);
  }

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

  .ui-card-content {
    color: var(--p-color-text);
  }

  .ui-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--p-space-200);
  }
}
```

## Structure

How Replicas assembles it on Base UI.

```tsx
import type { ComponentProps } from "react";
import { join } from "./utils";

function Root({ className, variant, ...props }: ComponentProps<"div"> & { variant?: string }) {
  return <div className={join("ui-card", className)} data-variant={variant} {...props} />;
}

const part = (name: string) =>
  function Part({ className, ...props }: ComponentProps<"div">) {
    return <div className={join(`ui-card-${name}`, className)} {...props} />;
  };

function Title({ className, ...props }: ComponentProps<"h3">) {
  return <h3 className={join("ui-card-title", className)} {...props} />;
}

function Description({ className, ...props }: ComponentProps<"p">) {
  return <p className={join("ui-card-description", className)} {...props} />;
}

export const Card = {
  Root,
  Header: part("header"),
  Title,
  Description,
  Content: part("content"),
  Footer: part("footer"),
};
```

## Example

```tsx
import { Button, Card } from "@replicas/ui";

export default function CardDemo() {
  return (
    <Card.Root style={{ width: 320 }}>
      <Card.Header>
        <Card.Title>Mobile App</Card.Title>
        <Card.Description>Ship the redesigned onboarding flow.</Card.Description>
      </Card.Header>
      <Card.Content>12 of 18 tasks done</Card.Content>
      <Card.Footer>
        <Button size="small">View project</Button>
      </Card.Footer>
    </Card.Root>
  );
}
```

## Foundations

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