{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "description-list",
  "title": "Description list",
  "description": "Pairs of a label and its value, lined up as a table lines up its columns: details start on one line after their labels, and amounts line up on the end edge over a total. In a narrow column each value goes under its label, and an action beside a value never makes its row taller.",
  "dependencies": [
    "class-variance-authority"
  ],
  "registryDependencies": [
    "https://kinoui.com/r/theme.json"
  ],
  "files": [
    {
      "path": "registry/components/kino/description-list.tsx",
      "content": "import { cva, type VariantProps } from 'class-variance-authority'\nimport type { ComponentProps } from 'react'\n\nimport { cn } from '@/lib/utils'\n\n/*\n * Pairs of a label and its value. As a table lines its columns up, text\n * starts and amounts end: `align='start'` sets the labels in one column and\n * starts every value on one line after it, and `align='end'` puts the values\n * on the end edge, as a receipt lines its amounts up over a total. In a\n * narrow column, under 18rem, each value goes under its label. Each row is as\n * tall as a small control, so an action beside a value never makes its row\n * taller than the rest.\n */\n\n/** Above and below a row's text, so one line makes a row as tall as a small control. */\nconst rowPadding = 'py-[calc((var(--control-height-sm)-1lh)/2)]'\n\nconst descriptionListVariants = cva(\n  [\n    'group/description-list @container/description-list grid w-full min-w-0 gap-x-4 text-sm',\n    // The first and last rows' padding sits outside, so the text lines up with what's around it.\n    '-my-[calc((var(--control-height-sm)-1lh)/2)]',\n  ],\n  {\n    variants: {\n      /** Where the values sit: on one line after the labels, or on the end edge. */\n      align: {\n        // The labels' column is as wide as the widest label, up to half the list.\n        start: 'grid-cols-[fit-content(50%)_minmax(0,1fr)]',\n        end: 'grid-cols-1',\n      },\n    },\n    defaultVariants: { align: 'start' },\n  },\n)\n\nfunction DescriptionList({\n  className,\n  align,\n  ...props\n}: ComponentProps<'dl'> & VariantProps<typeof descriptionListVariants>) {\n  return (\n    <dl\n      data-slot='description-list'\n      data-align={align ?? 'start'}\n      className={cn(descriptionListVariants({ align }), className)}\n      {...props}\n    />\n  )\n}\n\nconst descriptionListItemVariants = cva(\n  [\n    'group/description-list-item col-span-full grid min-w-0 grid-cols-1 gap-x-4 gap-y-0.5',\n    rowPadding,\n    // At the start, every row shares the list's columns, so the values line up.\n    '@2xs/description-list:group-data-[align=start]/description-list:grid-cols-subgrid',\n    // At the end, the label keeps a share of the row, and the value takes what it needs of the rest.\n    '@2xs/description-list:group-data-[align=end]/description-list:grid-cols-[minmax(min(6rem,33%),1fr)_minmax(0,auto)]',\n  ],\n  {\n    variants: {\n      variant: {\n        default: '',\n        /** The sum of the rows above it, under a line. */\n        total: [\n          'mt-[calc((var(--control-height-sm)-1lh)/2)] border-t font-medium',\n          'forced-colors:border-[CanvasText]',\n        ],\n      },\n    },\n    defaultVariants: { variant: 'default' },\n  },\n)\n\n/** A label and its value. */\nfunction DescriptionListItem({\n  className,\n  variant,\n  ...props\n}: ComponentProps<'div'> & VariantProps<typeof descriptionListItemVariants>) {\n  return (\n    <div\n      data-slot='description-list-item'\n      data-variant={variant ?? 'default'}\n      className={cn(descriptionListItemVariants({ variant }), className)}\n      {...props}\n    />\n  )\n}\n\n/** The label: muted, except a total's. A long one wraps. */\nfunction DescriptionListTerm({ className, ...props }: ComponentProps<'dt'>) {\n  return (\n    <dt\n      data-slot='description-list-term'\n      className={cn(\n        'text-muted-foreground min-w-0 text-pretty wrap-anywhere group-data-[variant=total]/description-list-item:text-foreground',\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * The value, and its actions after it. A long unbroken word, such as an ID or\n * a URL, breaks rather than run out of the row.\n */\nfunction DescriptionListDetails({ className, ...props }: ComponentProps<'dd'>) {\n  return (\n    <dd\n      data-slot='description-list-details'\n      className={cn(\n        // A block, so its text flows, wraps and truncates as text; with an action, a row.\n        'text-foreground min-w-0 tabular-nums wrap-anywhere',\n        // Elements in the text, such as a badge, sit on the line's top, so they never make it taller.\n        '*:align-top',\n        'has-data-[slot=description-list-action]:flex has-data-[slot=description-list-action]:items-start has-data-[slot=description-list-action]:gap-2',\n        '@2xs/description-list:group-data-[align=end]/description-list:justify-end @2xs/description-list:group-data-[align=end]/description-list:text-end',\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * Buttons beside a value, such as Copy or Edit: an `xs` button takes no more\n * than a line's height, so its row stays as tall as the others.\n */\nfunction DescriptionListAction({ className, ...props }: ComponentProps<'div'>) {\n  return (\n    <div\n      data-slot='description-list-action'\n      className={cn(\n        // At the row's end, so a value that changes width never moves it; on the end edge, right after the value.\n        'ms-auto flex shrink-0 items-center gap-1 -my-[calc((var(--control-height-xs)-1lh)/2)] @2xs/description-list:group-data-[align=end]/description-list:ms-0',\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\n/**\n * The value beside an action. An action makes the details a row, so a value\n * made of text and elements goes in here to flow as one, and to truncate.\n */\nfunction DescriptionListValue({ className, ...props }: ComponentProps<'span'>) {\n  return (\n    <span\n      data-slot='description-list-value'\n      className={cn('min-w-0 wrap-anywhere', className)}\n      {...props}\n    />\n  )\n}\n\nexport {\n  DescriptionList,\n  DescriptionListAction,\n  DescriptionListDetails,\n  DescriptionListItem,\n  DescriptionListTerm,\n  DescriptionListValue,\n  descriptionListItemVariants,\n  descriptionListVariants,\n}\n",
      "type": "registry:component",
      "target": "@components/kino/description-list.tsx"
    }
  ],
  "type": "registry:component"
}