Menu
All plugins

Unfold for Bricks

Unfold for Bricks adds one element that shows the first part of any content and lets visitors open the rest. Fold by height or by lines of text, add a soft fade, and choose how the toggle looks. Everything inside is ordinary Bricks content, so it stays editable and searchable.

Version: 0.1.1 · Requires: Bricks Builder, WordPress 6.5+ and PHP 8.1+ · See the live demo

Please note: this is an early release. It has been run on this playground but not yet tested widely, so stage & back up before using it on a live site.

What it does

  • Adds one nestable element, Unfold, to the Layout group.
  • Shows the first part of whatever you put inside, then a button unfolds the rest with a smooth height animation.
  • Without JavaScript everything stays visible. Printing shows all the content.

Using it

  1. Add Unfold and drop any Bricks elements inside it: text, headings, lists, images, buttons.
  2. Under Collapsed size, choose Show by Height or Lines of text and set the amount.
  3. Under Toggle button, set the Unfold and Fold text.
  4. If the fade sits on a coloured section, set the Fade colour (Style tab) to match that background.

Controls

Collapsed size

  • Show by: Height (any CSS unit, and it can change per breakpoint) or Lines of text.
  • Visible height / Visible lines: how much is shown while folded.
  • Space between items: even spacing between the elements inside. The default is 1em.
  • Start unfolded: opens on load. The button then folds it.
  • Always show the toggle, even when everything fits: by default the button hides itself when the content is shorter than the fold.
  • In the builder: show everything while you edit, or show the folded state.

Toggle button

  • Unfold and fold text, an icon (a chevron by default), its position, and an option to hide it or not turn it over when unfolded.
  • Alignment: start, centre, end or full width.
  • Style: soft grey, outline or text link. Buttons are square by default.

Motion & behaviour

  • Duration and easing of the animation. Reduced-motion settings are respected.
  • Scroll back to the top when folding: useful for long sections.
  • Accordion group: give several Unfold elements the same group name and opening one folds the others.

Style tab

  • Fade: remove it, change its height or colour.
  • Button: typography, colours (including hover), border, padding and the space above the button.

Accessibility

  • The toggle is a real button with aria-expanded and aria-controls.
  • Tabbing into hidden content unfolds it, so keyboard users are never stuck behind the fold.
  • Content that is folded away stays in the page for search engines and screen readers; the fold is visual.

Styling

Styles live under the plugin’s own .ufb classes and share nothing with other plugins. Useful hooks: .ufb-body, .ufb-toggle, .ufb-icon. Useful variables: --ufb-height, --ufb-lines, --ufb-fade, --ufb-fade-height, --ufb-flow, --ufb-gap, --ufb-btn-bg, --ufb-btn-ink, --ufb-btn-border, --ufb-btn-bg-hover and --ufb-btn-ink-hover.

Scripting

Each element exposes open(), close() and toggle() on its root node (document.querySelector('.ufb').ufb.toggle()). Call window.UFB.refresh() after adding elements dynamically.

Limitations

  • The fade is a flat colour gradient, so set it to match the background. It will not blend over a photograph or gradient.
  • Focusable items inside the folded part can still be reached by keyboard (and unfold the content when they are).
  • Not yet tested in the Bricks builder preview or across a full browser matrix.

Changelog

  • 0.1.1 — even spacing between items inside the fold, a default chevron icon with a Hide the icon option, and every checkbox can now be changed in the builder.
  • 0.1.0 — first release.