Skip to the content

Tabs

Tabs for a page section, written as plain markup: a row of buttons, one panel each, anything inside a panel, any number of them.

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 tabs-* classes of the paste. The Embed holds what moves, and reads five variables, --tabs-accent (the plate), --tabs-ink, --tabs-radius, --tabs-line and --tabs-fade: set them on the block, or on anything above it, in a rule of your own. The box of the panels is bare in the preview; give its class a colour to make it a surface. Keep the padding on the panels, since the box changes height from one to the next.
  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-tabs Marks the block that holds the row of tabs and the panels. It takes no value: leave the value field empty. The settings below go on the same element.
    data-tabs-list On the row that holds the tabs. It takes no value. It becomes the tablist, and it is the part that scrolls sideways on a narrow screen. Name it for screen readers with aria-label, "Services" in the paste. Without it the block is left alone and the engine says so in the console. [ Required ]
    data-tabs-tab On each tab: a button in plain HTML, a Link block in Webflow, its link left on #. It takes no value. The first tab opens the first panel, the second the second: nothing else pairs them. A tab with disabled or aria-disabled="true" is dimmed and skipped. [ Required ]
    data-tabs-panels On the box that holds the panels and nothing else. It takes no value. Its height follows the open panel during a change, so the padding goes inside the panels. Without it the engine takes the parent of the first panel. [ Optional ]
    data-tabs-panel On each panel, as many as there are tabs, in the same order. It takes no value. A panel holds anything. Its id, set in the ID field of the Settings panel, is what the address carries: page#delivery opens that tab. [ Required ]
    data-tabs-state Written by the engine on a panel: active on the open one, leaving on the one that rolls up. The open tab carries aria-selected="true", the row and the box of the panels data-tabs-moving during a change, a row that scrolls data-tabs-fade (start, end or both), the block data-tabs-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-tabs-start 1 The tab that is open when the page arrives, when the address names none. Options: a number counted from 1, 2 for the second tab; or the id of a panel, delivery.
    data-tabs-activation auto What the arrow keys do in the row of tabs. Options: auto, the arrow moves the focus and opens that tab at once, the usual choice when the panels are already in the page; manual, the arrow only moves the focus and Enter or Space opens the tab, for panels that are heavy to show.
    data-tabs-hash on Whether the open tab is in the address of the page. Options: on, a tab chosen by the visitor writes the id of its panel after the # without adding a step to the history, and an address or a link that names a panel, or anything inside one, opens it; off, the address is neither read nor written.
    data-tabs-autoplay 0 The time spent on a tab before the next one opens by itself, in seconds.
    data-tabs-duration 0.9 The time of a whole change, in seconds: the plate sinks, the line runs, the plate rises, the panels hand over.

What it does

Tabs is a site utility component for Webflow and vanilla JavaScript, with no library. Also called animated tabs, autoplay tabs or tab indicator animation.

Tabs for a page section, written as plain markup: a row of buttons, one panel each, anything inside a panel, any number of them. The open tab stands on a plate of colour. On a change the plate sinks to a line at the foot of the tab, the line runs along the foot of the row, stretching towards the next tab, and rises there as a plate again; meanwhile the panel that leaves rolls up towards that line and the next one unrolls from it, and the box goes from one height to the other, so the page under the tabs follows and never jumps. A change asked for in the middle of another carries on from where the plate is. The whole ARIA tabs pattern: roles written by the engine, one tab stop, arrows, Home and End, activation on focus or on Enter as a setting, disabled tabs skipped. The open tab is in the address, so a link opens the right one, and a link to anything inside a panel opens that panel. On a narrow screen the row scrolls sideways, fades on the side where tabs are hidden, and keeps the open tab in the middle. An optional autoplay counts on a line across the head of the open tab, holds under the pointer, with the focus inside and off screen, and stops for good when a tab is chosen. Without JavaScript the panels are all in the page, one under the other. Reduced motion respected. No library. Pattern type tabs, tabbed content, section navigation.

Updated

Questions

Paste the block: it arrives as a div marked data-tabs holding a row marked data-tabs-list with one Link block per tab marked data-tabs-tab, and a box marked data-tabs-panels with one div per panel marked data-tabs-panel. The tabs and the panels pair in order, so adding a tab is duplicating one of each in the Navigator.

Yes. data-tabs-autoplay="6" on the block opens the next tab every six seconds, with a line across the head of the open tab counting the time left. The clock holds while the pointer is over the block, while the focus is inside it and while the tabs are off screen, and stops for good once the visitor chooses a tab.

Yes. The engine writes the ARIA tabs pattern itself: tablist, tab and tabpanel roles, aria-selected, aria-controls and one tab stop. Left, Right, Home and End move between tabs, and data-tabs-activation="manual" makes Enter or Space open the tab instead of the arrow.

Yes. Give each panel an id: choosing a tab writes that id after the # of the address without adding a history step, and a page or a link that names the id, or anything inside the panel, opens that tab. data-tabs-hash="off" turns both off.

No. During a change the box of the panels animates from the height of the panel that leaves to the height of the one that comes, so what is under the tabs glides, while the plate of the open tab sinks to a line, runs to the next tab and rises there. At rest the box has no height of its own.