Hairline Chevron Accordion
Two-column FAQ: large 36px heading on the left, right column of question rows separated by 1px hairlines, each with a down chevron at the far right.
Rebuilt from cursor.com/pricing in the Warm Paper Editorial style.
npx shadcn@latest add https://justyoink.it/r/warm-paper-editorial/blocks/faq-hairline-accordion.json
Looks exactly like cursor.com: brings its fonts and colours, namespaced so your own theme stays untouched.
npx shadcn@latest add https://justyoink.it/r/warm-paper-editorial/mine/faq-hairline-accordion.json
Restyled to your project: uses your shadcn colours, fonts and radius, so it matches the rest of your app. Layout, type sizes and motion stay as designed.
Usage
Props: heading (string) and items (array of {q, a}). Click a row to expand it in place; the chevron rotates and the hairline stays. Only one row is open at a time.
components/faq-hairline-accordion.tsx
"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Item = { q: string; a: string }; const DEFAULT_ITEMS: Item[] = [ { q: "Which plan suits a small team?", a: "Start with the shared tier if you have fewer than ten people. You can move up at any time and the change is prorated automatically." }, { q: "How can I pay for my subscription?", a: "We accept major credit cards and bank transfers for annual billing. Invoices are available from the billing page." }, { q: "How do monthly allowances work?", a: "Each plan includes a fixed allowance that resets at the start of every billing cycle. You will be notified before reaching it." }, { q: "Is the sandbox environment included?", a: "Yes, every plan includes a sandbox for testing with reduced limits and no extra charge." }, { q: "Which integrations are supported?", a: "We support the most popular editors, version control hosts and chat tools. The full list lives in the documentation." }, { q: "Do listed prices include tax?", a: "Prices are shown before tax. Applicable taxes are calculated at checkout based on your billing address." }, { q: "How do I manage usage across my organization?", a: "Admins can view activity per member, set spending caps and export reports from the organization dashboard." }, { q: "How is my information handled?", a: "Your content is encrypted in transit and at rest, and is never used to train shared models unless you opt in." }, { q: "Can I purchase through a partner?", a: "Yes, authorized partners can sell licenses. Contact our sales team and we will connect you with one in your region." }, ]; export default function HairlineChevronAccordion({ heading = "Common Questions", items = DEFAULT_ITEMS, }: { heading?: string; items?: Item[]; }) { const [open, setOpen] = useState<number | null>(null); return ( <section className="bg-canvas text-ink font-sans"> <div className="mx-auto grid max-w-[1300px] gap-10 px-6 py-16 md:grid-cols-2 md:gap-16 md:py-24"> <Reveal from="up"> <h2 className="text-[36px] leading-[1.15] tracking-[-0.02em] font-normal">{heading}</h2> </Reveal> <ul className="border-t border-hairline md:ml-auto md:w-full"> {items.map((it, i) => { const isOpen = open === i; return ( <li key={i} className="border-b border-hairline"> <h3> <button type="button" aria-expanded={isOpen} aria-controls={`faq-panel-${i}`} onClick={() => setOpen(isOpen ? null : i)} className="flex w-full items-center justify-between gap-6 py-[18px] text-left text-[16px] leading-6 text-ink transition-colors duration-hover-color ease-hover-color hover:text-ink/75 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ink" > <span>{it.q}</span> <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true" className={`shrink-0 transition-transform duration-300 ${isOpen ? "rotate-180" : ""}`} > <path d="M2 5.5l6 6 6-6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /> </svg> </button> </h3> <div id={`faq-panel-${i}`} role="region" className={`grid transition-[grid-template-rows,opacity] duration-300 ease-out ${isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"}`} > <div className="overflow-hidden"> <p className="pb-5 pr-10 text-[15px] leading-6 text-ink-muted">{it.a}</p> </div> </div> </li> ); })} </ul> </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> ); }"use client"; import { useEffect, useLayoutEffect, useRef, type CSSProperties, type ElementType, type ReactNode, type RefObject } from "react"; import { useState } from "react"; type Item = { q: string; a: string }; const DEFAULT_ITEMS: Item[] = [ { q: "Which plan suits a small team?", a: "Start with the shared tier if you have fewer than ten people. You can move up at any time and the change is prorated automatically." }, { q: "How can I pay for my subscription?", a: "We accept major credit cards and bank transfers for annual billing. Invoices are available from the billing page." }, { q: "How do monthly allowances work?", a: "Each plan includes a fixed allowance that resets at the start of every billing cycle. You will be notified before reaching it." }, { q: "Is the sandbox environment included?", a: "Yes, every plan includes a sandbox for testing with reduced limits and no extra charge." }, { q: "Which integrations are supported?", a: "We support the most popular editors, version control hosts and chat tools. The full list lives in the documentation." }, { q: "Do listed prices include tax?", a: "Prices are shown before tax. Applicable taxes are calculated at checkout based on your billing address." }, { q: "How do I manage usage across my organization?", a: "Admins can view activity per member, set spending caps and export reports from the organization dashboard." }, { q: "How is my information handled?", a: "Your content is encrypted in transit and at rest, and is never used to train shared models unless you opt in." }, { q: "Can I purchase through a partner?", a: "Yes, authorized partners can sell licenses. Contact our sales team and we will connect you with one in your region." }, ]; export default function HairlineChevronAccordion({ heading = "Common Questions", items = DEFAULT_ITEMS, }: { heading?: string; items?: Item[]; }) { const [open, setOpen] = useState<number | null>(null); return ( <section className="bg-background text-foreground font-sans"> <div className="mx-auto grid max-w-[1300px] gap-10 px-6 py-16 md:grid-cols-2 md:gap-16 md:py-24"> <Reveal from="up"> <h2 className="text-[36px] leading-[1.15] tracking-[-0.02em] font-normal">{heading}</h2> </Reveal> <ul className="border-t border-border md:ml-auto md:w-full"> {items.map((it, i) => { const isOpen = open === i; return ( <li key={i} className="border-b border-border"> <h3> <button type="button" aria-expanded={isOpen} aria-controls={`faq-panel-${i}`} onClick={() => setOpen(isOpen ? null : i)} className="flex w-full items-center justify-between gap-6 py-[18px] text-left text-[16px] leading-6 text-foreground transition-colors duration-warm-hover-color ease-warm-hover-color hover:text-foreground/75 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-foreground" > <span>{it.q}</span> <svg width="16" height="16" viewBox="0 0 16 16" fill="none" aria-hidden="true" className={`shrink-0 transition-transform duration-300 ${isOpen ? "rotate-180" : ""}`} > <path d="M2 5.5l6 6 6-6" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round" /> </svg> </button> </h3> <div id={`faq-panel-${i}`} role="region" className={`grid transition-[grid-template-rows,opacity] duration-300 ease-out ${isOpen ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"}`} > <div className="overflow-hidden"> <p className="pb-5 pr-10 text-[15px] leading-6 text-muted-foreground">{it.a}</p> </div> </div> </li> ); })} </ul> </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- Accessible: passedNo serious accessibility problems (axe-core): readable contrast, labelled buttons and images.
- Responsive: passedRenders at phone (390px), tablet (768px) and desktop width without sideways scrolling.
- Dark mode: passedStill readable when installed in your theme and switched to dark mode.
- Themeable: passedUses design tokens rather than hard-coded colours, so it follows your theme cleanly.
- Animates cleanly: not passedStays invisible after its animation: <div> "Start with the shared tier if you have f"Stays invisible after its animation: <div> "We accept major credit cards and bank tr"Stays invisible after its animation: <div> "Each plan includes a fixed allowance tha"Stays invisible after its animation: <div> "Yes, every plan includes a sandbox for t"