Skip to content

Colour-shifting letters on hover in React

A large heading whose letters take on colour and lift one after another when the card is hovered or entered with the keyboard, in pure CSS.

Here is an excerpt of this component's code in React. The full code is free for members, ready to copy into your project.

This component also comes in

Open in a new tab

The code in React

HoverColorLetters.tsx
export function HoverColorLetters() {
  return (
    <article className="group grid gap-4 rounded-3xl bg-white p-[clamp(1.5rem,5vw,2.5rem)] text-[#1f1a17] shadow-[0_1px_2px_rgb(0_0_0/0.06),0_12px_32px_-12px_rgb(0_0_0/0.18)] dark:bg-[#17131f] dark:text-[#f7f3ee]">
      <p className="m-0 text-[0.8125rem] font-bold tracking-[0.06em] text-[#c2410c] uppercase dark:text-[#fdba74]">
        Atelier Terre Vive · Portes ouvertes
      </p>
      <h2 className="m-0 text-[clamp(2.25rem,10vw,4.25rem)] leading-[1.05] font-black tracking-[-0.02em] [--ink:#1f1a17] dark:[--ink:#f7f3ee]">
        <span className="sr-only">Venez toucher la terre</span>
        <span aria-hidden="true">
          <span className="inline-block whitespace-nowrap">
            <span className="inline-block pb-[0.08em] [--c:#c2410c] dark:[--c:#fdba74] bg-[linear-gradient(180deg,var(--ink)_46%,var(--c)_54%)] bg-size-[100%_220%] bg-position-[50%_0%] bg-clip-text text-transparent transition-[background-position,transform] duration-[450ms] ease-[cubic-bezier(0.34,1.56,0.64,1)] delay-[0ms] group-hover:bg-position-[50%_100%] motion-safe:group-hover:[transform:translateY(-0.14em)] group-focus-within:bg-position-[50%_100%] motion-safe:group-focus-within:[transform:translateY(-0.14em)] motion-reduce:transition-none motion-reduce:bg-position-[50%_100%] forced-colors:bg-none forced-colors:text-[CanvasText]">
              V

Free component: copy it freely, including for commercial projects.

Visual effects components in React
  • Cards that fade in as they enter the screen, one after another in each row, without a line of JavaScript and with a static fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A translucent card with a saturated blur whose sharper edge refracts the colourful shapes drifting behind it, with an opaque fallback when transparency is reduced.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A help block shaped like a conversation: bubbles, three animated typing dots and clickable quick replies that show your answers to frequent questions, frozen under prefers-reduced-motion.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • A paragraph whose words turn from grey to full ink, one by one, as the page scrolls, in pure CSS with a plain-text fallback.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component
  • Four offset, translucent sine waves gently roll along the bottom of a section, each at its own pace.

    • Tailwind
    • React
    • CSS
    • WordPress
    Component