Skip to the content

Panel accordion

A row of tall picture panels where the one under the pointer opens wide and the others fold to slim strips under a veil of the page colour.

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 row needs a height: the frames take what the words leave, and a row with no height shows no picture. The stylesheet gives one by default, which any class of the page replaces. The row is also a size container, so its width cannot come from its content.
  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-panel-accordion Marks the box that holds the panels, the row. It takes no value: leave the value field empty. That box is what lays the panels side by side, what the effect is mounted on and what carries the settings. Without it on any box of the page, the embed marks the parent of the first panel it finds next to itself, and says so in the console when there is none.
    data-panel-accordion-item Marks one panel, inside that box. It takes no value. A panel is what the pointer reaches, what a tap opens and what takes the focus, so in the preview it is the link itself. Without it on any panel, nothing is mounted and the console says so. [ Required ]
    data-panel-accordion-frame Marks the box that clips the picture of a panel, and that carries the veil. It takes no value. Without it the picture is clipped by the panel itself, over the words, and no veil shows. [ Optional ]
    data-panel-accordion-image Marks the picture of a panel, an Image inside the frame. It takes no value. It is held as wide as the open panel and slides inside the frame as the panel moves. Without it the image is laid out by the page alone and is cropped anew at every width. [ Optional ]
    data-panel-accordion-fold Marks the block of words only the open panel shows. It takes no value, and it holds one wrapper that holds the lines. It is laid out at the width of the open panel, and on a narrow screen it is what opens in height. Without it the words wrap again at every width of their panel. [ Optional ]
    data-panel-accordion-line Marks one line that rises out of a mask when its panel opens: the name, the text. It takes no value. Without it the words are simply there, hidden only by the edge of a folded panel. [ Optional ]
    data-panel-accordion-number Marks the number of a panel, which turns to the ink when the panel is open. It takes no value. Without it the number keeps its own colour. [ Optional ]
    data-panel-accordion-state Written by the engine: still or live on the row, open on the open panel, before and after on the folded ones, nothing when every panel is folded. Never written by hand; the stylesheet reads it for every size and every move. [ 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-panel-accordion-tint #f4ece0 Colour of the veil laid over the picture of every folded panel, the cream of the page in the preview. Options: any CSS colour; the colour of the page fades the folded panels into it, the ink #15100c puts them in the shade; taken out of this block, --panel-accordion-tint on the row takes over.
    data-panel-accordion-veil 0.5 Strength of that veil on a folded panel, 0 to 1; the open panel never carries it.
    data-panel-accordion-ratio 3.6 Size of the open panel against a folded one: its width in the row, the height of its picture in the column.
    data-panel-accordion-strip clamp(44px, 13vw, 64px) Height of the picture of a folded panel once the row is a column, any CSS unit; the open picture is strip times ratio.
    data-panel-accordion-gap clamp(4px, 0.5vw, 8px) Space between two panels, in the row and in the column, any CSS unit.
    data-panel-accordion-parallax clamp(14px, 2.2vw, 36px) How far a picture travels inside its frame while its panel opens or folds, any CSS unit; the picture is held that much wider than the open panel on each side.
    data-panel-accordion-duration 0.9 Time a panel takes to open, in seconds; the veil and the pictures move on the same clock.
    data-panel-accordion-ease cubic-bezier(0.5, 0, 0.1, 1) Pace of the opening, any CSS easing.
    data-panel-accordion-text-delay 0.28 Wait, in seconds, before the words of the open panel rise out of their mask; each line then follows the one before by 0.07 s.
    data-panel-accordion-rest 1 Number of the panel open when the page loads, counted from 1. Options: 1 to the number of panels; 0 leaves every panel folded, all the same width, until one is reached.
    data-panel-accordion-back 0 What the row does when the pointer or the focus leaves it. Options: 0 keeps the last panel open; 1 goes back to the rest panel, or folds every panel when rest is 0.

What it does

Panel accordion is an animated navigation component for Webflow and vanilla JavaScript, with no library. Also called horizontal image accordion, image accordion on hover or expanding image panels.

A row of tall picture panels where the one under the pointer opens wide and the others fold to slim strips under a veil of the page colour. Each panel is one entry: a picture in a frame, and under it a number, a name and one line. The name and the line of the open panel rise out of a mask a little after the panel has started to move, one line after the other, and every picture slides a short way inside its frame, against the move of its panel, so the opening reads as heavy and smooth. Hover or focus opens a panel with a mouse, a tap opens it on a touch screen and a second tap follows its link, and the arrow keys walk the row, which is one Tab stop. On a narrow screen the row becomes a column and the panels open in height. No library: the sizes and the pace are CSS transitions on flex shares and transforms, and the script only writes the state, the settings and the keyboard. Under reduced motion a panel still opens, at once.

Updated

Questions

Mark the row data-panel-accordion and each panel data-panel-accordion-item; inside a panel, the box that clips the picture takes data-panel-accordion-frame and the picture data-panel-accordion-image. Settings are custom attributes on the row, for instance data-panel-accordion-rest="3" for the panel open when the page loads. The row needs a height, and the stylesheet gives it clamp(360px, 70vh, 820px) until a class of yours replaces it.

With CSS. Everything that moves is a transition on flex-grow and on transforms, with no library; the script never measures a box and never runs a frame loop, it only writes the state, the settings and the keyboard. Without panel-accordion.css nothing opens.

Set data-panel-accordion-ratio, the size of the open panel against a folded one, 3.6 by default. Near 2 the open panel barely stands out; past 6 the folded panels are slivers and the open one takes the row. data-panel-accordion-duration, 0.9 by default, is the time in seconds a panel takes to open.

At 767px of the window and under, the row becomes a column and the panels open in height. A tap on a folded panel opens it without following its link, and a tap on the open panel follows it. In the column a folded picture is one strip tall, clamp(44px, 13vw, 64px) by default, and the open one ratio times taller.

Yes. The row is one Tab stop: the arrow keys move the focus to the next or the previous panel and wrap around, Home and End go to the first and the last, and the panel that has the focus opens. Each panel gets aria-expanded, and under prefers-reduced-motion a panel still opens, at once, with its words in place.