Cards & content / Accordions

Hairline Plus Accordion

'Our Products' title above stacked rows separated by thin green hairlines; each row is a medium-weight label with a thin plus icon on the right. Below sit circled-arrow shop links in small bold type, beside a soft-shadow capsule image.

Rebuilt from seed.com/approach in the Verdant Lab Editorial style.

npx shadcn@latest add https://justyoink.it/r/verdant-lab-editorial/blocks/plus-accordion-list.json

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

Usage

Props: number, heading, listTitle, items ({title, body}[]) and links ({label, href}[]). Click a row to expand it; the plus turns into a minus and the arrow circles fill on hover.

components/plus-accordion-list.tsx
"use client";

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

type Item = { title: string; body: string };
type Link = { label: string; href: string };

export default function HairlineplusAccordion(props: { number?: string; heading?: string; listTitle?: string; items?: Item[]; links?: Link[] }) {
  const {
    number = "03",
    heading = "Sourcing",
    listTitle = "Our Range",
    items = [
      { title: "Origin + Harvest Tracking", body: "Every batch is traced from the field to the finished capsule, with records kept for each lot." },
      { title: "Purity Checks", body: "Independent labs screen each lot for residues and heavy metals before release." },
      { title: "Packaging Standards", body: "Sealed, light-proof containers protect freshness through the full shelf life." },
    ],
    links = [
      { label: "Shop Daily Greens", href: "#" },
      { label: "Shop Kids Daily Greens", href: "#" },
    ],
  } = props;
  const [open, setOpen] = useState<number | null>(null);

  return (
    <section className="bg-canvas text-ink font-sans px-5 md:px-[50px] pb-24">
      <div className="border-t border-ink grid grid-cols-1 md:grid-cols-2 pt-5">
        <span className="text-h1 font-light text-5xl">{number}</span>
        <h2 className="text-5xl font-light md:-ml-[130px] md:pl-0 mt-2 md:mt-0">{heading}</h2>
      </div>
      <div className="mt-16 md:mt-28 grid md:grid-cols-2 gap-10 items-start">
        <Reveal from="scale">
          <div className="relative mx-auto aspect-square w-full max-w-[560px]">
            <div className="absolute inset-0 rounded-full bg-[radial-gradient(circle,#fff_0%,#fff_45%,#ececec_62%,#f6f6f6_75%,transparent_100%)]" />
            <div className="absolute inset-[18%] rounded-full bg-[radial-gradient(circle_at_40%_35%,#fff,#f3f3f3)] shadow-[inset_0_10px_40px_rgba(0,0,0,0.08)]" />
            <div className="absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 h-[12%] w-[4.5%] rounded-full bg-gradient-to-r from-[#0f2a14] via-[#274a2c] to-[#0b1f10] shadow-[10px_8px_14px_rgba(0,0,0,0.3)]" />
          </div>
        </Reveal>
        <div className="md:pt-16 max-w-[470px]">
          <h3 className="text-3xl font-light mb-6">{listTitle}</h3>
          <ul className="border-t border-ink/30">
            {items.map((it, i) => {
              const isOpen = open === i;
              return (
                <li key={it.title} className="border-b border-ink/30">
                  <button
                    type="button"
                    aria-expanded={isOpen}
                    onClick={() => setOpen(isOpen ? null : i)}
                    className="flex w-full items-center justify-between py-6 text-left font-medium text-[17px] focus-visible:outline focus-visible:outline-2 focus-visible:outline-ink"
                  >
                    {it.title}
                    <svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" className={`transition-transform duration-ui-hover ${isOpen ? "rotate-180" : ""}`} aria-hidden="true">
                      <path d="M8 0v16" className={`origin-center transition-opacity duration-ui-hover ${isOpen ? "opacity-0" : "opacity-100"}`} />
                      <path d="M0 8h16" />
                    </svg>
                  </button>
                  <div className={`grid transition-all duration-slide-panel ease-slide-panel ${isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"}`}>
                    <p className="overflow-hidden text-body text-ink/80 pr-8"><span className="block pb-6">{it.body}</span></p>
                  </div>
                </li>
              );
            })}
          </ul>
          <div className="mt-8 flex flex-col gap-6">
            {links.map((l) => (
              <a key={l.label} href={l.href} className="group flex items-center gap-4 text-sm font-bold focus-visible:outline focus-visible:outline-2 focus-visible:outline-ink">
                <span className="flex h-[26px] w-[26px] items-center justify-center rounded-full border border-ink transition-all duration-ui-hover ease-ui-hover group-hover:bg-ink group-hover:text-canvas">
                  <svg width="14" height="10" viewBox="0 0 14 10" fill="none" stroke="currentColor" aria-hidden="true"><path d="M0 5h13M9 1l4 4-4 4" /></svg>
                </span>
                {l.label}
              </a>
            ))}
          </div>
        </div>
      </div>
    </section>
  );
}

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

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;
}

type YkRevealFrom = "up" | "down" | "left" | "right" | "scale" | "blur" | "none";

/** Fades content in as it scrolls into view. */
function Reveal({
  children,
  from = "up",
  delay = 0,
  duration = 700,
  distance = 24,
  once = true,
  as = "div",
  className,
  style,
}: {
  children?: ReactNode;
  from?: YkRevealFrom;
  delay?: number;
  duration?: number;
  distance?: number;
  once?: boolean;
  as?: ElementType;
  className?: string;
  style?: CSSProperties;
}) {
  const Tag = as;
  const ref = useRef<HTMLElement>(null);
  const state = useYkReveal(ref, once);
  const hidden = state === "hidden";
  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.94)",
    blur: `translate3d(0, ${distance / 2}px, 0)`,
    none: "none",
  }[from];
  const t = `${duration}ms ${YK_EASE} ${delay}ms`;
  return (
    <Tag
      ref={ref}
      className={className}
      style={{
        ...style,
        ...(hidden && { opacity: 0, transform: offset, filter: from === "blur" ? "blur(12px)" : undefined }),
        ...(state === "shown" && { transition: `opacity ${t}, transform ${t}, filter ${t}` }),
      }}
    >
      {children}
    </Tag>
  );
}

Quality checks

Automated, in a real browser · 4d ago
—

More from Verdant Lab Editorial

The whole style →

Center-Focus Video Story Carousel

Carousels

Frosted Glass Photo Hero

Heroes

Offer Popup Dialog

Dialogs & modals

Timeline Benefit Tiles

Feature sections

Glass Panel Annotated Capsule

Feature sections

Centered Product Quartet

Feature sections