Skip to content

Celebrating our new site: 30% off everything with code , until Dec 1.

Bright Themes

Accordions for Ghost

Collapsible sections for FAQs and long posts, built on the browser's own details element, so they open with a mouse, a keyboard or a screen reader and need no JavaScript.

  • Works with any Ghost theme

New to Ghost snippets?

Build a card once, save it as a snippet, and add it to any post from the card menu. The tutorial shows each step.

Demo

When does my subscription start?

Right away. As soon as you confirm your email, you have access to every post on your plan, and the first newsletter arrives with the next issue.

I forgot my password. How do I sign in?

You don't need one. Choose Sign in, enter your email, and we'll send you a link that signs you in on that device.

How do I change or cancel my plan?

Open your account from the site's menu. You can switch between monthly and yearly plans or cancel there; a canceled plan stays active until the end of the period you paid for.

Open the questions one by one: opening one closes the others. The second has its own color.

When to use it

  • An FAQ at the end of a pricing or membership post, where readers scan for their one question.
  • A tutorial's troubleshooting section, one fix per error message, so readers open only the one they hit.
  • Answers to the exercises in a lesson or quiz post, which readers open once they've tried.
  • The practical details of a course or event (refunds, access, schedule) that most readers skip.

When not to: For one hidden answer, or a post you send as a newsletter, Ghost's Toggle card is simpler and needs no code.

The code

<div class="bt-accordion-group">
  <details class="bt-accordion" name="faq" open>
    <summary>When does my subscription start?</summary>
    <div class="bt-accordion-body">
      <p>Right away. As soon as you confirm your email, you have access to every post on your plan, and the first newsletter arrives with the next issue.</p>
    </div>
  </details>

  <details class="bt-accordion" name="faq" style="--bt-accordion-accent: #0f766e;">
    <summary>I forgot my password. How do I sign in?</summary>
    <div class="bt-accordion-body">
      <p>You don't need one. Choose Sign in, enter your email, and we'll send you a link that signs you in on that device.</p>
    </div>
  </details>

  <details class="bt-accordion" name="faq">
    <summary>How do I change or cancel my plan?</summary>
    <div class="bt-accordion-body">
      <p>Open your account from the site's menu. You can switch between monthly and yearly plans or cancel there; a canceled plan stays active until the end of the period you paid for.</p>
    </div>
  </details>
</div>

Add it to your site

  1. Copy the CSS and paste it in Settings › Advanced › Code injection › Site headerSettings › Advanced › Code injection › Site header (opens your Ghost Admin in a new tab), between <style> and </style>. Once per site.
  2. In a post, add an HTML card (type /html) and paste the HTML.
  3. Change the example text to your own, then publish or update the post.

Tip

Save the card as a Ghost snippet to add it to any post from the card menu: how Ghost snippets work.

How it works

Each question is a <details> element with a <summary>, the browser’s own disclosure widget, so the browser does the opening and closing. The CSS only restyles it: a plus in place of the default triangle, turning into a cross when open, and a border and a light tint in your accent color. The text keeps your theme’s color, so it fits light and dark themes.

The questions share name="faq", so opening one closes the others. Remove the name to let readers open several at once, and give each group on a page its own name. Add open to a <details> to show it open when the page loads.

Ghost’s editor has its own Toggle card, one collapsible section with no code, which also works in newsletters. Use it for a one-off question; use this snippet for a styled group, such as an FAQ, with one question open at a time. The CSS from code injection doesn’t reach emails, so in a newsletter these show as plain, unstyled sections. See how editor cards work in Ghost and how code injection works.

Customize

VariableDefaultWhat it changes
--bt-accordion-accentvar(--ghost-accent-color, #4433ff)The color of the left border and the background tint. Defaults to your site's accent color; set it on one bt-accordion's style attribute to change only that one.
--bt-accordion-tint8%How much of the accent color tints the background. 0% for no background.
--bt-accordion-radius6pxThe corner radius.
Works with every Ghost theme, including ours. Something not right? Ask us.

All snippets

Launch a better Ghost site

From a solo newsletter to a busy newsroom, there is a theme that fits. No code needed.