# Hover momentum (Notchset): prompt.md (v2.0.0)

- id: `hover-momentum` · version 2.0.0 · component · free
- category: Text & motion
- build: one set of files for every shadcn style
- install: `npx shadcn@latest add https://notchset.dev/r/hover-momentum.json`
- npm dependencies: none
- registry dependencies: utils, https://notchset.dev/r/notchset-foundation.json
- docs: https://notchset.dev/components/hover-momentum
- The install command carries everything this item needs (files, CSS, tokens, npm and registry dependencies). Prefer it to copying source by hand.

A card that shows its recent activity only when you ask: hover or focus grows a small bar chart of the last days with its one line of meaning, and it folds away when you leave. Nothing new at rest..

## Build it
- Stack: React 18.3 or 19, TypeScript, Tailwind CSS v4 utility classes on the foundation's roles, a components.json (imports use its aliases).
- Packages: none beyond React.
- Files: `components/ui/notchset/hover-momentum.tsx`.
- Registry dependencies, installed with it automatically: shadcn `utils` (cn), `notchset-foundation`.
- Builds: one set of files, the same for every shadcn style.
- Exports to keep: `HoverMomentum`, and every exported type.
- CSS: the install adds the notchset foundation (its roles, keyframes and motion switch, reading your shadcn tokens for colour) to your global stylesheet once. Nothing to import by hand.
- Re-running `add` (or `--overwrite`) re-applies those rules: put overrides in your own CSS, never in the installed rules.
- Colours: every part reads the foundation's roles (`--ns-canvas`, `--ns-ink`, `--ns-line`, `--ns-signal` …), which read your shadcn tokens (`--background`, `--foreground`, `--border`, `--destructive` …), plus the optional `--success` and `--warning`. Retheme on `:root` or any container; never add Tailwind colour classes inside the component.
- This item reads `--ns-bezel`, `--ns-ease`, `--ns-ink-2`, `--ns-ink-3`, `--ns-line`, `--ns-line-soft`, `--ns-radius-lg`, `--ns-raised`, `--ns-signal`, `--ns-text-meta`, `--ns-time-color`, `--ns-time-dialog`, `--ns-time-menu`.
- Retune it (on any ancestor) with the foundation's roles and hooks: `--ns-bad`, `--ns-bad-ink`, `--ns-band`, `--ns-band-edge`, `--ns-band-grade`, `--ns-band-optimal`, `--ns-beat`, `--ns-bezel`, `--ns-canvas`, `--ns-cat-1`, `--ns-cat-2`, `--ns-cat-3`, `--ns-cat-4`, `--ns-cat-5`, `--ns-cat-6`, `--ns-check`, `--ns-chip`, `--ns-control`, `--ns-control-pad`, `--ns-control-sm`, `--ns-deep`, `--ns-deep-ink`, `--ns-deep-ink-2`, `--ns-deep-line`, `--ns-dialog`, `--ns-dialog-lg`, `--ns-dialog-sm`, `--ns-ease`, `--ns-ease-in`, `--ns-ease-panel`, `--ns-ease-pop`, `--ns-field`, `--ns-flood-arc`, `--ns-flood-aurora`, `--ns-flood-behind-1`, `--ns-flood-behind-2`, `--ns-flood-bloom`, `--ns-flood-deep`, `--ns-flood-dial-bloom`, `--ns-flood-glass`, `--ns-flood-grain`, `--ns-flood-image`, `--ns-flood-ink`, `--ns-flood-ink-low`, `--ns-flood-light`, `--ns-flood-mid`, `--ns-flood-pale`, `--ns-flood-pane`, `--ns-flood-pane-edge`, `--ns-flood-pill-ink`, `--ns-flood-ribbon`, `--ns-flood-ribbon-core`, `--ns-flood-shadow`, `--ns-flood-sheen`, `--ns-flood-wash`, `--ns-font-body`, `--ns-font-display`, `--ns-font-mono`, `--ns-font-script`, `--ns-glass`, `--ns-glass-blur`, `--ns-glass-shadow`, `--ns-glow`, `--ns-grain`, `--ns-gutter`, `--ns-header`, `--ns-heat`, `--ns-hover`, `--ns-ink`, `--ns-ink-2`, `--ns-ink-3`, `--ns-ink-4`, `--ns-leading`, `--ns-lift`, `--ns-light-1`, `--ns-light-2`, `--ns-light-3`, `--ns-light-spread`, `--ns-light-strength`, `--ns-line`, `--ns-line-soft`, `--ns-lit-edge`, `--ns-menu-dy`, `--ns-menu-row`, `--ns-mesh`, `--ns-mesh-frost`, `--ns-ok`, `--ns-ok-ink`, `--ns-orb-body`, `--ns-orb-cool`, `--ns-orb-core`, `--ns-orb-dawn`, `--ns-orb-deep`, `--ns-orb-edge`, `--ns-orb-grain`, `--ns-orb-ground`, `--ns-orb-halo`, `--ns-orb-inner`, `--ns-orb-key`, `--ns-orb-lift`, `--ns-orb-limb`, `--ns-orb-limb-from`, `--ns-orb-rim`, `--ns-orb-skin-hi`, `--ns-orb-skin-lo`, `--ns-orb-skin-mid`, `--ns-orb-warm`, `--ns-panel`, `--ns-panel-w`, `--ns-prism-edge`, `--ns-prism-glint`, `--ns-prism-sheen`, `--ns-prism-tint`, `--ns-pulse`, `--ns-radius`, `--ns-radius-card`, `--ns-radius-full`, `--ns-radius-lg`, `--ns-radius-sm`, `--ns-radius-xl`, `--ns-raised`, `--ns-range`, `--ns-row`, `--ns-row-compact`, `--ns-segment`, `--ns-selected`, `--ns-series`, `--ns-series-core`, `--ns-series-lilac`, `--ns-series-tint`, `--ns-shadow-dialog`, `--ns-shadow-float`, `--ns-shadow-panel`, `--ns-sheet`, `--ns-sheet-bottom`, `--ns-side`, `--ns-signal`, `--ns-sleep-awake`, `--ns-sleep-deep`, `--ns-sleep-light`, `--ns-sleep-rem`, `--ns-space-1`, `--ns-space-2`, `--ns-space-3`, `--ns-space-4`, `--ns-space-5`, `--ns-space-6`, `--ns-space-8`, `--ns-space-section`, `--ns-stack-on`, `--ns-standing-critical`, `--ns-standing-in`, `--ns-standing-out`, `--ns-state-doing`, `--ns-state-done`, `--ns-state-review`, `--ns-state-todo`, `--ns-switch-h`, `--ns-switch-w`, `--ns-text-body`, `--ns-text-control`, `--ns-text-display`, `--ns-text-figure`, `--ns-text-headline`, `--ns-text-hero`, `--ns-text-lede`, `--ns-text-meta`, `--ns-text-page`, `--ns-text-record`, `--ns-text-small`, `--ns-text-strong`, `--ns-text-sub`, `--ns-text-title`, `--ns-tile-shadow`, `--ns-time-born`, `--ns-time-color`, `--ns-time-dialog`, `--ns-time-menu`, `--ns-time-page`, `--ns-time-panel`, `--ns-time-toast`, `--ns-tint`, `--ns-tint-ink`, `--ns-toast-bottom`, `--ns-toast-left`, `--ns-touch`, `--ns-tracking-display`, `--ns-tracking-headline`, `--ns-warn`, `--ns-warn-ink`, `--ns-wash-clay`, `--ns-wash-dusk`, `--ns-wash-graphite`, `--ns-wash-ink`, `--ns-wash-sage`, `--ns-wash-sand`, `--ns-weight-light`, `--ns-weight-medium`, `--ns-weight-regular`, `--ns-weight-strong`, `--ns-well`.
- Never add Tailwind colour classes inside the component.

```tsx
import { CompanyMark } from "@/components/ui/notchset/company-mark";
```

## Parts
- A single export that takes props.

## Match the original
- Read `components/ui/notchset/hover-momentum.tsx` as the reference implementation before changing or recreating anything, and match it: sizes, colours per theme, motion timings, copy and behaviour.
- If you deviate (a prop you can't honour, a style you changed, a dependency you swapped), say so in your reply, part by part.
- Keep the accessibility contract, the keyboard map and the motion levels listed below.

## Use it when

### Not when

## Mistakes
- Recreating the component instead of installing it

## Usage

```tsx
"use client";
import { CompanyMark } from "@/components/ui/notchset/company-mark";
import { HoverMomentum } from "@/components/ui/notchset/hover-momentum";

/* the companies' own marks, 24×24 paths as the CRM seed draws them */
const GLYPH: Record<string, string> = {
  airtable: "M11.992 1.966c-.434 0-.87.086-1.28.257L1.779 5.917c-.503.208-.49.908.012 1.116l8.982 3.558a3.266 3.266 0 0 0 2.454 0l8.982-3.558c.503-.196.503-.908.012-1.116l-8.957-3.694a3.255 3.255 0 0 0-1.272-.257zM23.4 8.056a.589.589 0 0 0-.222.045l-10.012 3.877a.612.612 0 0 0-.38.564v8.896a.6.6 0 0 0 .821.552L23.62 18.1a.583.583 0 0 0 .38-.551V8.653a.6.6 0 0 0-.6-.596zM.676 8.095a.644.644 0 0 0-.48.19C.086 8.396 0 8.53 0 8.69v8.355c0 .442.515.737.908.54l6.27-3.006.307-.147 2.969-1.436c.466-.22.43-.908-.061-1.092L.883 8.138a.57.57 0 0 0-.207-.044z",
};

const TOUCHES = [0, 1, 0, 0, 2, 1, 0, 0, 1, 0, 3, 0, 2, 1];

export default function HoverMomentumDemo() {
  return (
    <HoverMomentum label="Airtable deal" values={TOUCHES} summary="11 touches in 14 days, 3 this week" className="w-[260px]">
      <span className="flex items-center gap-2.5">
        <CompanyMark name="Airtable" color="#18bfff" glyph={GLYPH.airtable} size={24} />
        <span className="flex min-w-0 flex-1 flex-col">
          <span className="text-[var(--ns-ink)]">Airtable</span>
          <span className="text-[length:var(--ns-text-small)] text-[var(--ns-ink-3)]">Team plan upgrade</span>
        </span>
        <span className="text-[var(--ns-ink)] tabular-nums">$118k</span>
      </span>
    </HoverMomentum>
  );
}
```

This example also uses `company-mark` (https://notchset.dev/components/company-mark). Installing this item doesn't bring them; to paste the example as it is: `npx shadcn@latest add https://notchset.dev/r/hover-momentum.json https://notchset.dev/r/company-mark.json`.

## Props

| Prop | Type | Default | What it does |
|---|---|---|---|
| `values` | `number[]` |  | one value per day, oldest first |
| `label` | `string` |  | what the card is, for screen readers ("Raycast deal") |
| `summary` | `string` |  | the chart's meaning in words |
| `range` | `[string, string]` |  | what the first and last bars stand for; by default the last bar is today and the first is as many days back as there are bars after it ("13 days ago" for 14 values, "4 days ago" for 5) |

Full docs: https://notchset.dev/components/hover-momentum

## Customising
- Colours: every part reads the foundation's roles (`--ns-canvas`, `--ns-ink`, `--ns-line`, `--ns-signal` …), which read your shadcn tokens (`--background`, `--foreground`, `--border`, `--destructive` …), plus the optional `--success` and `--warning`. Retheme on `:root` or any container; never add Tailwind colour classes inside the component.
- Dark mode follows the `.dark` class or `data-theme="dark"` on an ancestor (the shadcn and next-themes conventions).
- Update later: Commit or stash local changes first (or copy the files), so the update can be undone. Read https://notchset.dev/r/changelog.json for the new versions: a major version, an entry marked breaking or a merge says what to change. Then re-run the install with `--overwrite`, on a branch. It replaces the component's files, the shared helper files they import, and the item's CSS rules in the global stylesheet, so review the whole diff (components, shared files, CSS), re-apply your own edits, and run the app's typecheck, tests and build.

## Accessibility contract (preserve when editing)

## Install

```bash
npx shadcn@latest add https://notchset.dev/r/hover-momentum.json
```

Or add the `@notchset` registry to components.json and run `npx shadcn@latest add @notchset/hover-momentum`. Every components.json style gets the same files.

## Continue the workflow

- [Card](https://notchset.dev/components/card)
- [Knobs](https://notchset.dev/components/knobs)
- [Line figure](https://notchset.dev/components/line-figure)

## Source

### components/ui/notchset/hover-momentum.tsx

```tsx
// Notchset hover-momentum 2.0.0 · https://notchset.dev/changelog
"use client";
import * as React from "react";
import { cn } from "@/lib/utils";

/*
 * Hover momentum: a card that shows its recent activity only when you ask. At rest it's just the card; on hover or
 * keyboard focus it grows a small bar chart of the last days (one bar per day, the newest strongest) with its one
 * line of meaning ("6 touches in 14 days"), and folds away when you leave. Nothing new at rest, nothing to
 * dismiss. The card itself is the focus target, so the chart is one Tab away; on touch, a tap focuses it.
 *
 *   <HoverMomentum label="Raycast" values={touchesByDay} summary="6 touches in 14 days, 2 this week">
 *     <DealCardBody … />
 *   </HoverMomentum>
 */
type HoverMomentumProps = {
  /** one value per day, oldest first */
  values: number[];
  /** what the card is, for screen readers ("Raycast deal") */
  label: string;
  /** the chart's meaning in words */
  summary: string;
  /** what the first and last bars stand for; by default the last bar is today and the first is as many days back as
      there are bars after it ("13 days ago" for 14 values, "4 days ago" for 5) */
  range?: [string, string] | undefined;
  children: React.ReactNode;
  className?: string | undefined;
};

const daysAgo = (n: number) => (n <= 0 ? "Today" : n === 1 ? "Yesterday" : `${n} days ago`);

function HoverMomentum({ values, label, summary, range: given, children, className }: HoverMomentumProps) {
  const hi = Math.max(...values, 1);
  /* one bar is only today, and no bars have no span to name */
  const range: [string, string] | null = given ?? (values.length > 1 ? [daysAgo(values.length - 1), "Today"] : values.length ? ["Today", ""] : null);
  return (
    <div
      data-slot="hover-momentum"
      tabIndex={0}
      role="group"
      aria-label={`${label}. ${summary}`}
      className={cn(
        "group/momentum rounded-[var(--ns-radius-lg)] bg-[var(--ns-raised)] p-3 shadow-[var(--ns-bezel)] outline-hidden [transition:box-shadow_var(--ns-time-color)] hover:shadow-[var(--ns-bezel),0_6px_18px_-8px_rgba(0,0,0,.18)] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[var(--ns-signal)]",
        className,
      )}
    >
      {children}
      <div
        aria-hidden
        data-ns-glide=""
        className="grid grid-rows-[0fr] opacity-0 [transition:grid-template-rows_var(--ns-time-menu)_var(--ns-ease),opacity_var(--ns-time-menu)_var(--ns-ease)] group-hover/momentum:grid-rows-[1fr] group-hover/momentum:opacity-100 group-focus/momentum:grid-rows-[1fr] group-focus/momentum:opacity-100"
      >
        <div className="min-h-0 overflow-hidden">
          <div className="mt-2.5 flex flex-col gap-1.5 border-t border-[var(--ns-line-soft)] pt-2.5">
            <span className="text-[length:var(--ns-text-meta)] text-[var(--ns-ink-2)]">{summary}</span>
            <span className="flex h-9 items-end gap-[3px]">
              {values.map((v, i) => (
                <i
                  key={i}
                  data-ns-glide=""
                  style={{ height: `${v ? Math.max(14, Math.round((v / hi) * 100)) : 6}%`, transitionDelay: `${i * 12}ms` }}
                  className={cn(
                    "block min-w-0 flex-1 origin-bottom scale-y-50 rounded-[2px] [transition:scale_var(--ns-time-dialog)_var(--ns-ease)] group-hover/momentum:scale-y-100 group-focus/momentum:scale-y-100",
                    v ? (i >= values.length - 3 ? "bg-[var(--ns-ink-2)]" : "bg-[var(--ns-ink-3)] opacity-60") : "bg-[var(--ns-line)]",
                  )}
                />
              ))}
            </span>
            {range && (
              <span className="flex justify-between text-[length:var(--ns-text-meta)] text-[var(--ns-ink-3)]">
                <span>{range[0]}</span>
                <span>{range[1]}</span>
              </span>
            )}
          </div>
        </div>
      </div>
    </div>
  );
}

export { HoverMomentum, type HoverMomentumProps };
```

The foundation (the tokens listed above, keyframes and motion levels) installs once with the first component; its CSS is public at https://notchset.dev/r/notchset-foundation.json.
