# Showcase Hero
*URL: https://www.grettech.com/components/showcase-hero*

A product hero in an editorial frame of hairline rules and a hatched band, with a trusted-by row and a tabbed browser window over a colour glow.

- Editorial hairline rules with crosses where they meet
- Hatched band between the copy and the window
- Tabs with a sliding pill and a progress bar that advances them
- Avatar stack and star rating for social proof

## Install with the shadcn CLI
```bash
npx shadcn@latest add https://www.grettech.com/api/registry/showcase-hero
```
With its demo: `npx shadcn@latest add https://www.grettech.com/api/registry/showcase-hero-demo`

**Dependencies:** npm: motion, clsx, tailwind-merge

## Manual installation
**Step 1: Install dependencies**
Install the packages this component uses and the shadcn/ui components it builds on. It also needs the `cn` helper in `lib/utils.ts`, which `npx shadcn@latest init` adds.

```bash
npm install motion clsx tailwind-merge
```

**Step 2: Copy the source code**
Add these files to your project components directory.

File: `components/ui/showcase-hero.tsx`
```tsx
"use client"

import { cn } from "@/lib/utils"
import { motion } from "motion/react"
import * as React from "react"

export type ShowcaseTab = {
  label: string
  src: string
  alt: string
}

export type ShowcaseTrust = {
  /** Photo URLs for the avatar stack (up to five are shown) */
  avatars: string[]
  /** e.g. "Trusted by 120+ teams" */
  label: string
  /** Stars out of five; hidden when not set */
  rating?: number
}

export interface ShowcaseHeroProps extends Omit<
  React.HTMLAttributes<HTMLElement>,
  "title"
> {
  title: React.ReactNode
  description?: string
  /** Buttons or links under the description */
  actions?: React.ReactNode
  trust?: ShowcaseTrust
  /** Screens shown in the window, one per tab */
  tabs: ShowcaseTab[]
  /** Milliseconds per tab when advancing on its own; 0 turns it off */
  interval?: number
  defaultTab?: number
  /** Two colours for the glow under the window */
  glowColors?: [string, string]
}

// Fine diagonal hatching, in the text colour at low strength
const HATCH: React.CSSProperties = {
  backgroundImage:
    "repeating-linear-gradient(115deg, transparent 0 8.5px, color-mix(in oklab, currentColor 14%, transparent) 8.5px 9.5px)",
}

/** A small plus where two rules cross */
function Cross({ className }: { className: string }) {
  return (
    <svg
      viewBox="0 0 11 11"
      aria-hidden="true"
      className={cn("absolute z-10 size-[11px] text-foreground/40", className)}
      fill="none"
      stroke="currentColor"
    >
      <path d="M5.5 0v11M0 5.5h11" />
    </svg>
  )
}

const REDUCED = "(prefers-reduced-motion: reduce)"
function subscribeReducedMotion(onChange: () => void) {
  const media = window.matchMedia(REDUCED)
  media.addEventListener("change", onChange)
  return () => media.removeEventListener("change", onChange)
}

function Stars({ rating }: { rating: number }) {
  return (
    <span
      className="flex items-center gap-0.5 text-amber-500"
      aria-label={`Rated ${rating} out of 5`}
    >
      {Array.from({ length: 5 }, (_, i) => (
        <svg
          key={i}
          viewBox="0 0 20 20"
          aria-hidden="true"
          className={cn("size-3.5", i >= Math.round(rating) && "opacity-25")}
          fill="currentColor"
        >
          <path d="M10 1.5l2.6 5.3 5.9.9-4.3 4.1 1 5.8L10 14.9l-5.2 2.7 1-5.8L1.5 7.7l5.9-.9L10 1.5z" />
        </svg>
      ))}
    </span>
  )
}

/**
 * A product hero: a large left-aligned title with a "trusted by" avatar
 * stack, above a browser window whose tabs switch between screenshots. The
 * tabs advance on their own (pausing on hover, focus and reduced motion)
 * and work as a proper tab list from the keyboard.
 */
export const ShowcaseHero = React.forwardRef<HTMLElement, ShowcaseHeroProps>(
  (
    {
      title,
      description,
      actions,
      trust,
      tabs,
      interval = 5000,
      defaultTab = 0,
      glowColors = ["#6366f1", "#22d3ee"],
      className,
      ...props
    },
    ref
  ) => {
    const [active, setActive] = React.useState(
      Math.min(Math.max(0, defaultTab), Math.max(0, tabs.length - 1))
    )
    const [paused, setPaused] = React.useState(false)
    const reduced = React.useSyncExternalStore(
      subscribeReducedMotion,
      () => window.matchMedia(REDUCED).matches,
      () => false
    )
    const id = React.useId()
    const tabRefs = React.useRef<(HTMLButtonElement | null)[]>([])
    const listRef = React.useRef<HTMLDivElement>(null)

    // Keep the active tab in view on narrow screens. Scrolling the list
    // itself (not scrollIntoView) never moves the page.
    React.useEffect(() => {
      const list = listRef.current
      const tab = tabRefs.current[active]
      if (!list || !tab) return
      const left = tab.offsetLeft - list.offsetLeft
      if (
        left < list.scrollLeft ||
        left + tab.offsetWidth > list.scrollLeft + list.clientWidth
      )
        list.scrollTo({ left: left - 8, behavior: "smooth" })
    }, [active])

    // The progress bar under the active tab is the timer: when it fills,
    // the next tab opens, so the two never drift apart
    const auto = interval > 0 && tabs.length > 1 && !paused && !reduced
    const next = () => setActive((a) => (a + 1) % tabs.length)

    const select = (i: number) => {
      const next = (i + tabs.length) % tabs.length
      setActive(next)
      tabRefs.current[next]?.focus()
    }
    const onKeyDown = (e: React.KeyboardEvent) => {
      if (e.key === "ArrowRight") select(active + 1)
      else if (e.key === "ArrowLeft") select(active - 1)
      else if (e.key === "Home") select(0)
      else if (e.key === "End") select(tabs.length - 1)
      else return
      e.preventDefault()
    }

    return (
      <section
        ref={ref}
        className={cn(
          "relative isolate w-full overflow-hidden bg-background px-6 py-16 sm:py-24",
          className
        )}
        {...props}
      >
        {/* Editorial frame: hairline rules that run off the edges, with
          small crosses where they meet */}
        <div className="relative mx-auto max-w-6xl">
          <div
            aria-hidden="true"
            className="pointer-events-none absolute inset-0"
          >
            <span className="absolute -top-24 -bottom-24 left-0 w-px bg-foreground/10" />
            <span className="absolute -top-24 right-0 -bottom-24 w-px bg-foreground/10" />
            <span className="absolute top-0 left-1/2 h-px w-[200vw] -translate-x-1/2 bg-foreground/10" />
            <Cross className="top-0 left-0 -translate-1/2" />
            <Cross className="top-0 right-0 translate-x-1/2 -translate-y-1/2" />
          </div>

          <div className="flex flex-col gap-10 px-5 pt-10 sm:px-10 sm:pt-14 lg:flex-row lg:items-end lg:justify-between">
            <div className="max-w-3xl">
              <h1 className="text-4xl leading-[1.05] font-bold tracking-tight text-balance text-foreground sm:text-6xl lg:text-7xl">
                {title}
              </h1>
              {description && (
                <p className="mt-6 max-w-xl text-base text-pretty text-muted-foreground sm:text-lg">
                  {description}
                </p>
              )}
              {actions && (
                <div className="mt-8 flex flex-wrap items-center gap-3">
                  {actions}
                </div>
              )}
            </div>

            {trust && (
              <div className="flex shrink-0 flex-col gap-3 lg:items-end lg:text-right">
                <p className="max-w-72 text-sm text-muted-foreground">
                  {trust.label}
                </p>
                <div className="flex items-center gap-3">
                  <div className="flex -space-x-3">
                    {trust.avatars.slice(0, 5).map((src, i) => (
                      // eslint-disable-next-line @next/next/no-img-element
                      <img
                        key={`${src}-${i}`}
                        src={src}
                        alt=""
                        width={40}
                        height={40}
                        className="size-10 rounded-full border-2 border-background object-cover"
                      />
                    ))}
                  </div>
                  {trust.rating !== undefined && (
                    <Stars rating={trust.rating} />
                  )}
                </div>
              </div>
            )}
          </div>

          {/* Hatched band between the copy and the window */}
          <div
            aria-hidden="true"
            className="relative mt-12 h-8 text-foreground sm:mt-14 sm:h-10"
            style={HATCH}
          >
            <span className="absolute top-0 left-1/2 h-px w-[200vw] -translate-x-1/2 bg-foreground/10" />
            <span className="absolute bottom-0 left-1/2 h-px w-[200vw] -translate-x-1/2 bg-foreground/10" />
            <Cross className="bottom-0 left-0 -translate-x-1/2 translate-y-1/2" />
            <Cross className="right-0 bottom-0 translate-1/2" />
          </div>

          {tabs.length > 0 && (
            <div className="relative px-3 pt-8 sm:px-8 sm:pt-10">
              {/* Colour glow under the window */}
              <div
                aria-hidden="true"
                className="pointer-events-none absolute -inset-x-6 top-1/4 -bottom-16 -z-10 opacity-55 blur-3xl dark:opacity-40"
                style={{
                  backgroundImage: `radial-gradient(closest-side at 30% 50%, ${glowColors[0]}, transparent), radial-gradient(closest-side at 70% 55%, ${glowColors[1]}, transparent)`,
                }}
              />
              <div className="rounded-[22px] bg-foreground/[0.04] p-1.5 ring-1 ring-foreground/10 backdrop-blur-md sm:p-2">
                <div
                  className="overflow-hidden rounded-2xl border bg-muted/60 shadow-[0_30px_80px_-30px_rgba(0,0,0,0.35)]"
                  onPointerEnter={() => setPaused(true)}
                  onPointerLeave={() => setPaused(false)}
                  onFocus={() => setPaused(true)}
                  onBlur={(e) => {
                    if (!e.currentTarget.contains(e.relatedTarget as Node))
                      setPaused(false)
                  }}
                >
                  {/* Window bar with the tabs */}
                  <div className="flex items-center gap-4 border-b px-4 py-2.5">
                    <div aria-hidden="true" className="hidden gap-1.5 sm:flex">
                      <span className="size-3 rounded-full bg-[#ff5f57]" />
                      <span className="size-3 rounded-full bg-[#febc2e]" />
                      <span className="size-3 rounded-full bg-[#28c840]" />
                    </div>
                    <div
                      ref={listRef}
                      role="tablist"
                      aria-label="Screens"
                      onKeyDown={onKeyDown}
                      className="flex min-w-0 [scrollbar-width:none] gap-1 overflow-x-auto"
                    >
                      {tabs.map((tab, i) => {
                        const selected = i === active
                        return (
                          <button
                            key={`${tab.label}-${i}`}
                            ref={(el) => {
                              tabRefs.current[i] = el
                            }}
                            type="button"
                            role="tab"
                            id={`${id}-tab-${i}`}
                            aria-selected={selected}
                            aria-controls={`${id}-panel`}
                            tabIndex={selected ? 0 : -1}
                            onClick={() => setActive(i)}
                            className={cn(
                              "relative shrink-0 overflow-hidden rounded-md px-3 py-1 text-xs font-medium whitespace-nowrap transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",
                              selected
                                ? "text-foreground"
                                : "text-muted-foreground hover:text-foreground"
                            )}
                          >
                            {/* The selected pill slides between tabs */}
                            {selected && (
                              <motion.span
                                layoutId={`${id}-pill`}
                                aria-hidden="true"
                                className="absolute inset-0 rounded-md bg-background shadow-sm"
                                transition={{
                                  type: "spring",
                                  stiffness: 420,
                                  damping: 34,
                                }}
                              />
                            )}
                            <span className="relative">{tab.label}</span>
                            {selected && auto && (
                              <motion.span
                                key={active}
                                aria-hidden="true"
                                className="absolute inset-x-0 bottom-0 h-0.5 origin-left bg-foreground/30"
                                initial={{ scaleX: 0 }}
                                animate={{ scaleX: 1 }}
                                transition={{
                                  duration: interval / 1000,
                                  ease: "linear",
                                }}
                                onAnimationComplete={next}
                              />
                            )}
                          </button>
                        )
                      })}
                    </div>
                  </div>

                  {/* Screens, stacked so switching is a crossfade */}
                  <div
                    id={`${id}-panel`}
                    role="tabpanel"
                    aria-labelledby={`${id}-tab-${active}`}
                    className="relative aspect-video bg-background"
                  >
                    {tabs.map((tab, i) =>
                      // A tab without an image shows an empty window
                      tab.src ? (
                        <motion.img
                          key={`${tab.src}-${i}`}
                          src={tab.src}
                          alt={i === active ? tab.alt : ""}
                          aria-hidden={i !== active}
                          loading={i === active ? "eager" : "lazy"}
                          className="absolute inset-0 size-full object-cover object-top"
                          initial={false}
                          animate={
                            i === active
                              ? { opacity: 1, scale: 1 }
                              : { opacity: 0, scale: 1.02 }
                          }
                          transition={{
                            duration: reduced ? 0 : 0.6,
                            ease: [0.2, 0.8, 0.2, 1],
                          }}
                        />
                      ) : null
                    )}
                  </div>
                </div>
              </div>
            </div>
          )}
        </div>
      </section>
    )
  }
)
ShowcaseHero.displayName = "ShowcaseHero"

```

**Step 3: Framework Adjustments (Optional)**
If you are manually copying this code into a Vite or Remix project (without using the CLI), make sure to remove the `"use client";` directive from the very top of the file.

## Props
| Name | Type | Default | Required | Description |
|---|---|---|---|---|
| `title` | `React.ReactNode` | - | Yes | The main headline. |
| `description` | `string` | - | No | Supporting text under the title. |
| `actions` | `React.ReactNode` | - | No | Buttons or links under the description. |
| `tabs` | `ShowcaseTab[]` | - | Yes | Screens shown in the window, one per tab. |
| `tabs.label` | `string` | - | Yes | Tab label. |
| `tabs.src` | `string` | - | Yes | Screenshot URL. |
| `tabs.alt` | `string` | - | Yes | Description of the screenshot. |
| `trust` | `ShowcaseTrust` | - | No | Avatar stack, label and rating shown beside the title. |
| `trust.avatars` | `string[]` | - | Yes | Photo URLs; up to five are shown. |
| `trust.label` | `string` | - | Yes | Text such as "Trusted by 120+ teams". |
| `trust.rating` | `number` | - | No | Stars out of five; hidden when not set. |
| `interval` | `number` | `5000` | No | Milliseconds per tab when advancing on its own. 0 turns it off. |
| `defaultTab` | `number` | `0` | No | Tab shown first. |
| `glowColors` | `[string, string]` | `["#6366f1", "#22d3ee"]` | No | Two colours for the glow under the window. |
| `className` | `string` | - | No | Extra classes for the section. |

## Usage
```tsx
"use client"

import { ShowcaseHero } from "@/components/ui/showcase-hero"

const TABS = [
  {
    label: "Dashboard",
    src:
      "https://images.unsplash.com/photo-1551288049-bebda4e38f71?w=800&q=75&auto=format",
    alt: "Analytics dashboard with charts and recent activity",
  },
  {
    label: "Design",
    src:
      "https://images.unsplash.com/photo-1561070791-2526d30994b5?q=75&w=1200&auto=format&fit=crop",
    alt: "Designers sketching interface layouts on paper",
  },
  {
    label: "Build",
    src:
      "https://images.unsplash.com/photo-1498050108023-c5249f4df085?q=75&w=1200&auto=format&fit=crop",
    alt: "Code open in an editor on a laptop",
  },
  {
    label: "Launch",
    src:
      "https://images.unsplash.com/photo-1460925895917-afdab827c52f?q=75&w=1200&auto=format&fit=crop",
    alt: "Live product analytics on a laptop screen",
  },
]

export default function ShowcaseHeroDemo() {
  return (
    <ShowcaseHero
      title="Every client project, from brief to launch."
      description="Plan work, share designs for review and track releases with your clients in one shared workspace."
      trust={{
        label: "Used by design studios in 12 countries",
        rating: 5,
        avatars: [
          "https://images.unsplash.com/photo-1438761681033-6461ffad8d80?w=200&h=200&fit=crop&crop=faces&q=75",
          "https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=200&h=200&fit=crop&crop=faces&q=75",
          "https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=400&h=400&fit=crop&q=80",
          "https://images.unsplash.com/photo-1535713875002-d1d0cf377fde?w=200&h=200&fit=crop&crop=faces&q=75",
          "https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=400&h=400&fit=crop&q=80",
        ],
      }}
      tabs={TABS}
      actions={
        <>
          <a
            href="#start"
            className="rounded-lg bg-foreground px-5 py-2.5 text-sm font-medium text-background transition-opacity hover:opacity-90"
          >
            Try it free
          </a>
          <a
            href="#work"
            className="rounded-lg border px-5 py-2.5 text-sm font-medium text-foreground transition-colors hover:bg-muted"
          >
            Watch the tour
          </a>
        </>
      }
    />
  )
}

```
