FAQ section
Common questions grouped by topic. A sliding pill picks the topic, and each question in the card opens its answer underneath, one at a time.
Questions, answered
The things people ask before they sign up, grouped by topic.
It keeps your projects, files and feedback in one place, so the team and the client always look at the same thing.
Small studios and freelancers who run a handful of client projects at a time and are tired of chasing email threads.
Yes. Every plan starts with 14 days free, and you do not need a card to begin.
You pay per member, monthly or yearly. Clients you invite to a project are always free.
At any time, from Settings. Moving up takes effect straight away, and moving down applies from your next bill.
If something is not right in the first 30 days, write to us and we will refund the payment in full.
Write to [email protected]. A person answers within one working day, and usually much sooner.
On servers in the EU, backed up every night. You can ask us to delete it for good whenever you like.
Yes. Any project can be downloaded as a zip of its files with the comments in a spreadsheet.
Options
Code
import { useId, useState } from "react";
import "./faq-section.css";
const topics = [
{
name: "General",
questions: [
{ q: "What does Logoipsum do?", a: "It keeps your projects, files and feedback in one place, so the team and the client always look at the same thing." },
{ q: "Who is it for?", a: "Small studios and freelancers who run a handful of client projects at a time and are tired of chasing email threads." },
{ q: "Can I try it before paying?", a: "Yes. Every plan starts with 14 days free, and you do not need a card to begin." },
],
},
{
name: "Billing",
questions: [
{ q: "How does billing work?", a: "You pay per member, monthly or yearly. Clients you invite to a project are always free." },
{ q: "Can I change plan later?", a: "At any time, from Settings. Moving up takes effect straight away, and moving down applies from your next bill." },
{ q: "Do you offer refunds?", a: "If something is not right in the first 30 days, write to us and we will refund the payment in full." },
],
},
{
name: "Support",
questions: [
{ q: "How do I get help?", a: "Write to [email protected]. A person answers within one working day, and usually much sooner." },
{ q: "Where is my data kept?", a: "On servers in the EU, backed up every night. You can ask us to delete it for good whenever you like." },
{ q: "Can I export my work?", a: "Yes. Any project can be downloaded as a zip of its files with the comments in a spreadsheet." },
],
},
];
/* One question. Its answer stays in the page while closed, so it can open
with a transition, and is inert so it cannot be tabbed into. */
function Question({ q, a, open, onToggle }) {
const id = useId();
return (
<div className="dh-faq-item">
<h3>
<button type="button" aria-expanded={open} aria-controls={id} onClick={onToggle}>
{q}
<svg viewBox="0 0 16 16" aria-hidden="true">
<path d="M8 3.5v9" />
<path d="M3.5 8h9" />
</svg>
</button>
</h3>
<div className="dh-faq-answer" id={id} role="region" inert={!open}>
<p>{a}</p>
</div>
</div>
);
}
/* <FaqSection title="Questions, answered" topics={[{ name: "General", questions: [{ q: "…", a: "…" }] }]} /> */
export function FaqSection({
title = "Questions, answered",
text = "The things people ask before they sign up, grouped by topic.",
email = "[email protected]",
topics: list = topics,
}) {
const id = useId();
const [at, setAt] = useState(0);
const [open, setOpen] = useState(0);
const choose = (index) => {
setAt(index);
setOpen(0);
};
/* The arrow keys move between topics, as they do in any set of tabs. */
const onKeyDown = (event) => {
const last = list.length - 1;
const next = { ArrowRight: at === last ? 0 : at + 1, ArrowLeft: at === 0 ? last : at - 1, Home: 0, End: last }[event.key];
if (next === undefined) return;
choose(next);
event.currentTarget.children[next].focus();
};
return (
<section className="dh-faq">
<div className="dh-faq-inner">
<header className="dh-faq-head">
<h2>{title}</h2>
<p>{text}</p>
</header>
<div className="dh-faq-tabs" role="tablist" aria-label="Topics" style={{ "--count": list.length, "--at": at }} onKeyDown={onKeyDown}>
{list.map((topic, index) => (
<button
type="button"
role="tab"
key={topic.name}
id={id + "tab" + index}
aria-controls={id + "panel"}
aria-selected={index === at}
tabIndex={index === at ? 0 : -1}
onClick={() => choose(index)}
>
{topic.name}
</button>
))}
</div>
<aside className="dh-faq-help">
<p>
<b>Not here?</b> Write to us and a person will reply within a working day.
</p>
<a href={"mailto:" + email}>{email}</a>
</aside>
{/* The key makes the list fade in again when the topic changes. */}
<div className="dh-faq-panel" role="tabpanel" id={id + "panel"} aria-labelledby={id + "tab" + at} key={at}>
{list[at].questions.map((item, index) => (
<Question key={item.q} {...item} open={index === open} onToggle={() => setOpen(index === open ? -1 : index)} />
))}
</div>
</div>
</section>
);
}
export function Example() {
return <FaqSection />;
}/* Common questions grouped by topic. The topics are a sunk track with a raised
pill that slides; the questions sit in one card and open one at a time. */
.dh-faq {
container: dh-faq / inline-size;
padding: 24px;
background: var(--dh-bg, #f7f7f6);
color: var(--dh-fg, #171717);
font-family: inherit;
}
.dh-faq *,
.dh-faq *::before,
.dh-faq *::after {
box-sizing: border-box;
}
.dh-faq-inner {
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
--ring: 0 0 0 1px var(--line), 0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
--ease: cubic-bezier(0.23, 1, 0.32, 1);
display: grid;
grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
grid-template-rows: auto auto 1fr;
gap: 0 56px;
max-width: 840px;
margin: 0 auto;
padding: 40px 0;
font-size: 13px;
line-height: 20px;
}
.dh-faq :is(h2, h3, p) {
margin: 0;
}
.dh-faq-head h2 {
font-size: 24px;
font-weight: 500;
line-height: 32px;
letter-spacing: -0.025em;
}
.dh-faq-head p {
margin-top: 6px;
color: var(--dh-muted, #5c5c5c);
}
/* The topic switcher. --count is how many topics there are and --at is the chosen one. */
.dh-faq-tabs {
position: relative;
display: grid;
grid-template-columns: repeat(var(--count), 1fr);
align-self: start;
margin-top: 20px;
padding: 3px;
border-radius: 9px;
background: var(--dh-well, #ededeb);
}
.dh-faq-tabs::before {
content: "";
position: absolute;
top: 3px;
bottom: 3px;
left: 3px;
width: calc((100% - 6px) / var(--count));
border-radius: 6px;
background: var(--dh-raised, #fff);
box-shadow: var(--ring);
translate: calc(var(--at) * 100%) 0;
transition: translate 0.4s cubic-bezier(0.3, 1.25, 0.4, 1);
}
.dh-faq-tabs button {
position: relative;
height: 26px;
padding: 0 10px;
border: 0;
border-radius: 6px;
background: none;
color: var(--dh-muted, #5c5c5c);
font: inherit;
font-size: 12px;
font-weight: 500;
letter-spacing: -0.01em;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: color 0.15s var(--ease);
}
.dh-faq-tabs button[aria-selected="true"] {
color: var(--dh-fg, #171717);
}
.dh-faq :is(button, a):focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 1px;
}
/* A quiet note under the topics, for a question that is not in the list. */
.dh-faq-help {
align-self: end;
margin-top: 24px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: var(--dh-muted, #5c5c5c);
font-size: 12px;
line-height: 18px;
}
.dh-faq-help b {
color: var(--dh-fg, #171717);
font-weight: 500;
}
.dh-faq-help a {
display: inline-block;
margin-top: 8px;
padding: 1px 6px;
border-radius: 5px;
background: color-mix(in srgb, var(--accent) 12%, transparent);
color: color-mix(in srgb, var(--accent) 80%, var(--dh-fg, #171717));
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
text-decoration: none;
}
/* The questions of one topic, in one card. */
.dh-faq-panel {
grid-area: 1 / 2 / -1;
align-self: start;
overflow: hidden;
border-radius: 14px;
background: var(--dh-raised, #fff);
box-shadow: var(--ring);
animation: dh-faq-in 0.3s var(--ease) both;
}
.dh-faq-panel[hidden] {
display: none;
}
.dh-faq-item + .dh-faq-item {
border-top: 1px solid var(--line);
}
.dh-faq-item button {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
width: 100%;
min-height: 48px;
padding: 12px 14px 12px 16px;
border: 0;
background: none;
color: inherit;
font: inherit;
font-size: 14px;
font-weight: 500;
letter-spacing: -0.015em;
text-align: left;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.dh-faq-item button:focus-visible {
outline-offset: -3px;
border-radius: 12px;
}
/* The plus sits in a small raised tile. Opening the question turns it into
a minus and colours the tile with your accent. */
.dh-faq-item svg {
flex: none;
width: 22px;
height: 22px;
padding: 5px;
border-radius: 6px;
background: var(--dh-raised, #fff);
box-shadow: var(--ring);
fill: none;
stroke: var(--dh-muted, #5c5c5c);
stroke-width: 1.5;
stroke-linecap: round;
transition:
rotate 0.3s var(--ease),
background-color 0.2s var(--ease),
stroke 0.2s var(--ease);
}
.dh-faq-item svg path:first-child {
transform-origin: center;
transition: scale 0.3s var(--ease);
}
.dh-faq-item button[aria-expanded="true"] svg {
background: color-mix(in srgb, var(--accent) 12%, var(--dh-raised, #fff));
box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
stroke: color-mix(in srgb, var(--accent) 80%, var(--dh-fg, #171717));
rotate: 180deg;
}
.dh-faq-item button[aria-expanded="true"] svg path:first-child {
scale: 1 0;
}
/* The answer opens by growing a grid row from nothing to its own height. */
.dh-faq-answer {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 0.3s var(--ease);
}
.dh-faq-item:has(button[aria-expanded="true"]) .dh-faq-answer {
grid-template-rows: 1fr;
}
.dh-faq-answer p {
min-height: 0;
overflow: hidden;
max-width: 440px;
padding: 0 16px;
color: var(--dh-muted, #5c5c5c);
opacity: 0;
filter: blur(4px);
transition:
opacity 0.3s var(--ease),
filter 0.3s var(--ease),
padding 0.3s var(--ease);
}
.dh-faq-item:has(button[aria-expanded="true"]) .dh-faq-answer p {
padding-bottom: 16px;
opacity: 1;
filter: none;
}
@media (hover: hover) and (pointer: fine) {
.dh-faq-tabs button:hover {
color: var(--dh-fg, #171717);
}
.dh-faq-item button:hover svg {
stroke: var(--dh-fg, #171717);
}
.dh-faq-help a:hover {
background: color-mix(in srgb, var(--accent) 18%, transparent);
}
}
/* In a narrow space everything is one column, and the targets grow. */
@container dh-faq (max-width: 680px) {
.dh-faq {
padding: 16px;
}
.dh-faq-inner {
grid-template-columns: minmax(0, 1fr);
grid-template-rows: none;
padding: 16px 0;
font-size: 15px;
line-height: 22px;
}
.dh-faq-tabs button {
height: 38px;
font-size: 14px;
}
.dh-faq-panel {
grid-area: auto;
margin-top: 16px;
}
.dh-faq-help {
order: 1;
font-size: 14px;
line-height: 20px;
}
.dh-faq-item button {
min-height: 52px;
font-size: 15px;
}
}
@keyframes dh-faq-in {
from {
opacity: 0;
filter: blur(4px);
transform: translateY(-4px);
}
}
@media (prefers-reduced-motion: reduce) {
.dh-faq-tabs::before,
.dh-faq-item svg,
.dh-faq-item svg path:first-child,
.dh-faq-answer,
.dh-faq-answer p {
transition: none;
}
.dh-faq-panel {
animation: none;
}
}<section class="dh-faq">
<div class="dh-faq-inner">
<header class="dh-faq-head">
<h2>Questions, answered</h2>
<p>The things people ask before they sign up, grouped by topic.</p>
</header>
<div class="dh-faq-tabs" role="tablist" aria-label="Topics" style="--count: 3; --at: 0">
<button type="button" role="tab" id="dh-faq-tab-1" aria-controls="dh-faq-panel-1" aria-selected="true">General</button>
<button type="button" role="tab" id="dh-faq-tab-2" aria-controls="dh-faq-panel-2" aria-selected="false" tabindex="-1">Billing</button>
<button type="button" role="tab" id="dh-faq-tab-3" aria-controls="dh-faq-panel-3" aria-selected="false" tabindex="-1">Support</button>
</div>
<aside class="dh-faq-help">
<p><b>Not here?</b> Write to us and a person will reply within a working day.</p>
<a href="mailto:[email protected]">[email protected]</a>
</aside>
<div class="dh-faq-panel" role="tabpanel" id="dh-faq-panel-1" aria-labelledby="dh-faq-tab-1">
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="true" aria-controls="dh-faq-answer-1-1">What does Logoipsum do?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-1-1" role="region"><p>It keeps your projects, files and feedback in one place, so the team and the client always look at the same thing.</p></div>
</div>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="false" aria-controls="dh-faq-answer-1-2">Who is it for?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-1-2" role="region" inert><p>Small studios and freelancers who run a handful of client projects at a time and are tired of chasing email threads.</p></div>
</div>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="false" aria-controls="dh-faq-answer-1-3">Can I try it before paying?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-1-3" role="region" inert><p>Yes. Every plan starts with 14 days free, and you do not need a card to begin.</p></div>
</div>
</div>
<div class="dh-faq-panel" role="tabpanel" id="dh-faq-panel-2" aria-labelledby="dh-faq-tab-2" hidden>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="true" aria-controls="dh-faq-answer-2-1">How does billing work?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-2-1" role="region"><p>You pay per member, monthly or yearly. Clients you invite to a project are always free.</p></div>
</div>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="false" aria-controls="dh-faq-answer-2-2">Can I change plan later?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-2-2" role="region" inert><p>At any time, from Settings. Moving up takes effect straight away, and moving down applies from your next bill.</p></div>
</div>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="false" aria-controls="dh-faq-answer-2-3">Do you offer refunds?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-2-3" role="region" inert><p>If something is not right in the first 30 days, write to us and we will refund the payment in full.</p></div>
</div>
</div>
<div class="dh-faq-panel" role="tabpanel" id="dh-faq-panel-3" aria-labelledby="dh-faq-tab-3" hidden>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="true" aria-controls="dh-faq-answer-3-1">How do I get help?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-3-1" role="region"><p>Write to [email protected]. A person answers within one working day, and usually much sooner.</p></div>
</div>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="false" aria-controls="dh-faq-answer-3-2">Where is my data kept?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-3-2" role="region" inert><p>On servers in the EU, backed up every night. You can ask us to delete it for good whenever you like.</p></div>
</div>
<div class="dh-faq-item">
<h3><button type="button" aria-expanded="false" aria-controls="dh-faq-answer-3-3">Can I export my work?<svg viewBox="0 0 16 16" aria-hidden="true"><path d="M8 3.5v9" /><path d="M3.5 8h9" /></svg></button></h3>
<div class="dh-faq-answer" id="dh-faq-answer-3-3" role="region" inert><p>Yes. Any project can be downloaded as a zip of its files with the comments in a spreadsheet.</p></div>
</div>
</div>
</div>
</section>/* Common questions grouped by topic. The topics are a sunk track with a raised
pill that slides; the questions sit in one card and open one at a time. */
.dh-faq {
container: dh-faq / inline-size;
padding: 24px;
background: var(--dh-bg, #f7f7f6);
color: var(--dh-fg, #171717);
font-family: inherit;
}
.dh-faq *,
.dh-faq *::before,
.dh-faq *::after {
box-sizing: border-box;
}
.dh-faq-inner {
--accent: var(--dh-accent, #2563ff);
--line: color-mix(in srgb, var(--dh-fg, #171717) 9%, transparent);
--ring: 0 0 0 1px var(--line), 0 1px 2px color-mix(in srgb, var(--dh-fg, #171717) 10%, transparent);
--ease: cubic-bezier(0.23, 1, 0.32, 1);
display: grid;
grid-template-columns: minmax(0, 280px) minmax(0, 1fr);
grid-template-rows: auto auto 1fr;
gap: 0 56px;
max-width: 840px;
margin: 0 auto;
padding: 40px 0;
font-size: 13px;
line-height: 20px;
}
.dh-faq :is(h2, h3, p) {
margin: 0;
}
.dh-faq-head h2 {
font-size: 24px;
font-weight: 500;
line-height: 32px;
letter-spacing: -0.025em;
}
.dh-faq-head p {
margin-top: 6px;
color: var(--dh-muted, #5c5c5c);
}
/* The topic switcher. --count is how many topics there are and --at is the chosen one. */
.dh-faq-tabs {
position: relative;
display: grid;
grid-template-columns: repeat(var(--count), 1fr);
align-self: start;
margin-top: 20px;
padding: 3px;
border-radius: 9px;
background: var(--dh-well, #ededeb);
}
.dh-faq-tabs::before {
content: "";
position: absolute;
top: 3px;
bottom: 3px;
left: 3px;
width: calc((100% - 6px) / var(--count));
border-radius: 6px;
background: var(--dh-raised, #fff);
box-shadow: var(--ring);
translate: calc(var(--at) * 100%) 0;
transition: translate 0.4s cubic-bezier(0.3, 1.25, 0.4, 1);
}
.dh-faq-tabs button {
position: relative;
height: 26px;
padding: 0 10px;
border: 0;
border-radius: 6px;
background: none;
color: var(--dh-muted, #5c5c5c);
font: inherit;
font-size: 12px;
font-weight: 500;
letter-spacing: -0.01em;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
transition: color 0.15s var(--ease);
}
.dh-faq-tabs button[aria-selected="true"] {
color: var(--dh-fg, #171717);
}
.dh-faq :is(button, a):focus-visible {
outline: 2px solid var(--dh-faint, #8a8a8a);
outline-offset: 1px;
}
/* A quiet note under the topics, for a question that is not in the list. */
.dh-faq-help {
align-self: end;
margin-top: 24px;
padding-top: 14px;
border-top: 1px solid var(--line);
color: var(--dh-muted, #5c5c5c);
font-size: 12px;
line-height: 18px;
}
.dh-faq-help b {
color: var(--dh-fg, #171717);
font-weight: 500;
}
.dh-faq-help a {
display: inline-block;
margin-top: 8px;
padding: 1px 6px;
border-radius: 5px;
background: color-mix(in srgb, var(--accent) 12%, transparent);
color: color-mix(in srgb, var(--accent) 80%, var(--dh-fg, #171717));
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
font-size: 11px;
text-decoration: none;
}
/* The questions of one topic, in one card. */
.dh-faq-panel {
grid-area: 1 / 2 / -1;
align-self: start;
overflow: hidden;
border-radius: 14px;
background: var(--dh-raised, #fff);
box-shadow: var(--ring);
animation: dh-faq-in 0.3s var(--ease) both;
}
.dh-faq-panel[hidden] {
display: none;
}
.dh-faq-item + .dh-faq-item {
border-top: 1px solid var(--line);
}
.dh-faq-item button {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
width: 100%;
min-height: 48px;
padding: 12px 14px 12px 16px;
border: 0;
background: none;
color: inherit;
font: inherit;
font-size: 14px;
font-weight: 500;
letter-spacing: -0.015em;
text-align: left;
cursor: pointer;
-webkit-tap-highlight-color: transparent;
}
.dh-faq-item button:focus-visible {
outline-offset: -3px;
border-radius: 12px;
}
/* The plus sits in a small raised tile. Opening the question turns it into
a minus and colours the tile with your accent. */
.dh-faq-item svg {
flex: none;
width: 22px;
height: 22px;
padding: 5px;
border-radius: 6px;
background: var(--dh-raised, #fff);
box-shadow: var(--ring);
fill: none;
stroke: var(--dh-muted, #5c5c5c);
stroke-width: 1.5;
stroke-linecap: round;
transition:
rotate 0.3s var(--ease),
background-color 0.2s var(--ease),
stroke 0.2s var(--ease);
}
.dh-faq-item svg path:first-child {
transform-origin: center;
transition: scale 0.3s var(--ease);
}
.dh-faq-item button[aria-expanded="true"] svg {
background: color-mix(in srgb, var(--accent) 12%, var(--dh-raised, #fff));
box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent);
stroke: color-mix(in srgb, var(--accent) 80%, var(--dh-fg, #171717));
rotate: 180deg;
}
.dh-faq-item button[aria-expanded="true"] svg path:first-child {
scale: 1 0;
}
/* The answer opens by growing a grid row from nothing to its own height. */
.dh-faq-answer {
display: grid;
grid-template-rows: 0fr;
transition: grid-template-rows 0.3s var(--ease);
}
.dh-faq-item:has(button[aria-expanded="true"]) .dh-faq-answer {
grid-template-rows: 1fr;
}
.dh-faq-answer p {
min-height: 0;
overflow: hidden;
max-width: 440px;
padding: 0 16px;
color: var(--dh-muted, #5c5c5c);
opacity: 0;
filter: blur(4px);
transition:
opacity 0.3s var(--ease),
filter 0.3s var(--ease),
padding 0.3s var(--ease);
}
.dh-faq-item:has(button[aria-expanded="true"]) .dh-faq-answer p {
padding-bottom: 16px;
opacity: 1;
filter: none;
}
@media (hover: hover) and (pointer: fine) {
.dh-faq-tabs button:hover {
color: var(--dh-fg, #171717);
}
.dh-faq-item button:hover svg {
stroke: var(--dh-fg, #171717);
}
.dh-faq-help a:hover {
background: color-mix(in srgb, var(--accent) 18%, transparent);
}
}
/* In a narrow space everything is one column, and the targets grow. */
@container dh-faq (max-width: 680px) {
.dh-faq {
padding: 16px;
}
.dh-faq-inner {
grid-template-columns: minmax(0, 1fr);
grid-template-rows: none;
padding: 16px 0;
font-size: 15px;
line-height: 22px;
}
.dh-faq-tabs button {
height: 38px;
font-size: 14px;
}
.dh-faq-panel {
grid-area: auto;
margin-top: 16px;
}
.dh-faq-help {
order: 1;
font-size: 14px;
line-height: 20px;
}
.dh-faq-item button {
min-height: 52px;
font-size: 15px;
}
}
@keyframes dh-faq-in {
from {
opacity: 0;
filter: blur(4px);
transform: translateY(-4px);
}
}
@media (prefers-reduced-motion: reduce) {
.dh-faq-tabs::before,
.dh-faq-item svg,
.dh-faq-item svg path:first-child,
.dh-faq-answer,
.dh-faq-answer p {
transition: none;
}
.dh-faq-panel {
animation: none;
}
}document.querySelectorAll(".dh-faq").forEach((faq) => {
const strip = faq.querySelector(".dh-faq-tabs");
const tabs = [...strip.querySelectorAll("[role=tab]")];
/* Choosing a topic slides the pill and swaps the list of questions. */
const choose = (index, focus) => {
tabs.forEach((tab, at) => {
const on = at === index;
tab.setAttribute("aria-selected", String(on));
tab.tabIndex = on ? 0 : -1;
faq.querySelector("#" + tab.getAttribute("aria-controls")).hidden = !on;
});
strip.style.setProperty("--at", index);
if (focus) tabs[index].focus();
};
tabs.forEach((tab, index) => {
tab.addEventListener("click", () => choose(index));
tab.addEventListener("keydown", (event) => {
const step = { ArrowRight: 1, ArrowLeft: -1 }[event.key];
if (step) choose((index + step + tabs.length) % tabs.length, true);
if (event.key === "Home") choose(0, true);
if (event.key === "End") choose(tabs.length - 1, true);
});
});
/* Opening a question closes the one that was open in the same topic. */
faq.querySelectorAll(".dh-faq-item button").forEach((button) => {
button.addEventListener("click", () => {
const open = button.getAttribute("aria-expanded") === "true";
button.closest(".dh-faq-panel").querySelectorAll(".dh-faq-item button").forEach((other) => {
const on = other === button && !open;
other.setAttribute("aria-expanded", String(on));
other.parentElement.nextElementSibling.inert = !on;
});
});
});
});FAQ section is not in the Figma file yet.
Use the React or HTML code for now.