# Lead scoring

> Inbound B2B lead queue with fit-score rings, qualification reasons, expandable intent breakdowns and CRM sync buttons.

- Kind: block · Category: AI · Interactivity: script
- Install: `npx shadcn@latest add @haze/lead-scoring`
- File: `src/components/haze/blocks/lead-scoring.astro`
- npm dependencies: @lucide/astro
- Registry dependencies: @haze/utils
- Docs page: https://hazeui.com/blocks/lead-scoring

## Use when
- Prioritizing inbound B2B leads with transparent AI fit scores and intent signals
- Letting revenue teams inspect why a lead scored high and push it to HubSpot or Salesforce

## Avoid when
- Showing a dense multi-column CRM directory; use sortable-data-table or data-grid

## Alternatives
- [call-insights](https://hazeui.com/blocks/call-insights.md)
- [gauge](https://hazeui.com/ui/gauge.md)

## Props

| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| id | `string` | "haze-lead-scoring" | no | Unique prefix for section heading IDs. |
| title | `string` | "Inbound lead scoring" | no | Card heading. |
| leads | `Lead[]` | 3 scored B2B leads | no | Ranked leads with score, summary reason and intent signals. |
| class | `string` |  | no | Extra classes on the outer section. |

## Accessibility
- Each lead row expands via a native details/summary disclosure so intent signals remain accessible without script.
- CRM sync buttons disable after syncing and announce the confirmation in a polite role="status" element.
- Key Tab: Move across lead summaries and HubSpot/Salesforce sync buttons
- Key Enter / Space: Expand or collapse a lead breakdown or push the lead to a CRM

## Agent prompts

### Install and use

Install the Haze UI block "Lead scoring" with `npx shadcn@latest add @haze/lead-scoring`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "https://hazeui.com/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import LeadScoring from "@/components/haze/blocks/lead-scoring.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: https://hazeui.com/blocks/lead-scoring.md

### Customize with real content

Adapt the Haze lead-scoring block for our product. Replace the demo values of these props with our real content: id, title, leads, class. Keep the layout, the heading level rules and these accessibility details: Each lead row expands via a native details/summary disclosure so intent signals remain accessible without script. CRM sync buttons disable after syncing and announce the confirmation in a polite role="status" element. Do not add raw color classes; use the Haze tokens.

### Choose the right block

Before using lead-scoring, check it fits: use it when prioritizing inbound b2b leads with transparent ai fit scores and intent signals; letting revenue teams inspect why a lead scored high and push it to hubspot or salesforce. Avoid it when showing a dense multi-column crm directory; use sortable-data-table or data-grid. Alternatives: @haze/call-insights, @haze/gauge.

## Example requests that should lead here
- Build an inbound B2B lead scoring card with fit-score rings, expandable intent signals and HubSpot/Salesforce sync

## Source

```astro
---
import { ArrowUpRight, Check, ChevronDown, Sparkles } from "@lucide/astro";
import { cn } from "../../../lib/haze/utils";

interface Lead {
  id: string;
  company: string;
  contact: string;
  score: number;
  reason: string;
  signals: { label: string; points: string }[];
}

interface Props {
  id?: string;
  title?: string;
  leads?: Lead[];
  class?: string;
}

const {
  id = "haze-lead-scoring",
  title = "Inbound lead scoring",
  leads = [
    {
      id: "l1",
      company: "Tidewell Logistics",
      contact: "Claire Patel · VP Engineering",
      score: 94,
      reason: "Visited enterprise pricing 4x, downloaded security pack, 180+ developers.",
      signals: [
        { label: "Enterprise pricing & SLA visits", points: "+38" },
        { label: "Company size (180+ engineers)", points: "+32" },
        { label: "VP-level buyer intent", points: "+24" },
      ],
    },
    {
      id: "l2",
      company: "Fieldwork Labs",
      contact: "Jonas Lind · Staff Frontend",
      score: 81,
      reason: "Installed CLI registry twice this week and opened Astro migration guide.",
      signals: [
        { label: "Active CLI registry installs", points: "+41" },
        { label: "Docs engagement (9 pages)", points: "+24" },
        { label: "Series B funding signal", points: "+16" },
      ],
    },
    {
      id: "l3",
      company: "Larch Studio",
      contact: "Mina Sato · Design Lead",
      score: 62,
      reason: "Agency evaluating component kits for a single client launch.",
      signals: [
        { label: "Component showcase browsing", points: "+28" },
        { label: "Team size (12 people)", points: "+18" },
        { label: "Short evaluation window", points: "+16" },
      ],
    },
  ],
  class: className,
} = Astro.props;
---

<section aria-labelledby={`${id}-title`} data-haze-lead-scoring class={cn("bg-background px-4 py-10 sm:px-6 sm:py-14", className)}>
  <div class="mx-auto max-w-3xl rounded-2xl border border-border bg-card p-5 sm:p-6">
    <header class="flex flex-wrap items-center justify-between gap-2 border-b border-border pb-4">
      <div class="flex items-center gap-2">
        <Sparkles class="size-4 text-muted-foreground" aria-hidden="true" />
        <h2 id={`${id}-title`} class="text-base/6 font-semibold tracking-tight text-foreground">{title}</h2>
      </div>
      <span class="text-xs text-muted-foreground tabular-nums">3 qualified today</span>
    </header>

    <ul role="list" class="mt-4 space-y-2.5">
      {
        leads.map((lead, idx) => {
          const r = 18;
          const circ = 2 * Math.PI * r;
          const offset = circ - (lead.score / 100) * circ;
          return (
            <li class="rounded-xl border border-border bg-muted/40">
              <details open={idx === 0} class="group">
                <summary class="flex cursor-pointer list-none items-center gap-3.5 p-3.5 select-none focus-visible:outline-2 focus-visible:outline-ring [&::-webkit-details-marker]:hidden">
                  <div class="relative grid size-11 shrink-0 place-items-center" aria-hidden="true">
                    <svg viewBox="0 0 44 44" class="size-11 -rotate-90">
                      <circle cx="22" cy="22" r={r} fill="none" stroke="currentColor" stroke-width="3.5" class="text-muted" />
                      <circle
                        cx="22"
                        cy="22"
                        r={r}
                        fill="none"
                        stroke="currentColor"
                        stroke-width="3.5"
                        stroke-linecap="round"
                        stroke-dasharray={circ}
                        stroke-dashoffset={offset}
                        class={lead.score >= 85 ? "text-success" : lead.score >= 70 ? "text-foreground" : "text-warning"}
                      />
                    </svg>
                    <span class="absolute font-mono text-xs font-semibold text-foreground tabular-nums">{lead.score}</span>
                  </div>

                  <div class="min-w-0 flex-1">
                    <div class="flex flex-wrap items-baseline gap-x-2">
                      <span class="text-sm/5 font-semibold text-foreground">{lead.company}</span>
                      <span class="text-xs/4 text-muted-foreground">{lead.contact}</span>
                    </div>
                    <p class="mt-0.5 line-clamp-1 text-xs/5 text-muted-foreground">{lead.reason}</p>
                  </div>

                  <ChevronDown class="size-4 shrink-0 text-muted-foreground transition-transform duration-150 ease-snappy group-open:rotate-180" aria-hidden="true" />
                </summary>

                <div class="border-t border-border px-4 py-3.5">
                  <p class="text-[0.6875rem]/4 font-medium tracking-wider text-muted-foreground uppercase">Intent signal breakdown</p>
                  <ul role="list" class="mt-2 grid gap-1.5 sm:grid-cols-3">
                    {
                      lead.signals.map((s) => (
                        <li class="flex items-center justify-between gap-2 rounded-lg border border-border bg-card px-2.5 py-2 text-xs">
                          <span class="truncate text-muted-foreground">{s.label}</span>
                          <span class="font-mono font-medium text-success tabular-nums">{s.points}</span>
                        </li>
                      ))
                    }
                  </ul>
                  <div class="mt-3 flex flex-wrap items-center justify-end gap-2">
                    <button
                      type="button"
                      data-ls-push={`HubSpot:${lead.company}`}
                      class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg border border-frame bg-field px-3 text-xs font-medium text-foreground hover:border-frame-strong hover:bg-accent focus-visible:outline-2 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75"
                    >
                      Push to HubSpot
                      <ArrowUpRight class="size-3.5" aria-hidden="true" />
                    </button>
                    <button
                      type="button"
                      data-ls-push={`Salesforce:${lead.company}`}
                      class="inline-flex h-8 cursor-pointer items-center gap-1.5 rounded-lg bg-primary px-3 text-xs font-medium text-primary-foreground hover:opacity-90 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-ring transition-[background-color,border-color,color,opacity,scale] duration-150 ease-snappy active:scale-[0.97] active:duration-75"
                    >
                      Sync Salesforce
                      <ArrowUpRight class="size-3.5" aria-hidden="true" />
                    </button>
                  </div>
                </div>
              </details>
            </li>
          );
        })
      }
    </ul>

    <p data-ls-status role="status" class="mt-3 min-h-4 text-xs/4 text-muted-foreground"></p>
  </div>
</section>

<script>
  function initLeadScoring() {
    document.querySelectorAll<HTMLElement>("[data-haze-lead-scoring]").forEach((root) => {
      if (root.hasAttribute("data-enhanced")) return;
      root.setAttribute("data-enhanced", "");
      const status = root.querySelector<HTMLElement>("[data-ls-status]");
      root.querySelectorAll<HTMLButtonElement>("[data-ls-push]").forEach((btn) => {
        btn.addEventListener("click", () => {
          const [crm, company] = (btn.dataset.lsPush ?? ":").split(":");
          btn.textContent = `Synced to ${crm}`;
          btn.disabled = true;
          if (status) status.textContent = `Pushed ${company} to ${crm}.`;
        });
      });
    });
  }
  initLeadScoring();
  document.addEventListener("astro:page-load", initLeadScoring);
</script>
```
