Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 47 additions & 35 deletions components/hero/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { StaggerText } from "@/registry/hover/stagger-text/stagger-text";
* The hero. Every element in it is shipped inventory or the stack the product targets — no
* decorative filler (docs/DESIGN.md § The hero contains no decorative filler).
*
* One centred column: the gallery is the page's real content and starts a scroll below, so
* the hero states what this is, hands over the command, and gets out of the way. The Tailwind
* mark sits under the command as the stack's signature rather than beside the headline
* competing with it.
* Left-aligned on the same edge as the gallery headings, so the page reads as one document:
* the headline set large across the measure, then a hairline, then the pitch and the command
* side by side. The gallery is the page's real content, so the hero is kept to roughly one
* screen and the first row of tiles shows above the fold on a laptop.
*/
export function Hero() {
return (
<section className="flex flex-col items-center pb-16 pt-16 text-center sm:pb-20 sm:pt-24">
<section className="pb-20 pt-14 sm:pb-24 sm:pt-20">
<p className="inline-flex items-center gap-2 rounded-full border border-[var(--rule)] bg-[var(--surface)] px-3 py-1 font-mono text-[10px] uppercase tracking-[0.12em] text-[var(--mid)] sm:text-[11px] sm:tracking-[0.18em]">
<span aria-hidden className="size-1.5 rounded-full bg-[var(--ink)]" />
React + Tailwind · shadcn registry
Expand All @@ -24,41 +24,53 @@ export function Hero() {
* The first word of the H1 IS the shipped stagger-text effect, so a visitor triggers
* the product by accident while reading the headline. StaggerText is a server
* component that ships no JavaScript, so this costs the page nothing.
*
* "Tailwind" is the lockup: the particle mark sized in em so it tracks the type, then
* the word itself. nowrap keeps the mark from being stranded at the end of a line.
*/}
<h1 className="mt-7 max-w-4xl text-balance font-display text-[clamp(2.4rem,7vw,4.75rem)] font-semibold leading-[0.98] tracking-[-0.04em] text-[var(--ink)]">
<StaggerText>Hover</StaggerText> effects for React and Tailwind.
</h1>

<p className="mt-6 max-w-xl text-pretty text-base leading-relaxed text-[var(--mid)] sm:text-lg">
{effects.length === 12 ? "Twelve" : effects.length} of them. One file each, no
dependencies — you own the code the moment it lands. Add any of them with the shadcn
CLI.{" "}
<span className="whitespace-nowrap text-[var(--ink)]">
<span aria-hidden className="text-[var(--mid)]">
[
</span>
Hover anything below
<span aria-hidden className="text-[var(--mid)]">
]
<h1 className="mt-7 max-w-5xl text-balance font-display text-[clamp(2.6rem,8.2vw,6.25rem)] font-semibold leading-[0.94] tracking-[-0.045em] text-[var(--ink)]">
<StaggerText>Hover</StaggerText> effects for React and{" "}
<span className="whitespace-nowrap">
<span
aria-hidden
className="mr-[0.1em] inline-block h-[0.7em] w-[1.15em] align-[-0.04em]"
>
<TailwindLogotype />
</span>
Tailwind.
</span>
</p>

{/*
* `flex` with a shrinkable child, because MagneticButton's wrapper is a hardcoded
* `inline-flex` this page cannot reach through `className`. Without this the button
* grows to the full length of the command and scrolls the page sideways on a phone.
*/}
<div className="mt-9 flex w-full max-w-lg [&>span]:min-w-0 [&>span]:flex-1">
<InstallCommand slug="magnetic-button" />
</div>
</h1>

<p className="mt-5 font-mono text-xs text-[var(--mid)]">
Built for landing pages, not dashboards.
</p>
<div className="mt-10 grid gap-8 border-t border-[var(--rule)] pt-8 sm:mt-14 lg:grid-cols-[minmax(0,1fr)_minmax(0,30rem)] lg:items-end lg:gap-16">
<p className="max-w-xl text-pretty text-base leading-relaxed text-[var(--mid)] sm:text-lg">
{effects.length === 12 ? "Twelve" : effects.length} of them. One file each, no
dependencies — you own the code the moment it lands. Add any of them with the
shadcn CLI.{" "}
<span className="whitespace-nowrap text-[var(--ink)]">
<span aria-hidden className="text-[var(--mid)]">
[
</span>
Hover anything below
<span aria-hidden className="text-[var(--mid)]">
]
</span>
</span>
</p>

<div className="mt-10 w-full max-w-[15rem] sm:max-w-[17rem]">
<TailwindLogotype />
<div>
{/*
* `flex` with a shrinkable child, because MagneticButton's wrapper is a hardcoded
* `inline-flex` this page cannot reach through `className`. Without this the
* button grows to the full length of the command and scrolls the page sideways on
* a phone.
*/}
<div className="flex w-full [&>span]:min-w-0 [&>span]:flex-1">
<InstallCommand slug="magnetic-button" />
</div>
<p className="mt-4 font-mono text-xs text-[var(--mid)]">
Built for landing pages, not dashboards.
</p>
</div>
</div>
</section>
);
Expand Down
118 changes: 57 additions & 61 deletions components/hero/tailwind-logotype.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,32 @@ import { useEffect, useState } from "react";

import ParticleImage from "@/components/hero/svg-particles";

/** Hover assembly and cursor repulsion are a pointer affordance. Touch has no
* hover to give, so on a phone or tablet the field would idle scattered and
* never resolve. Below 1024 — and on any width without a real pointer, which
* is what keeps a tap from standing in for a hover — the interaction is off
* and the skyline renders assembled and static. */
/** Hover assembly and cursor repulsion are a pointer affordance. Touch has no hover to give,
* so on a phone or tablet the field would idle scattered and never resolve. Without a real
* pointer, or with reduced motion, the interaction is off and the mark renders assembled
* and static. */
const INTERACTIVE =
"(min-width: 1024px) and (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)";
"(hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)";

/** The dotted skyline: buildings.svg rasterised into particles that scatter
* away from the cursor. */
/** Tailwind's own sky, the one colour the mark samples — and only under the pointer. */
const SKY = "#38bdf8";

/**
* The Tailwind mark, sampled into particles, set inline in the H1 where the word "Tailwind"
* begins (docs/DESIGN.md § The hero contains no decorative filler). The wordmark beside it
* stays type, so the headline still reads — and is announced — as a sentence.
*
* It sizes to its parent, which the hero sets in `em` so the mark tracks the headline across
* every breakpoint instead of claiming a block of its own.
*
* It obeys the page thesis: the dots rest in --ink and take Tailwind's sky only while the
* pointer is on the lockup. --ink is read off <html> because the canvas cannot resolve a
* CSS variable, and re-read when the theme toggle flips the class, since --ink inverts.
*/
export const TailwindLogotype = () => {
const [interactive, setInteractive] = useState(false);
const [active, setActive] = useState(false);
const [ink, setInk] = useState("#14150f");

useEffect(() => {
const mq = window.matchMedia(INTERACTIVE);
Expand All @@ -25,73 +39,55 @@ export const TailwindLogotype = () => {
return () => mq.removeEventListener("change", sync);
}, []);

useEffect(() => {
const root = document.documentElement;
const read = () => setInk(getComputedStyle(root).getPropertyValue("--ink").trim() || "#14150f");
read();
const observer = new MutationObserver(read);
observer.observe(root, { attributes: true, attributeFilter: ["class"] });
return () => observer.disconnect();
}, []);

return (
<ParticleImage
imageConfig={{
// buildings.svg tiled three times across the band; the sheet is
// bottom-aligned and padded to the band aspect so nothing stretches
image: "/tailwindcss-mark.svg",
// "fit" contains the artwork at its own aspect. The previous "stretch" is not a mode
// this component implements, so it fell through to the percentage branch and drew the
// mark at 100%x100% of the box — which re-proportioned it at every breakpoint, worst
// in the stacked layout where the box is far wider than the mark. `scale` under 10
// leaves a margin the dots can roam and be repelled into without clipping at the edge.
// "fit" contains the artwork at its own aspect. `scale` under 10 leaves a margin the
// dots can roam and be repelled into without clipping at the canvas edge.
mode: "fit",
sizeUnit: "%",
widthPct: 100,
heightPct: 100,
scale: 9,
scale: 8,
}}
particleShape="square"
// particleCount sets the sampling step (150 / count): 25 -> every 6px
particleCount={25}
// the rasteriser draws each dot at ceil(size / 4) device px, so a value of
// 5 was a 2px block; 20 gives a 5px dot that actually reads as a circle
particleSize={16}
// at rest each dot drifts within roamRadius px of where it sits in the
// skyline, so the band reads as a loosened version of the artwork rather
// than a cloud; it snaps back into the image while the cursor is over the
// black part of the hero (the white nav / trust bar are excluded)
hoverEnabled={interactive}
// hoverTargetSelector / hoverExcludeSelector were removed: this component implements
// neither, so they were spread straight onto the container div and React logged two
// "does not recognize the prop on a DOM element" errors on every load. There is no
// [data-hero] element on the page either — they were carried over from elsewhere.
hoverConfig={{
hoverType: "roam",
transition: { duration: 1.1, ease: "easeInOut" },
roamRadius: 18,
roamShape: "rectangle",
roamOpacity: 0.55,
}}
// particleCount sets the sampling step (150 / count): 60 -> every 2.5px. The mark is
// headline-sized now, so a coarser lattice would resolve too few dots to read as it.
particleCount={60}
// the rasteriser draws each dot at ceil(size / 4) device px
particleSize={8}
particleColor="single"
singleColor={active ? SKY : ink}
// Assembled at rest, always. The vendored "roam" hover idles the dots scattered across
// the whole box and only assembles them under the pointer; at headline size that read
// as noise in the middle of a sentence, so the mark must be legible before it is
// touched. The cursor still deforms it — repulsion below — and recolours it.
hoverEnabled={false}
repulsionEnabled={interactive}
// section-24's values exactly. "random" nudges each dot in its own
// direction by its own amount, so the field deforms; "outside" pushed
// every dot in the radius out to the rim, which is what stamped a clean
// circular hole under the cursor.
// "random" nudges each dot in its own direction by its own amount, so the field
// deforms rather than stamping a clean circular hole under the cursor. Scaled down
// with the mark: at headline size a 60px radius covered all of it.
repulsionConfig={{
repulsionMode: "random",
repulsionForce: 10,
repulsionRadius: 60,
}}
// with the interaction off there is nothing to hover, click or drag, so
// the canvas stops swallowing taps and scroll gestures
// Sized by class rather than by the inline width/height props, so it can respond. A
// fixed 300px height against a 75% width meant the box aspect changed at every
// viewport: on a phone that resolved to roughly 115x300, a tall slot the mark could
// never sit in sensibly. An aspect ratio holds the box's proportions steady while its
// width tracks the column, and the max-width stops it dominating the stacked layout
// where it has the whole measure to itself.
// Sized by class instead of the inline width/height props, so the box can respond. A
// fixed 300px height against a 75% width meant the box's proportions changed at every
// viewport — on a phone it resolved to roughly 115x300, a tall slot the mark could
// never sit in. A fixed aspect keeps the composition steady while the width tracks the
// column, and the max-width stops it dominating the stacked layout where it has the
// whole measure to itself.
className="mx-auto aspect-[16/10] w-full max-w-[22rem] sm:max-w-[26rem] lg:max-w-none"
style={{
pointerEvents: interactive ? undefined : "none",
repulsionForce: 5,
repulsionRadius: 26,
}}
onPointerEnter={() => setActive(true)}
onPointerLeave={() => setActive(false)}
className="size-full"
// with the interaction off there is nothing to hover, so the canvas stops swallowing
// taps and scroll gestures
style={{ pointerEvents: interactive ? undefined : "none" }}
/>
);
};
15 changes: 10 additions & 5 deletions docs/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,11 @@ because they are labels on an instrument, not sentences.
## Layout

The diagram below is the v1 layout. Since the 2026-09-29 redesign the header is three
floating pills (logo · section nav with `/r/` · GitHub + theme toggle), the hero is one
centred column, and tiles are bezels with a footer strip — see § Tile metadata.
floating pills (logo · section nav with `/r/` · GitHub + theme toggle), and tiles are
bezels with a footer strip — see § Tile metadata. Since 2026-09-30 the hero is left-aligned
on the gallery's edge: the headline across the measure, a hairline, then the pitch and the
install command side by side (stacked below `lg`). It is kept to about one screen so the
first row of tiles shows above the fold on a laptop.

```
┌────────────────────────────────────────────────────────┐
Expand Down Expand Up @@ -188,10 +191,12 @@ broken font rather than an effect. The mark is two broad strokes and carries it.

It obeys the page thesis rather than being exempted from it: the mark rests in `--ink` and
samples Tailwind's own #38BDF8 only while the pointer is on the lockup. Colour is still a
function of the cursor. The vendored physics has no reduced-motion or touch handling of its
own and drives a permanent `requestAnimationFrame`, so it mounts only behind a
function of the cursor. It sits inline in the H1, sized in `em` so it tracks the type, and
rests assembled — the vendored "roam" idle, which scatters the dots until hovered, read as
noise mid-sentence at headline size. The vendored physics has no reduced-motion or touch
handling of its own, so repulsion and pointer events are enabled only behind a
`(hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference)` gate;
everything else gets the same artwork masked to `--ink`, costing no JavaScript.
everything else gets the mark assembled, static and in `--ink`.

If a later edit makes this the thin end of a wedge — a second illustration, a screenshot, a
gradient — the rule above is the one that wins, not this paragraph.
Expand Down
Loading