Skip to the content

FAQ accordion

A list of questions and answers, written as plain markup: one block per question, a heading and whatever the answer holds, three questions or thirty.

Become a member to unlock the full effect today.

Join now

Already a member? Sign in

Documentation

  1. Copy to Webflow

    Add Geist and Geist Mono to your site's fonts (Site settings, Fonts, Google Fonts) before pasting: Webflow removes any font your site has not installed.

  2. Add custom CSS

    The look of the preview is the faq-* classes of the paste. The Embed holds what moves, and reads a few variables, --faq-ink, --faq-gutter (the column of the signs, and where the answers start), --faq-pad (the space above and below a question), --faq-mark and --faq-stroke (the plus): set them on the list, or on anything above it, in a rule of your own. The space under an open answer is the bottom padding of the answer's class.
  3. Add custom JS

  4. Use it on your own elements

    Custom attributes
    Select the element on the canvas and open the Settings panel. Under Custom attributes, add a pair: the name on the left, the value on the right.
    Custom attributeWhat it does
    data-faq Marks the list of questions. It takes no value: leave the value field empty. The settings below go on the same element.
    data-faq-item On the block that holds one question and its answer. It takes no value. Repeat it for each question, three or thirty. Its id is what the address carries: page#delivery opens that question. In Webflow the id is the ID field of the Settings panel. Without an id the engine writes one from the words of the question. [ Required ]
    data-faq-question On the question: a heading that holds the words and nothing else. It takes no value. The engine puts a real button in it, with the sign before the words. An item without one is left alone and the engine says so in the console. [ Required ]
    data-faq-answer On the block that holds the answer. It takes no value. It holds anything, one line or three paragraphs, links and lists, and its height is never measured. [ Required ]
    data-faq-open A state, not a mark to write: the engine puts it on an open item, and takes it off. The button carries aria-expanded, an item on its way data-faq-moving, a list with an answer open data-faq-any, a mounted list data-faq-ready. Never written by hand; the stylesheet reads them, and so can a rule of yours. [ Optional ]
    Settings
    Every setting is a custom attribute too, added the same way and on the same element. An attribute always wins over the defaults written in the code.
    AttributeDefaultWhat it is
    data-faq-mode single How many answers may be open at once. Options: single, opening a question closes the one that was open, and the open one can still be closed; multiple, each question opens and closes on its own, the better choice when readers compare answers.
    data-faq-start 1 The question that is open when the page arrives, when the address names none. Options: a number counted from 1, 2 for the second question; 0 for none; the id of an item, delivery; all, with mode at multiple.
    data-faq-hash on Whether the open question is in the address of the page. Options: on, a question opened by the visitor writes the id of its item after the # without adding a step to the history, and an address or a link that names an item, or anything inside one, opens it; off, the address is neither read nor written.
    data-faq-schema off Whether the engine adds FAQPage structured data to the head of the page, built from the questions and answers. Options: off, nothing is added; on, one JSON-LD script, see "Structured data" for what it is worth today.
    data-faq-duration 1 The time an answer takes to open or to close, in seconds.

What it does

FAQ accordion is a site utility component for Webflow and vanilla JavaScript, with no library. Also called accessible accordion, smooth accordion animation height auto or faq schema accordion.

A list of questions and answers, written as plain markup: one block per question, a heading and whatever the answer holds, three questions or thirty. A plus stands before each question, in a column of its own, and the answer starts under the words; nothing is ruled, an even step from one question to the next does the work. A press opens the answer: the box grows from nothing to the height of the answer with nothing measured, and the lines of the answer, the browser's own lines whatever the answer holds, rise one after the other from behind their own lower edge as the box makes room for them; closing, they go back down from the last to the first. The upright bar of the plus draws in, leaving a minus. The text stays real text throughout, and the markup is untouched once the move is over. One number from 0 to 1 runs all of it, so a second press in the middle of the first turns round as a curve, and any number of quick presses leave no step and no jump. When an answer above closes, the question that was pressed stays where it is on the screen and the page moves round it. One answer open at a time or several, as a setting. The accordion pattern in full: a real button in each heading, aria-expanded, aria-controls, arrows, Home and End. The open question is in the address, so a link opens the right one. A closed answer is still found by the browser's own search, which opens it. Without JavaScript every answer is in the page. Reduced motion respected. Optional FAQPage structured data. No library. Pattern type accordion, FAQ, disclosure, collapsible content.

Updated

Questions

Paste the block: it arrives as a list marked data-faq holding one div per question marked data-faq-item, each with a heading marked data-faq-question and a block marked data-faq-answer. Duplicate an item in the Navigator to add a question; the engine puts the button and the plus sign in each heading on the published page.

Yes. Each question becomes a real button inside its heading, with aria-expanded and aria-controls written by the engine. Tab goes from question to question, Enter or Space opens and closes one, Up, Down, Home and End move between them, and a closed answer is out of the tab order.

The box of an answer is one grid row that goes from 0fr to 1fr, so its height follows the answer with nothing measured, and the lines of the answer rise one after the other as the box makes room. A press in the middle of a move turns round from where it is, and when an answer above closes, the question that was pressed stays where it is on the screen.

Yes to both. A closed answer carries hidden="until-found" in Chrome, Edge and Firefox, so the browser's search finds a word in it and opens it; Safari does not support it yet. Each item has an id that opening writes after the # of the address, and a link to that id opens the question.

It no longer changes how a result looks: Google ended FAQ rich results for every site on 7 May 2026, though it says it still reads the markup. data-faq-schema="on" adds the JSON-LD from the questions of the list, and schema() returns it as text to paste in the head for readers that do not run JavaScript.