{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "email-dock",
  "title": "Email Dock",
  "description": "Highlight and link parts of an email address with dock actions.",
  "dependencies": [
    "lucide-react"
  ],
  "files": [
    {
      "path": "src/registry/components/email-dock/email-dock.tsx",
      "content": "\"use client\";\n\nimport { Link2, Mail, User } from \"lucide-react\";\nimport * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\n/** Which part of the email string to emphasize on dock hover / tap. */\ntype EmailHighlightSegment = \"local\" | \"domain\" | \"full\";\n\ninterface EmailHighlight {\n\t/** Email part to emphasize on hover. */\n\tsegment: EmailHighlightSegment;\n\t/** Optional link (e.g. `mailto:` or website). */\n\thref?: string;\n\t/** Open `href` in a new tab. */\n\texternal?: boolean;\n\t/** Accessible name for the dock control; derived from segment when omitted. */\n\tlabel?: string;\n}\n\nconst SEGMENT_META: Record<\n\tEmailHighlightSegment,\n\t{\n\t\ticon: React.ComponentType<{ className?: string }>;\n\t\tlabel: string;\n\t\tbadge: string;\n\t}\n> = {\n\tlocal: { icon: User, label: \"Highlight username\", badge: \"name\" },\n\tdomain: { icon: Link2, label: \"Highlight domain\", badge: \"website\" },\n\tfull: { icon: Mail, label: \"Highlight full email\", badge: \"email\" },\n};\n\nconst DEFAULT_HIGHLIGHTS: EmailHighlight[] = [\n\t{ segment: \"local\" },\n\t{ segment: \"domain\" },\n\t{ segment: \"full\" },\n];\n\nconst HIGHLIGHT_CLASS =\n\t\"bg-gradient-to-r from-blue-400 to-blue-500 bg-clip-text text-transparent\";\n\nfunction parseEmail(email: string) {\n\tconst atIndex = email.indexOf(\"@\");\n\tif (atIndex === -1) {\n\t\treturn { local: email, at: \"\", domain: \"\" };\n\t}\n\treturn {\n\t\tlocal: email.slice(0, atIndex),\n\t\tat: \"@\",\n\t\tdomain: email.slice(atIndex + 1),\n\t};\n}\n\nfunction HighlightableText({\n\ttext,\n\tactive,\n\tactiveLabel,\n\tshowBadge = true,\n}: {\n\ttext: string;\n\tactive: boolean;\n\tactiveLabel: string;\n\tshowBadge?: boolean;\n}) {\n\tconst showDecoration = active && showBadge;\n\n\treturn (\n\t\t<span className=\"relative inline-block\">\n\t\t\t<span\n\t\t\t\taria-hidden\n\t\t\t\tclassName={cn(active ? HIGHLIGHT_CLASS : \"text-inherit\")}\n\t\t\t>\n\t\t\t\t{text}\n\t\t\t</span>\n\n\t\t\t{showDecoration ? (\n\t\t\t\t<>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\tclassName=\"pointer-events-none absolute -inset-x-0.5 top-[99%] -bottom-2 -z-10 border-border border-r border-b border-l border-dotted\"\n\t\t\t\t\t/>\n\t\t\t\t\t<span\n\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\tclassName=\"pointer-events-none absolute top-[calc(100%+0.6rem)] left-1/2 -translate-x-1/2 whitespace-nowrap font-thin text-[0.42em] text-foreground/35 tracking-[0.18em]\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{activeLabel}\n\t\t\t\t\t</span>\n\t\t\t\t</>\n\t\t\t) : null}\n\t\t</span>\n\t);\n}\n\ninterface EmailDockProps extends React.ComponentProps<\"div\"> {\n\t/** Full email address shown in the card. */\n\temail: string;\n\t/** Dock icons and highlight rules. Defaults to username / domain / full. */\n\thighlights?: EmailHighlight[];\n}\n\nfunction EmailDock({\n\temail,\n\thighlights = DEFAULT_HIGHLIGHTS,\n\tclassName,\n\t...props\n}: EmailDockProps) {\n\tconst parsed = React.useMemo(() => parseEmail(email), [email]);\n\tconst [activeSegment, setActiveSegment] =\n\t\tReact.useState<EmailHighlightSegment | null>(null);\n\n\tconst deactivate = () => setActiveSegment(null);\n\n\treturn (\n\t\t<div\n\t\t\tdata-slot=\"email-dock\"\n\t\t\tclassName={cn(\n\t\t\t\t\"relative flex w-full max-w-xl flex-col items-center justify-center\",\n\t\t\t\tclassName,\n\t\t\t)}\n\t\t\t{...props}\n\t\t>\n\t\t\t<p\n\t\t\t\tdata-slot=\"email-dock-address\"\n\t\t\t\tclassName=\"w-full text-center font-medium text-[clamp(1.35rem,4.5vw,2.25rem)] text-foreground/35 leading-tight tracking-tight\"\n\t\t\t>\n\t\t\t\t<span className=\"sr-only\">{email}</span>\n\t\t\t\t<span className=\"relative inline-block\">\n\t\t\t\t\t<HighlightableText\n\t\t\t\t\t\ttext={parsed.local}\n\t\t\t\t\t\tactive={activeSegment === \"local\" || activeSegment === \"full\"}\n\t\t\t\t\t\tactiveLabel={SEGMENT_META.local.badge}\n\t\t\t\t\t\tshowBadge={activeSegment === \"local\"}\n\t\t\t\t\t/>\n\n\t\t\t\t\t{parsed.at ? (\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\tactiveSegment === \"full\" ? HIGHLIGHT_CLASS : \"text-inherit\",\n\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{parsed.at}\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : null}\n\n\t\t\t\t\t{parsed.domain ? (\n\t\t\t\t\t\t<HighlightableText\n\t\t\t\t\t\t\ttext={parsed.domain}\n\t\t\t\t\t\t\tactive={activeSegment === \"domain\" || activeSegment === \"full\"}\n\t\t\t\t\t\t\tactiveLabel={SEGMENT_META.domain.badge}\n\t\t\t\t\t\t\tshowBadge={activeSegment === \"domain\"}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) : null}\n\n\t\t\t\t\t{activeSegment === \"full\" ? (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\tclassName=\"pointer-events-none absolute -inset-x-0.5 top-[99%] -bottom-2 -z-10 border-border border-r border-b border-l border-dotted\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\taria-hidden\n\t\t\t\t\t\t\t\tclassName=\"pointer-events-none absolute top-[calc(100%+0.6rem)] left-1/2 -translate-x-1/2 whitespace-nowrap font-thin text-[0.42em] text-foreground/35 tracking-[0.18em]\"\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{SEGMENT_META.full.badge}\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) : null}\n\t\t\t\t</span>\n\t\t\t</p>\n\n\t\t\t{highlights.length > 0 ? (\n\t\t\t\t<div\n\t\t\t\t\tdata-slot=\"email-dock-toolbar\"\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-label=\"Email actions\"\n\t\t\t\t\tclassName=\"mt-8 flex items-center justify-center gap-5 sm:mt-10 sm:gap-6\"\n\t\t\t\t\tonPointerLeave={deactivate}\n\t\t\t\t\tonBlur={(event) => {\n\t\t\t\t\t\tif (!event.currentTarget.contains(event.relatedTarget as Node)) {\n\t\t\t\t\t\t\tdeactivate();\n\t\t\t\t\t\t}\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t{highlights.map((highlight, index) => (\n\t\t\t\t\t\t<DockAction\n\t\t\t\t\t\t\tkey={`${highlight.segment}-${index}`}\n\t\t\t\t\t\t\thighlight={highlight}\n\t\t\t\t\t\t\tisActive={activeSegment === highlight.segment}\n\t\t\t\t\t\t\tonActivate={() => setActiveSegment(highlight.segment)}\n\t\t\t\t\t\t/>\n\t\t\t\t\t))}\n\t\t\t\t</div>\n\t\t\t) : null}\n\t\t</div>\n\t);\n}\n\ninterface DockActionProps {\n\thighlight: EmailHighlight;\n\tisActive: boolean;\n\tonActivate: () => void;\n}\n\nfunction DockAction({ highlight, isActive, onActivate }: DockActionProps) {\n\tconst meta = SEGMENT_META[highlight.segment];\n\tconst Icon = meta.icon;\n\tconst label = highlight.label ?? meta.label;\n\tconst sharedClass = cn(\n\t\t\"flex size-10 items-center justify-center rounded-full text-foreground/40\",\n\t\t\"hover:translate-y-[-2px] hover:text-foreground/80\",\n\t\t\"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50\",\n\t\t\"sm:size-11\",\n\t\tisActive && \"text-foreground\",\n\t);\n\n\tconst handlers = {\n\t\tonPointerEnter: onActivate,\n\t\tonFocus: onActivate,\n\t\tonClick: (event: React.MouseEvent) => {\n\t\t\tif (highlight.href) return;\n\t\t\tevent.preventDefault();\n\t\t\tonActivate();\n\t\t},\n\t};\n\n\tif (highlight.href) {\n\t\treturn (\n\t\t\t<a\n\t\t\t\tdata-slot=\"email-dock-action\"\n\t\t\t\thref={highlight.href}\n\t\t\t\taria-label={label}\n\t\t\t\ttarget={highlight.external ? \"_blank\" : undefined}\n\t\t\t\trel={highlight.external ? \"noopener noreferrer\" : undefined}\n\t\t\t\tclassName={sharedClass}\n\t\t\t\t{...handlers}\n\t\t\t>\n\t\t\t\t<Icon className=\"size-[1.15rem] stroke-[1.5] sm:size-5\" aria-hidden />\n\t\t\t</a>\n\t\t);\n\t}\n\n\treturn (\n\t\t<button\n\t\t\ttype=\"button\"\n\t\t\tdata-slot=\"email-dock-action\"\n\t\t\taria-label={label}\n\t\t\tclassName={sharedClass}\n\t\t\t{...handlers}\n\t\t>\n\t\t\t<Icon className=\"size-[1.15rem] stroke-[1.5] sm:size-5\" aria-hidden />\n\t\t</button>\n\t);\n}\n\nexport type { EmailDockProps, EmailHighlight, EmailHighlightSegment };\nexport { DEFAULT_HIGHLIGHTS, EmailDock };\n\nexport default EmailDock;\n",
      "type": "registry:component",
      "target": "@components/email-dock.tsx"
    }
  ],
  "meta": {
    "createdAt": "2026-07-20",
    "image": "https://cdn.tentui.com/images/components/email-dock",
    "video": "https://cdn.tentui.com/videos/components/email-dock"
  },
  "docs": "https://tentui.com/components/email-dock",
  "categories": [],
  "type": "registry:component"
}