{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"avatar-label-group","title":"Avatar Label Group","description":"Show a person, a team or an account as an avatar with a title and a subtitle beside it. Search terms: avatar with name, user cell, name and email, profile row, account row.","dependencies":["@base-ui/react@1.7.0"],"registryDependencies":["@siteplane/base","@siteplane/avatar"],"files":[{"path":"packages/ui/src/components/avatar-label-group/avatar-label-group.tsx","content":"\"use client\";\n\nimport { mergeProps } from \"@base-ui/react/merge-props\";\nimport { useRender } from \"@base-ui/react/use-render\";\nimport * as React from \"react\";\n\nimport { cn } from \"../../system/utils/cn\";\nimport { slotClass } from \"../../system/utils/slot-class\";\nimport { AvatarScope } from \"../avatar\";\n\nimport \"./avatar-label-group.css\";\n\n/** `sm`, `md` or `lg`: a 32, 40 or 48 px avatar with the text that goes with it. */\nexport type AvatarLabelGroupSize = \"sm\" | \"md\" | \"lg\";\n\nexport interface AvatarLabelGroupProps extends Omit<\n  useRender.ComponentProps<\"figure\">,\n  \"title\"\n> {\n  /**\n   * The size: `sm` is a 32 px avatar beside a 14 px\n   * title and a 12 px subtitle, `md` a 40 px avatar with 14 px text and `lg` a\n   * 48 px avatar with 16 px text. The avatar takes the size, so its initials,\n   * its icon and its corner marks step with it. `sm` by default, the size of a\n   * single Avatar.\n   */\n  size?: AvatarLabelGroupSize | undefined;\n  /**\n   * The main line beside the avatar, such as a person's name or an account. It\n   * wraps where the line is full.\n   */\n  title?: React.ReactNode;\n  /**\n   * The line under the title, such as an email address or a role. It stays on\n   * one line and ends with an ellipsis where the group is full.\n   */\n  subtitle?: React.ReactNode;\n}\n\n/**\n * An avatar with a title and a subtitle beside it: the person, team or account\n * a row, a menu header or an account card stands for. Put the Avatar in as the\n * child, with its image, its fallback and the marks it needs (`status`,\n * AvatarBadge, a verified Badge): the group gives it its size and its\n * hairline ring, so it passes neither, and the title and the subtitle take the\n * kit's text roles. The group is a figure, and its title and subtitle are the\n * figure's caption. Rendered as another element (`render`), such as the span\n * that a button, a link or a menu row takes (`render={<span />}`), it holds\n * the same caption and lines as spans, so it stays phrasing content there,\n * with the same slots, classes and look. It fills the row it stands in.\n */\nexport function AvatarLabelGroup({\n  children,\n  className,\n  render,\n  size = \"sm\",\n  subtitle,\n  title,\n  ...props\n}: AvatarLabelGroupProps): React.ReactElement {\n  const hasText = !isEmpty(title) || !isEmpty(subtitle);\n  // Only a figure holds a figcaption, and an element that takes phrasing\n  // content alone, such as a button, holds no paragraph: any other root holds\n  // its caption and lines as spans.\n  const figure =\n    render === undefined ||\n    (React.isValidElement(render) && render.type === \"figure\");\n  const Caption = figure ? \"figcaption\" : \"span\";\n  const Line = figure ? \"p\" : \"span\";\n  const defaultProps = {\n    children: (\n      <>\n        <AvatarScope bordered size={size}>\n          {children}\n        </AvatarScope>\n        {hasText ? (\n          <Caption\n            className=\"sp-avatar-label-group-caption\"\n            data-slot=\"avatar-label-group-caption\"\n          >\n            {isEmpty(title) ? null : (\n              <Line\n                className=\"sp-avatar-label-group-title\"\n                data-slot=\"avatar-label-group-title\"\n              >\n                {title}\n              </Line>\n            )}\n            {isEmpty(subtitle) ? null : (\n              <Line\n                className=\"sp-avatar-label-group-subtitle\"\n                data-slot=\"avatar-label-group-subtitle\"\n                // A truncated subtitle carries its full text (rulebook K5).\n                title={typeof subtitle === \"string\" ? subtitle : undefined}\n              >\n                {subtitle}\n              </Line>\n            )}\n          </Caption>\n        ) : null}\n      </>\n    ),\n    className: cn(slotClass(\"avatar-label-group\", props, render), className),\n    \"data-size\": size,\n    \"data-slot\": \"avatar-label-group\",\n  };\n\n  return useRender({\n    defaultTagName: \"figure\",\n    props: mergeProps<\"figure\">(defaultProps, props),\n    render,\n  });\n}\n\n/** Whether a line has nothing to show, so its element and its gap stay out. */\nfunction isEmpty(node: React.ReactNode): boolean {\n  return node === undefined || node === null || node === false || node === \"\";\n}\n","type":"registry:ui","target":"~/src/siteplane/components/avatar-label-group/avatar-label-group.tsx"},{"path":"packages/ui/src/components/avatar-label-group/avatar-label-group.css","content":"@layer theme, base, components, siteplane, utilities;\n\n@layer siteplane {\n  /* An avatar beside a title and a subtitle: 8 px\n   * between the avatar and the text, the text vertically centred on the avatar,\n   * and the group fills the row it stands in (flex: 1) without pushing past\n   * it (min-width: 0). The figure's own margins are the browser's, so the\n   * group takes none. */\n  :where(.sp-avatar-label-group) {\n    display: flex;\n    min-width: 0;\n    flex: 1 1 0%;\n    align-items: center;\n    gap: var(--sp-rw-space-2);\n    margin: 0;\n  }\n\n  /* The caption and its lines are blocks, as the figcaption and the paragraphs\n   * of a figure are, and so are the spans that a group rendered as a span holds\n   * inside a button, a link or a menu row. */\n  :where(.sp-avatar-label-group-caption) {\n    display: block;\n    min-width: 0;\n    flex: 1 1 0%;\n  }\n\n  /* The text roles. The title is the label role (the name of a row, as in the\n   * kit's lists) in the primary text colour; the subtitle is body text in the\n   * tertiary colour and stays on one line. sm: 14 px on a 20 px line over\n   * 12 px on 18; md: 14 px on 20 over 14 px on 20; lg: 16 px on 24 over 16 px\n   * on 24. */\n  :where(.sp-avatar-label-group-title) {\n    display: block;\n    margin: 0;\n    color: var(--sp-rw-fg-primary);\n    font-size: var(--sp-rw-font-14);\n    font-weight: var(--sp-rw-font-weight-label);\n    line-height: var(--sp-rw-line-20);\n    overflow-wrap: anywhere;\n  }\n\n  :where(.sp-avatar-label-group-subtitle) {\n    display: block;\n    margin: 0;\n    overflow: hidden;\n    color: var(--sp-rw-fg-tertiary);\n    font-size: var(--sp-rw-font-12);\n    font-weight: var(--sp-rw-font-weight-default);\n    line-height: var(--sp-rw-line-18);\n    text-overflow: ellipsis;\n    white-space: nowrap;\n  }\n\n  :where(\n    .sp-avatar-label-group[data-size=\"md\"] .sp-avatar-label-group-subtitle\n  ) {\n    font-size: var(--sp-rw-font-14);\n    line-height: var(--sp-rw-line-20);\n  }\n\n  :where(.sp-avatar-label-group[data-size=\"lg\"] .sp-avatar-label-group-title),\n  :where(\n    .sp-avatar-label-group[data-size=\"lg\"] .sp-avatar-label-group-subtitle\n  ) {\n    font-size: var(--sp-rw-font-16);\n    line-height: var(--sp-rw-line-24);\n  }\n}\n","type":"registry:ui","target":"~/src/siteplane/components/avatar-label-group/avatar-label-group.css"},{"path":"packages/ui/src/components/avatar-label-group/index.ts","content":"export * from \"./avatar-label-group\";\n","type":"registry:ui","target":"~/src/siteplane/components/avatar-label-group/index.ts"}],"type":"registry:ui","docs":"https://ui.siteplane.io/docs-markdown/components/avatar-label-group.md","categories":["Data display"],"meta":{"avoidWhen":["Avoid for several people at once; use Avatar Group.","Avoid the default figure inside a button or another element that takes only phrasing content; render the group as a span there (render={<span />}), whose caption and lines are spans."],"description":"Show a person, a team or an account as an avatar with a title and a subtitle beside it.","knownLimitations":["The subtitle stays on one line and ends with an ellipsis; it carries its full text as a title only when it is a string.","The group owns no interaction: wrap the row in a link or put a link in the title."],"providerNotes":[],"releaseStatus":"preview","searchTerms":["avatar label group","avatar with name","user cell","name and email","profile row","account row"],"useWhen":["Use for the name cell of a table, a member list, an account card or the header of an account menu, where an avatar stands beside a name and a line such as an email address.","Use the lg size for the header of a profile or an account page, and sm in dense lists."]}}