{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "card",
  "title": "Card",
  "description": "A surface that groups one thing's content: a media slot across the top, a title with a description and an action, a body, and a footer.",
  "registryDependencies": [
    "@ouro/heading",
    "@ouro/lib-appearance-hints",
    "@ouro/lib-class-name-check",
    "@ouro/lib-cn",
    "@ouro/lib-env",
    "@ouro/lib-router-link",
    "@ouro/lib-stretched-link",
    "@ouro/lib-use-dev-messages",
    "@ouro/text"
  ],
  "files": [
    {
      "path": "registry/ouro/components/ouro/card/card.tsx",
      "content": "\"use client\";\n\nimport { createElement, useId, type HTMLAttributes, type JSX, type ReactNode, type Ref } from \"react\";\nimport { radiusFor } from \"@/registry/ouro/lib/ouro/appearance-hints\";\nimport { useAppearanceClassNameCheck } from \"@/registry/ouro/lib/ouro/class-name-check\";\nimport { cn } from \"@/registry/ouro/lib/ouro/cn\";\nimport { RouterLink, safeRel } from \"@/registry/ouro/lib/ouro/router-link\";\nimport { raiseControlsClass, stretchedLinkClass } from \"@/registry/ouro/lib/ouro/stretched-link\";\nimport { useDevWarnings } from \"@/registry/ouro/lib/ouro/use-dev-messages\";\nimport { Heading } from \"@/registry/ouro/components/ouro/text/heading\";\nimport { Text } from \"@/registry/ouro/components/ouro/text/text\";\n\n/**\n * The props every Card takes, with or without `href`.\n *\n * @claim \"The props every Card takes, with\" registry/ouro/components/ouro/card/card.tsx verify:fileLine(registry/ouro/components/ouro/card/card.test-d.ts, /expectTypeOf<\\{ href: \"\\/cookbooks\\/1\" \\}>\\(\\)\\.toExtend<CardProps>\\(\\)/)\n */\nexport interface CardOwnProps {\n  /** The card's title, as a heading. With `href` it is the link's text, so a linked card needs one. */\n  title?: ReactNode;\n  /**\n   * Makes the whole card one link, with one tab stop, named by its `title`. Internal paths\n   * go through `OuroProvider`'s `linkComponent`, as with `Link`. Controls in any slot (a\n   * share button over the `media`, a link in the body, a button in `action` or `footer`)\n   * stay their own tab stops and take their own clicks and taps.\n   */\n  href?: string | undefined;\n  /** With `href`: opens the link in a new tab, safely, and tells screen readers so. */\n  external?: boolean | undefined;\n  /** With `href`: a ref to the link's `<a>`, to move focus to it (as a \"Show more\" does for the first new card). */\n  linkRef?: Ref<HTMLAnchorElement> | undefined;\n  /** A sentence or a count under the title: \"12 recipes\". */\n  description?: ReactNode;\n  /**\n   * With `href` and `media`: the media's pictures (`img` and `video`) grow by 3% while the pointer\n   * rests on the card or keyboard focus is in it, over `--ouro-duration-base` on\n   * `--ouro-ease-out`, inside the media's frame, so the card's shape and size never change. With\n   * reduced motion they hold still. Nothing fades.\n   * @claim \"the media's pictures (`img` and `video`)\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card with href, zoomMedia and revealDescription > grows the media's picture 3% inside its frame while the pointer rests on the card or keyboard focus is in it, and not with reduced motion)\n   */\n  zoomMedia?: boolean | undefined;\n  /**\n   * With `href` and `description`: on a screen with a mouse the description waits, transparent\n   * and keeping its room, until the pointer rests on the card or keyboard focus is in it, then\n   * fades in. On a touch screen it shows from the start. Screen readers read it while it is\n   * transparent too, and the link names it as its description, so a person who tabs to the card\n   * hears it.\n   * @claim \"Screen readers read it while it\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card with href, zoomMedia and revealDescription > shows the description on hover or keyboard focus, keeping its room, and names it as the link's description)\n   * @claim \"On a touch screen it shows\" registry/ouro/components/ouro/card/card.touch.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.touch.test.tsx::shows a revealDescription card's description on a touch screen)\n   * @claim \"on a screen with a mouse\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card with href, zoomMedia and revealDescription > shows the description on hover or keyboard focus, keeping its room, and names it as the link's description)\n   */\n  revealDescription?: boolean | undefined;\n  /**\n   * One control beside the title, at the end: a menu or a share button. With `href` it\n   * stays its own tab stop, above the link.\n   */\n  action?: ReactNode;\n  /**\n   * An image or video across the top, edge to edge: usually an `AspectRatio` around an\n   * `<img>`, so the card keeps its shape while the image loads.\n   */\n  media?: ReactNode;\n  /** The card's body, under the title. */\n  children?: ReactNode;\n  /** A row at the bottom for buttons or a timestamp. With `href`, controls here stay their own tab stops. */\n  footer?: ReactNode;\n  /**\n   * Below this breakpoint the `action` drops under the title and description, as in a\n   * settings panel on a phone. Without it the action stays beside the title at every width.\n   * @claim \"Without it the action stays beside\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card > keeps the action beside the title on a phone without stackBelow)\n   */\n  stackBelow?: \"sm\" | \"md\" | (string & { 'Use \"sm\" (640px) or \"md\" (768px)': never }) | undefined;\n  /**\n   * The title's heading level. Pick the level below the section the card sits in.\n   * @default 3\n   */\n  headingLevel?: 2 | 3 | 4 | 5 | 6 | (number & { \"Use 2 to 6, one below the section's heading\": never }) | undefined;\n  /**\n   * `outline` is a bordered surface in the theme's card colors; `plain` has no frame or\n   * padding, for a card's structure inside a surface of your own.\n   * @default \"outline\"\n   * @claim \"`outline` is a bordered surface in\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card > is a bordered surface in the card colors, with 24px padding)\n   * @claim \"`outline` is a bordered surface in\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card > has no frame or padding with variant=plain)\n   */\n  variant?: \"outline\" | \"plain\" | (string & { 'Use \"outline\" or \"plain\"; elevation comes from the theme': never }) | undefined;\n  /**\n   * Padding: `md` is 24px, `sm` 16px for dense grids. @default \"md\"\n   *\n   * @claim \"Padding: `md` is 24px, `sm` 16px\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card > is a bordered surface in the card colors, with 24px padding)\n   * @claim \"Padding: `md` is 24px, `sm` 16px\" registry/ouro/components/ouro/card/card.test.tsx verify:testExists(registry/ouro/components/ouro/card/card.test.tsx::Card > is tighter with size=sm)\n   */\n  size?: \"md\" | \"sm\" | (string & { 'Use \"md\" or \"sm\"': never }) | undefined;\n  /**\n   * The element to render: `li` in a list of cards, `article` for a self-contained item.\n   * @default \"div\"\n   */\n  as?: \"div\" | \"article\" | \"section\" | \"li\" | (string & { 'Use \"div\", \"article\", \"section\" or \"li\"; for a link use href': never }) | undefined;\n  /** Layout only: margins, width, grid placement (`col-span-2`). Appearance classes warn in development; use `variant`. */\n  className?: string | undefined;\n  ref?: Ref<HTMLElement> | undefined;\n\n  /** Not a prop. Ouro UI uses `description`: `<Card description=\"12 recipes\">`. */\n  subtitle?: { 'Use <Card description=\"12 recipes\">': never };\n  /** Not a prop. Ouro UI uses `media`: `<Card media={<AspectRatio ratio={4 / 3}><img … /></AspectRatio>}>`. */\n  image?: { \"Use <Card media={<AspectRatio ratio={4 / 3}>...</AspectRatio>}>\": never };\n  /** Not a prop. The header is `title`, `description` and `action`. */\n  header?: { 'Use <Card title=\"...\" description=\"...\" action={...}>': never };\n  /** Not a prop. Ouro UI uses `action` beside the title, or `footer` below the body. */\n  actions?: { \"Use <Card action={<Button>...</Button>}> or footer={...}\": never };\n  /** Not a prop. Ouro UI uses `href`, for router links too: `<Card href=\"/recipes/1\" title=\"…\">`. */\n  to?: { 'Use <Card href=\"/recipes/1\" title=\"...\">': never };\n  /** Not a prop. With `href` the whole card is a link: `<Card href=\"/recipes/1\" title=\"…\">`. */\n  asChild?: { 'Use <Card href=\"/recipes/1\" title=\"...\">': never };\n  /** Not a prop. A card with `href` is interactive; `zoomMedia` and `revealDescription` add hover and focus effects. */\n  interactive?: { \"Use <Card href=... zoomMedia revealDescription>\": never };\n}\n\n/**\n * Props for {@link Card}. With `href` the whole card is a link, named by its `title`. They\n * are one flat type, not a union on `href`: a union would drop the editor's hover docs on\n * `title` whenever another prop has a type error, so a link without a title is a\n * development message instead.\n */\nexport type CardProps = Omit<HTMLAttributes<HTMLElement>, keyof CardOwnProps> & CardOwnProps;\n\nconst elements = [\"div\", \"article\", \"section\", \"li\"] as const;\nconst levels = [2, 3, 4, 5, 6] as const;\n\nconst variants = {\n  // Where corner-shape is missing, the surface slot paints the background and border instead (see ouro-base.css).\n  outline:\n    \"rounded-ouro-xl border border-border bg-(--ouro-bg) border-(--ouro-bd) [--ouro-bg:var(--card)] [--ouro-bd:var(--border)] [--ouro-sq-w:1px] [--ouro-sq-r:calc(var(--radius)*var(--ouro-radius-scale,1)*1.4)] text-card-foreground shadow-(--shadow-xs)\",\n  plain: \"bg-transparent text-foreground\",\n} as const;\n\n// Vertical padding and gap on the root, inline padding on each section, so media can run edge to edge.\nconst rootSizes = {\n  outline: { md: \"gap-6 py-6\", sm: \"gap-4 py-4\" },\n  plain: { md: \"gap-4 py-0\", sm: \"gap-3 py-0\" },\n} as const;\nconst inset = { outline: { md: \"px-6\", sm: \"px-4\" }, plain: { md: \"px-0\", sm: \"px-0\" } } as const;\nconst mediaPull = { outline: { md: \"-mt-6\", sm: \"-mt-4\" }, plain: { md: \"rounded-ouro-xl\", sm: \"rounded-ouro-lg\" } } as const;\n\n// With href, the title's link stretches over the card (`stretchedLinkClass`), so the whole\n// card is one link with one tab stop, and every control in any slot (a share button over\n// the cover, a link in the body) sits above it (`raiseControlsClass`). A linked Item\n// inside is raised whole, so its own stretched link keeps covering its row.\nconst linkRoot =\n  \"press cursor-pointer outline-ring -outline-offset-2 has-[[data-card-link]:focus-visible]:outline-2 has-[[data-card-link]:focus-visible]:outline-solid \" +\n  \"motion-safe:has-[[data-card-link]:active]:scale-(--ouro-press-scale)\";\n\n// zoomMedia and revealDescription follow the card's hover with a mouse and keyboard focus anywhere in it.\n// Only pictures grow: a control over the media keeps its place above the card's link.\nconst zoomMediaClass =\n  \"motion-safe:[&_:is(img,video)]:transition-transform motion-safe:[&_:is(img,video)]:duration-(--ouro-duration-base) motion-safe:[&_:is(img,video)]:ease-(--ouro-ease-out) \" +\n  \"motion-safe:pointer-fine:group-hover/card:[&_:is(img,video)]:scale-[1.03] motion-safe:group-has-[:focus-visible]/card:[&_:is(img,video)]:scale-[1.03]\";\nconst revealClass =\n  \"transition-opacity duration-(--ouro-duration-base) ease-(--ouro-ease-out) motion-reduce:duration-(--ouro-duration-fast) \" +\n  \"pointer-fine:not-group-hover/card:not-group-has-[:focus-visible]/card:opacity-0\";\n\n// Below the breakpoint the header's action drops under the title, at the start.\nconst headerStacked = { sm: \"max-sm:flex-col max-sm:gap-3\", md: \"max-md:flex-col max-md:gap-3\" } as const;\n\nfunction cardHint(token: string): string {\n  if (token.startsWith(\"rounded\")) return radiusFor(token);\n  return `<Card variant=\"plain\"> inside your own surface, or the theme's --card color`;\n}\n\n/**\n * A surface that groups one thing's content: a media slot across the top, a title with a\n * description and an action, a body, and a footer. With `href` the whole card is one link,\n * named by its title, with one tab stop, and its action and footer controls stay their own.\n *\n * A linked card can answer the pointer and the keyboard: `zoomMedia` grows its pictures a little\n * inside their frame, and `revealDescription` keeps its description back until the card is\n * hovered or focused, on a screen with a mouse. Both honour reduced motion.\n *\n * Use `Item` instead for a compact row in a list (media, title, description and actions\n * side by side), and `Stack` when the group needs no surface.\n *\n * @group Display\n * @see https://ui.ouroboros.bot/docs/card\n *\n * @example\n * <Card title=\"Pantry\" description=\"What you have on hand\" action={<Button variant=\"plain\">Edit</Button>}>\n *   <Text>Flour, rice, black beans.</Text>\n * </Card>\n * <Card\n *   href=\"/cookbooks/weeknight\"\n *   media={<AspectRatio ratio={4 / 3}><img src={cover} alt=\"\" /></AspectRatio>}\n *   title=\"Weeknight dinners\"\n *   description=\"12 recipes\"\n * />\n * <Card\n *   href=\"/guides/braising\"\n *   media={<AspectRatio ratio={4 / 3}><img src={cover} alt=\"\" /></AspectRatio>}\n *   title=\"Braising\"\n *   description=\"Low heat, a lid, and time\"\n *   zoomMedia\n *   revealDescription\n * />\n */\nexport function Card(props: CardProps): JSX.Element {\n  const {\n    href,\n    title,\n    external,\n    linkRef,\n    description,\n    zoomMedia,\n    revealDescription,\n    action,\n    media,\n    children,\n    footer,\n    stackBelow: stackBelowProp,\n    headingLevel = 3,\n    variant: variantProp = \"outline\",\n    size: sizeProp = \"md\",\n    as: asProp = \"div\",\n    className,\n    subtitle,\n    image,\n    header,\n    actions,\n    to,\n    asChild,\n    interactive,\n    ...rest\n  } = props;\n  const descriptionId = useId();\n  const variant = Object.hasOwn(variants, variantProp) ? (variantProp as keyof typeof variants) : \"outline\";\n  const size: \"md\" | \"sm\" = sizeProp === \"sm\" ? \"sm\" : \"md\";\n  const element = (elements as readonly string[]).includes(asProp) ? (asProp as (typeof elements)[number]) : \"div\";\n  const level = (levels as readonly unknown[]).includes(headingLevel) ? (headingLevel as (typeof levels)[number]) : 3;\n  const stackBelow: \"sm\" | \"md\" | undefined = stackBelowProp === \"sm\" ? \"sm\" : stackBelowProp === \"md\" ? \"md\" : undefined;\n  const linked = href !== undefined && Boolean(title);\n  const zoom = linked && zoomMedia === true && Boolean(media);\n  const reveal = linked && revealDescription === true && Boolean(description);\n  useAppearanceClassNameCheck(\n    \"Card\",\n    className,\n    process.env.NODE_ENV !== \"production\" ? cardHint : /* istanbul ignore next @preserve -- production only */ \"\",\n  );\n  useDevWarnings(\n    \"Card\",\n    process.env.NODE_ENV !== \"production\"\n      ? () => [\n          href !== undefined && !title && [\"href needs a title, which is the link's text\", `<Card href=\"${href}\" title=\"Weeknight dinners\">`],\n          variant !== variantProp && [`variant=\"${String(variantProp)}\" is not a variant; use \"outline\", \"plain\"`, '<Card variant=\"outline\">'],\n          size !== sizeProp && [`size=\"${String(sizeProp)}\" is not a size; use \"md\", \"sm\"`, '<Card size=\"md\">'],\n          stackBelowProp !== undefined &&\n            stackBelow !== stackBelowProp && [`stackBelow=\"${String(stackBelowProp)}\" is not a breakpoint; use \"sm\", \"md\"`, '<Card stackBelow=\"sm\">'],\n          element !== asProp && [\n            `as=\"${String(asProp)}\" is not an element Card renders; use ${elements.map((name) => `\"${name}\"`).join(\", \")}`,\n            asProp === \"a\" ? '<Card href=\"/path\" title=\"…\">' : '<Card as=\"div\">',\n          ],\n          level !== headingLevel && [`headingLevel must be 2, 3, 4, 5 or 6, got ${String(headingLevel)}`, \"<Card headingLevel={2}>\"],\n          subtitle !== undefined && [\"subtitle is not a prop\", `<Card description=\"${String(subtitle)}\">`],\n          image !== undefined && [\"image is not a prop\", '<Card media={<AspectRatio ratio={4 / 3}><img src=… alt=\"\" /></AspectRatio>}>'],\n          header !== undefined && [\"header is not a prop\", '<Card title=\"…\" description=\"…\" action={…}>'],\n          actions !== undefined && [\"actions is not a prop\", \"<Card action={<Button>…</Button>}> beside the title, or footer={…} below\"],\n          to !== undefined && [\"to is not a prop\", `<Card href=\"${typeof to === \"string\" ? to : \"/path\"}\" title=\"…\">`],\n          asChild !== undefined && [\"asChild is not a prop\", '<Card href=\"/path\" title=\"…\">'],\n          interactive !== undefined && [\"interactive is not a prop; a card with href is a link\", '<Card href=\"/path\" title=\"…\" zoomMedia revealDescription>'],\n          zoomMedia === true && !zoom && [\"zoomMedia needs href, a title and media\", '<Card href=\"/path\" title=\"…\" media={…} zoomMedia>'],\n          revealDescription === true &&\n            !reveal && [\"revealDescription needs href, a title and a description\", '<Card href=\"/path\" title=\"…\" description=\"…\" revealDescription>'],\n        ]\n      : /* istanbul ignore next @preserve -- production only */ undefined,\n  );\n  const pad = inset[variant][size];\n  const heading = title ? (\n    <Heading level={level} size={size === \"sm\" ? \"sm\" : \"md\"}>\n      {linked ? (\n        <RouterLink\n          href={href}\n          ref={linkRef}\n          target={external ? \"_blank\" : undefined}\n          rel={external ? safeRel(undefined) : undefined}\n          data-card-link=\"\"\n          data-stretched-link=\"\"\n          data-ouro-control=\"card\"\n          data-ouro-part=\"link\"\n          aria-describedby={reveal ? descriptionId : undefined}\n          className={stretchedLinkClass}\n        >\n          {title}\n          {external && <span className=\"sr-only\"> (opens in a new tab)</span>}\n        </RouterLink>\n      ) : (\n        title\n      )}\n    </Heading>\n  ) : null;\n  return createElement(\n    element,\n    {\n      ...rest,\n      \"data-ouro\": \"card\",\n      \"data-ouro-squircle\": variant === \"outline\" ? \"\" : undefined,\n      \"data-linked\": linked ? \"\" : undefined,\n      className: cn(\n        \"relative isolate flex min-w-0 list-none flex-col overflow-hidden\",\n        variants[variant],\n        rootSizes[variant][size],\n        linked && linkRoot,\n        (zoom || reveal) && \"group/card\",\n        linked && raiseControlsClass,\n        className,\n      ),\n    },\n    variant === \"outline\" && <span data-ouro-surface=\"\" aria-hidden=\"true\" style={{ zIndex: -1 }} />,\n    media && <div className={cn(\"relative overflow-hidden\", mediaPull[variant][size], zoom && zoomMediaClass)}>{media}</div>,\n    (heading || description || action) && (\n      <div className={cn(\"flex items-start gap-4\", stackBelow && headerStacked[stackBelow], pad)}>\n        <div className=\"flex min-w-0 flex-1 flex-col gap-1\">\n          {heading}\n          {description &&\n            (reveal ? (\n              <div id={descriptionId} data-card-reveal=\"\" className={revealClass}>\n                <Text as=\"div\" size=\"sm\" tone=\"muted\">\n                  {description}\n                </Text>\n              </div>\n            ) : (\n              <Text as=\"div\" size=\"sm\" tone=\"muted\">\n                {description}\n              </Text>\n            ))}\n        </div>\n        {action && <div className=\"flex shrink-0 items-center gap-2\">{action}</div>}\n      </div>\n    ),\n    children && <div className={cn(\"min-w-0\", pad)}>{children}</div>,\n    footer && <div className={cn(\"flex flex-wrap items-center gap-2\", pad)}>{footer}</div>,\n  );\n}\n",
      "type": "registry:ui",
      "target": "@components/ouro/card/card.tsx"
    }
  ],
  "docs": "A surface that groups one thing's content: a media slot across the top, a title with a description and an action, a body, and a footer. Import: import { Card } from \"@/components/ouro/card/card\", with @/components replaced by your components alias (aliases.components in components.json, such as ~/components). Also installed: heading, text, the helpers they import in lib/ouro. Needs ouro-base in your stylesheet: add that item once per app, from the same place as this one, if you have not. Docs: https://ui.ouroboros.bot/docs/card.md Ouro UI v1.3.257.",
  "type": "registry:ui"
}