Page sections / Feature sections

Keycap Feature Grid

A faded grid of 3D keyboard keys with a few keys expanded into value-prop tiles (Fast, Ergonomic, Personal, Reliable) using bold lead-in words. Masked with radial edge fades beside left-aligned copy and a download button.

Rebuilt from raycast.com in the Obsidian Launcher style.

npx shadcn@latest add https://justyoink.it/r/obsidian-launcher/blocks/keycap-feature-grid.json

Looks exactly like raycast.com: brings its fonts and colours, namespaced so your own theme stays untouched.

Usage

Props: headline, subline, buttonLabel, and tiles (array of {label} keys or {lead,text,span} value-prop tiles). Hovering or focusing the button slides the key backdrop 20px; tiles stagger in on load.

components/keycap-feature-grid.tsx
"use client";

import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react";
import { useState } from "react";

type Tile = { lead?: string; text?: string; label?: string; span?: number; icon?: string };

const DEFAULT_TILES: Tile[] = [
  { label: "esc" }, { label: "F1" }, { label: "F2" }, { label: "F3" },
  { label: "§" }, { label: "1" }, { label: "2" }, { label: "3" },
  { label: "⇥", icon: "tab" },
  { lead: "Quick.", text: "Act in a blink.", span: 2, icon: "clock" },
  { lead: "Comfortable.", text: "Built around keys.", span: 2, icon: "cmd" },
  { lead: "Yours.", text: "Shape it to fit.", span: 2, icon: "user" },
  { lead: "Steady.", text: "Rarely ever fails.", span: 2, icon: "bug" },
  { label: "S" }, { label: "D" },
  { label: "⇧" }, { label: "~" }, { label: "Z" }, { label: "X" },
];

export default function KeycapFeatureGrid({
  headline = "It’s not about being busy.",
  subline = "It’s about ending each day feeling like it counted.",
  buttonLabel = "Get the app",
  tiles = DEFAULT_TILES,
}: {
  headline?: string;
  subline?: string;
  buttonLabel?: string;
  tiles?: Tile[];
}) {
  const [hover, setHover] = useState(false);
  return (
    <section className="relative isolate flex min-h-[720px] w-full items-center overflow-hidden bg-canvas text-primary">
      <div
        aria-hidden
        className={`absolute inset-y-0 right-0 w-full md:w-[60%] transition-transform duration-300 ease-in-out ${hover ? "translate-x-5" : "translate-x-0"} opacity-30 [mask-image:radial-gradient(95%_70%_at_70%_48%,black_17%,transparent)]`}
      >
        <Stagger step={140} from="up" distance={30} duration={700} className="grid grid-cols-4 gap-3 p-6 auto-rows-[110px]">
          {tiles.map((t, i) => (
            <div
              key={i}
              style={{ gridColumn: t.span ? `span ${t.span}` : undefined }}
              className="flex flex-col justify-between rounded-xl border border-hairline bg-keycap-face p-4 shadow-keycap transition-all duration-[400ms] hover:bg-surface-hover"
            >
              {t.icon && <span className="h-4 w-4 rounded-full border border-tertiary" />}
              {t.lead ? (
                <p className="text-ui text-tertiary"><b className="text-primary">{t.lead}</b> {t.text}</p>
              ) : (
                <span className="m-auto text-section-title text-secondary">{t.label}</span>
              )}
            </div>
          ))}
        </Stagger>
      </div>
      <div aria-hidden className="absolute inset-y-0 left-0 w-[45%] bg-[linear-gradient(90deg,var(--color-canvas)_50%,transparent)]" />
      <div className="relative z-10 max-w-sm px-8 md:px-[142px] md:max-w-xl">
        <h2 className="text-body-lg text-primary">{headline}</h2>
        <p className="text-body-lg text-tertiary">{subline}</p>
        <button
          onMouseEnter={() => setHover(true)}
          onMouseLeave={() => setHover(false)}
          onFocus={() => setHover(true)}
          onBlur={() => setHover(false)}
          className="mt-12 inline-flex items-center gap-2 rounded-lg bg-button-light px-3 py-2 text-ui text-surface-elevated shadow-keycap transition-all duration-button-lift ease-button-lift hover:bg-white hover:shadow-button-light-hover focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent-red"
        >
          <span aria-hidden className="h-3 w-3 rounded-full bg-surface-elevated" />
          {buttonLabel}
        </button>
      </div>
    </section>
  );
}

// ---- Yoink motion (inlined, no dependencies): Stagger ----

const YK_EASE = "cubic-bezier(0.16, 1, 0.3, 1)";

const useYkLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;

function ykReducedMotion(): boolean {
  return typeof window !== "undefined" && !!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches;
}

// "idle": untouched (visible) · "hidden": waiting below the fold · "shown": play the entrance.
// Content is only hidden once we know we can show it again (IntersectionObserver exists, motion allowed,
// and there is a box to watch), and a safety net reveals anything on screen that is still hidden.
type YkRevealState = "idle" | "hidden" | "shown";

function useYkReveal(ref: RefObject<Element | null>, once = true): YkRevealState {
  const [state, setState] = useState<YkRevealState>("idle");
  useYkLayoutEffect(() => {
    const el = ref.current;
    if (!el || ykReducedMotion() || typeof IntersectionObserver === "undefined") return;
    // watch the element's own box, or its children when it has none (display: contents)
    const boxes = () => (getComputedStyle(el).display === "contents" ? Array.from(el.children) : [el]);
    const onScreen = (t: Element) => {
      const r = t.getBoundingClientRect();
      return (r.width > 0 || r.height > 0) && r.bottom > 0 && r.right > 0 && r.top < window.innerHeight && r.left < window.innerWidth;
    };
    if (!boxes().some((t) => t.getBoundingClientRect().width > 0 || t.getBoundingClientRect().height > 0)) return; // e.g. hidden at mount: leave it visible
    let shown = false;
    const show = (v: boolean) => {
      if (v !== shown) (shown = v), setState(v ? "shown" : "hidden");
    };
    setState("hidden");
    const inView = new Set<Element>();
    const io = new IntersectionObserver((entries) => {
      for (const e of entries) {
        if (e.isIntersecting) inView.add(e.target);
        else inView.delete(e.target);
      }
      if (inView.size) {
        show(true);
        if (once) io.disconnect();
      } else if (!once) show(false);
    });
    const watched = new Set<Element>();
    const watch = () => boxes().forEach((t) => !watched.has(t) && (watched.add(t), io.observe(t)));
    watch();
    // safety net: styles that land after mount (display: contents) get watched too, and nothing
    // stays hidden for more than a moment while it is actually on screen
    const start = Date.now();
    const net = setInterval(() => {
      if (shown) return once && clearInterval(net);
      watch();
      if (Date.now() - start > 2400 && boxes().some(onScreen)) show(true);
    }, 600);
    return () => {
      io.disconnect();
      clearInterval(net);
    };
  }, [once]);
  return state;
}

/** Reveals each direct child one after another when the group scrolls into view. */
function Stagger({
  children,
  step = 90,
  from = "up",
  distance = 20,
  duration = 650,
  delay = 0,
  once = true,
  as = "div",
  className,
  style,
}: {
  children?: ReactNode;
  step?: number;
  from?: "up" | "down" | "left" | "right" | "scale" | "fade";
  distance?: number;
  duration?: number;
  delay?: number;
  once?: boolean;
  as?: ElementType;
  className?: string;
  style?: CSSProperties;
}) {
  const Tag = as;
  const ref = useRef<HTMLElement>(null);
  const state = useYkReveal(ref, once);
  useYkLayoutEffect(() => {
    const items = Array.from(ref.current?.children ?? []) as HTMLElement[];
    if (state === "idle") return;
    const offset = {
      up: `translate3d(0, ${distance}px, 0)`,
      down: `translate3d(0, ${-distance}px, 0)`,
      left: `translate3d(${-distance}px, 0, 0)`,
      right: `translate3d(${distance}px, 0, 0)`,
      scale: "scale(0.92)",
      fade: "none",
    }[from];
    if (state === "hidden") {
      for (const el of items) Object.assign(el.style, { transition: "none", opacity: "0", transform: offset });
      return;
    }
    items.forEach((el, i) => {
      const t = `${duration}ms ${YK_EASE} ${delay + i * step}ms`;
      Object.assign(el.style, { transition: `opacity ${t}, transform ${t}`, opacity: "", transform: "" });
    });
    // hand the children their own transitions back once everything has landed
    const done = setTimeout(() => items.forEach((el) => (el.style.transition = "")), delay + items.length * step + duration + 50);
    return () => clearTimeout(done);
  }, [state]);
  return (
    <Tag ref={ref} className={className} style={style}>
      {children}
    </Tag>
  );
}

Quality checks

Automated, in a real browser · 4d ago
—

More from Obsidian Launcher

The whole style →

AI Agent Bento Showcase

Feature sections

Blog Category Filter Row

Tab bars

Frosted Pill Navbar

Headers & nav bars

Centered Glow Hero

Heroes

Light Pill Download Button

Buttons

Launcher Window Showcase

Media & mockups