Skip to content
ProLifetime access for $199, paid once, every future release included
Truffle UI

Hero sections

9 examples. Resize any preview to see it at phone and tablet widths.

Split Type Specimen

Pro

A split editorial hero with a switchable type specimen and a downloadable sample.

The source for this block is part of Truffle Pro.

Console Hero

Free

A split hero whose terminal types a deploy command and prints each step, with a replay button and a fixed height so nothing shifts.

Hide code
components/blocks/hero-console.tsx
"use client";

import { useEffect, useRef, useState } from "react";
import { useInView, useReducedMotion } from "motion/react";
import { ArrowRight, Check, RotateCw } from "lucide-react";

const command = "npx relay deploy --prod";
const steps = [
  { text: "Linked to acme/storefront", ms: 420 },
  { text: "Built 148 routes in 6.2s", ms: 900 },
  { text: "Checked 3 regions: fra1, iad1, hnd1", ms: 700 },
  { text: "Live at storefront.acme.dev", ms: 500 },
];

/** Types the command, then prints each step. Every line has a reserved row, so the window never changes height. */
function Console() {
  const ref = useRef<HTMLDivElement>(null);
  const visible = useInView(ref, { once: true, amount: 0.6 });
  const reduce = useReducedMotion();
  const [run, setRun] = useState(0);
  const [typed, setTyped] = useState(0);
  const [done, setDone] = useState(0);
  const finished = reduce || done === steps.length;

  useEffect(() => {
    if (!visible || reduce) return;
    let cancelled = false;
    const timers: ReturnType<typeof setTimeout>[] = [];
    const wait = (ms: number) => new Promise<void>((resolve) => timers.push(setTimeout(resolve, ms)));
    (async () => {
      setTyped(0);
      setDone(0);
      await wait(350);
      for (let i = 1; i <= command.length && !cancelled; i++) {
        setTyped(i);
        await wait(38);
      }
      for (let i = 0; i < steps.length && !cancelled; i++) {
        await wait(steps[i].ms);
        if (!cancelled) setDone(i + 1);
      }
    })();
    return () => {
      cancelled = true;
      timers.forEach(clearTimeout);
    };
  }, [visible, reduce, run]);

  const shown = reduce ? command.length : typed;
  const complete = reduce ? steps.length : done;

  return (
    <div ref={ref} className="overflow-hidden rounded-xl border border-border bg-card shadow-[0_24px_60px_-30px_rgb(0_0_0/0.45)]">
      <div className="flex h-10 items-center justify-between border-b border-border pl-4 pr-1.5">
        <span className="font-mono text-xs text-muted-foreground">~/storefront</span>
        <button
          type="button"
          onClick={() => setRun((r) => r + 1)}
          disabled={!finished || !!reduce}
          aria-label="Run the deploy again"
          className="grid size-7 place-items-center rounded-md text-muted-foreground outline-none transition-[color,background-color,opacity] duration-150 hover:bg-accent hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-0"
        >
          <RotateCw className="size-3.5" aria-hidden />
        </button>
      </div>
      <div role="img" aria-label={`Terminal running ${command}. ${steps.map((s) => s.text).join(". ")}.`} className="p-4 font-mono text-[13px] leading-7 sm:p-5">
        <p className="flex">
          <span className="mr-2 text-muted-foreground">$</span>
          <span>{command.slice(0, shown)}</span>
          {shown < command.length || complete === 0 ? <span className="ml-px inline-block h-7 w-[7px] translate-y-px animate-[caret-blink_1.1s_steps(1)_infinite] bg-foreground/70 motion-reduce:animate-none" /> : null}
        </p>
        {steps.map((step, i) => (
          <p
            key={step.text}
            className={`flex items-center gap-2 transition-[opacity,translate] duration-300 ease-out motion-reduce:transition-none ${i < complete ? "opacity-100" : "translate-y-1 opacity-0"}`}
          >
            <Check className={`size-3.5 shrink-0 ${i === steps.length - 1 ? "text-emerald-600 dark:text-emerald-400" : "text-muted-foreground"}`} aria-hidden />
            <span className={i === steps.length - 1 ? "text-foreground" : "text-muted-foreground"}>{step.text}</span>
          </p>
        ))}
      </div>
    </div>
  );
}

export default function HeroConsole() {
  return (
    <section className="mx-auto grid w-full max-w-6xl items-center gap-10 px-6 py-14 sm:px-10 lg:grid-cols-[1fr_1.05fr] lg:gap-16 lg:py-24">
      <div>
        <p className="inline-flex items-center gap-2 rounded-md border border-border px-2.5 py-1 font-mono text-xs text-muted-foreground">
          <span aria-hidden className="size-1.5 rounded-full bg-emerald-500" /> v4.2 is out
        </p>
        <h1 className="mt-5 max-w-xl text-balance text-4xl font-semibold leading-[1.02] tracking-[-0.045em] sm:text-6xl">Ship the branch you are on.</h1>
        <p className="mt-5 max-w-md text-pretty leading-relaxed text-muted-foreground">One command builds, checks and promotes your work to every region. Roll back with the same command and a version number.</p>
        <div className="mt-8 flex flex-wrap items-center gap-3">
          <a href="#start" className="inline-flex h-11 items-center gap-2 rounded-lg bg-foreground px-5 text-sm font-medium text-background outline-none transition-[background-color,scale] duration-150 hover:bg-foreground/90 active:scale-[0.96] focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background motion-reduce:transition-none">
            Start deploying <ArrowRight className="size-4" aria-hidden />
          </a>
          <a href="#docs" className="inline-flex h-11 items-center rounded-lg border border-border px-5 text-sm font-medium outline-none transition-colors duration-150 hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring">Read the docs</a>
        </div>
      </div>
      <Console />
    </section>
  );
}

Editorial Hero

Pro

Oversized studio type with a serif word that rotates in place over a field of registration crosses, and a client row underneath.

The source for this block is part of Truffle Pro.

Aurora Hero

Pro

A centered hero with an aurora backdrop, a revealing headline and a shimmer call to action.

The source for this block is part of Truffle Pro.

Hero with Screenshot

Free

A centered hero: an announcement pill, a headline, two buttons and a product window that rises from below and is cut off by the edge of the section.

Hero with Form

Pro

A hero with a demo request beside the pitch: a rating, three promises, and a short form that validates, sends and confirms in place.

The source for this block is part of Truffle Pro.

Hero with Video

Pro

A full-width hero over a background film that starts paused on its poster, with play and sound controls, a scrim that keeps the headline readable, and two buttons.

The source for this block is part of Truffle Pro.

App Download

Pro

A section for a mobile app: three reasons, store badges, a QR code for people on a computer and a phone drawn in the page.

The source for this block is part of Truffle Pro.

App Landing Page

Pro

A page for a mobile app: the icon, a headline, store badges and store facts beside a phone, a carousel of screenshots, the platforms it runs on, a privacy label with compliance pills, and the version history.

The source for this block is part of Truffle Pro.