12. Interactive components

For developersVersion 1.0.0Last updated:

BuilderOS ships a library of interactive components (accordion, tabs, carousel, counter and before/after), in the style of Elementor’s widgets but with the package’s design: the AI supplies the HTML and CSS, and BuilderOS supplies the accessible behavior and the options the client can change from the editor: a carousel’s speed or autoplay, which tab opens by default, or the number a counter counts up to. The AI can also create custom components with BuilderOS.component(), with their options declared in the markup, and the client configures them the same way.

That way each AI stops coding these pieces its own way: the markup is always the same, the JavaScript is BuilderOS’s (no dependencies) and the options are edited in the panel.

In this chapter

Library options

ComponentOptionTypeDefaultWhat it does
accordionfirst-opentoggletrueThe first item starts open.
multipletogglefalseAllow several open at once (otherwise, opening one closes the others).
tabsinitialnumber (1–20)1Tab that starts open (clamped to the number of tabs).
activationselect: auto, manualautoWith the arrows: switch tabs as you move, or move and switch with Enter.
carouselautoplaytogglefalseAutomatic playback (with a pause button; it doesn’t activate with “reduce motion”).
intervalnumber (2–20 s, step 0.5)5Seconds per slide.
arrowstoggletruePrevious / Next buttons.
dotstoggletrueNavigation dots.
looptoggletrueAt the end, go back to the start (without a loop, the arrows are disabled at the ends; autoplay goes back to the start).
per-viewnumber (1–6)1Visible items on desktop.
per-view-tabletnumber (1–6)the desktop value, at most 2Visible items on tablet (≤ 1024 px).
per-view-mobilenumber (1–4)1Visible items on mobile (≤ 767 px).
counterdurationnumber (0.5–10 s)2Duration of the count.
startnumber0Number it counts up from.
prefix, suffixtext""Text before and after the number (€, +, %…).
separatorselect: auto, ., ,, space, noneautoThousands separator (auto = as written).
before-afterstartnumber (0–100 %)50Starting position of the cut.
orientationselect: horizontal, verticalhorizontalLeft/right or top/bottom.

❌ What NOT to do

  • Don’t code your own accordion, tabs, carousel, counter or before/after, and don’t load Swiper, Slick or similar for that: use data-bos-component. That way the client can configure them and they’re accessible.
  • Don’t use data-bos-* in CSS or JS (they’re removed on publish): style with your classes and the is-* classes; in a custom component’s JS use data-part.
  • Don’t hide closed panels or inactive tabs with display: none in your CSS, and don’t put hidden in the HTML: BuilderOS does it, and that way everything is readable without JavaScript.
  • Don’t set the carousel slides’ width or its overflow: the visible-items options control them.
  • Don’t write the counter as 0 in the HTML: write the final number.
  • Don’t make the buttons, tabs or controls <div> or <a>: use <button type="button">.
  • Don’t put tabs in a repeater; for lists the client extends, use the accordion.
  • Don’t add your own autoplay without a pause button, or animations that ignore prefers-reduced-motion.

Image viewer (lightbox)

To enlarge a package section’s photos, put data-bos-lightbox on the link to the large image:

<div class="obras">
  <a href="img/obra-1-grande.jpg" data-bos-lightbox="obras" data-bos-caption="Reforma integral en Chamberí">
    <img src="img/obra-1.jpg" alt="Salón reformado con suelo de roble">
  </a>
  <a href="img/obra-2-grande.jpg" data-bos-lightbox="obras">
    <img src="img/obra-2.jpg" alt="Cocina abierta en blanco">
  </a>
</div>
  • The value is the group: images in the same group form a gallery (arrows, counter, swipe).
  • Caption: data-bos-caption; otherwise the <figcaption> of its <figure>; otherwise the image’s alt.
  • It also works on an <img data-bos-lightbox> with no link (it enlarges the image itself or its data-full).
  • With photos the client can change (data-bos-edit="image"), put data-bos-lightbox on the <img> itself (no link): the viewer enlarges whichever image is there at the time. A link with a fixed href would keep pointing at the old photo.
  • BuilderOS converts it to data-lightbox when rendering (the data-bos-* attributes are cleaned) and loads the viewer only on that page.
  • Accessibility, keyboard, mobile and “reduce motion”: see chapter 13 › Viewer.

Announcement bar slot in the header

The builder’s announcement bar with “Inside the site header” is rendered in the package’s header:

  • in the element with the class bos-slot-announcement, if the header has one (e.g. <div class="bos-slot-announcement"></div> at the very top);
  • otherwise, as the first child of the first <header> in the header part.

It takes the full width of that element and receives clicks even if the header has pointer-events: none.