Site widgets
webx-ui/widgets is the set of interactive pieces every public site repeats: the header and its mobile menu, dialogs, tabs and accordions, the cookie banner, phones and opening hours, a language switcher, a slider, a lightbox, a video and a map. The logic, the keyboard, ARIA, loading on demand and consent are done in the package; the look is a skeleton on the site's tokens that a theme repaints with the same doors it uses for the modules.
It is a Composer library — no panel section, no tables. theme-default depends on it, so a site made by webx:setup with a theme has it already. Three rules hold for every widget:
- A script only where a widget stands. A page with a slider loads Swiper; the other hundred pages do not.
- Nothing third-party before consent. A YouTube player, a map's tiles, a counter: until the visitor agrees to that category there is no request to the third party at all, only a notice with a button.
- It works without JavaScript. A slider is a strip that scrolls, a lightbox a link to the picture, tabs are headings over their panels, a video a link to it, a map an address and a link.
The specification is docs/architecture/WEBX_UI_WIDGETS.md.
How a page gets the files
The package is the bottom layer of the theme chain, like a module: its views are overridden in the theme, its CSS comes first in the cascade, its built files are published next to the theme's.
php artisan webx:theme:sync # publishes dist/ of the theme chain, the widgets included@webxTheme in the layout's <head> prints the tokens, the widgets' runtime and the theme's CSS. It is expanded at the end of the response: by then every component on the page — the header and the footer too — has said what it needs, and only that is printed — <link>s in the head, a <script type="module"> before </body>.
- The runtime (
runtime.js|css, under 17 KB gzip) is on every page of a site with a theme: the behaviours by attribute, the header, the mobile menu, dropdowns and the form in a dialog. - A widget's own files load only when it is claimed. A component claims itself; code of your own claims with the facade:
use WebxUi\Widgets\Facades\Widgets;
Widgets::need('slider'); // dist/slider.js and slider.css on this pageWhat a visitor does not see before they act — a form in a closed dialog, a banner a script shows later — is rendered inside Widgets::later(fn () => …), in Blade @webxLater(<when>) … @endwebxLater. What it claims gets a stylesheet that does not block the first paint (media="print", switched on once loaded, and a <noscript> copy). If the page also shows the same widget straight away, its stylesheet blocks as usual. The dialogs of module-inbox forms are already rendered this way.
@webxLater(! $shownByTheServer)
<x-webx-form :action="$url">…</x-webx-form>
@endwebxLater- The scripts of the widgets that start on an element — the slider, the lightbox, the map, the form and its parts, and the like — wait until wanted. The page lists them for the runtime, and the runtime fetches one when its element comes within 200px of the window or is touched first; a click that comes before the script is held and given again. Their stylesheets are in the head as usual, so nothing looks different meanwhile. A widget of the first screen that must not wait is loaded at once with
data-webx-eager="slider"on any element (several names separated by spaces), orWidgets::eager('slider').
<x-webx-slider data-webx-eager="slider" …>- The cookie banner (
consent.js|css) is on every page: the package prints it before</body>by itself — there is no component to place and none to forget. - A lightbox link and a link to a form in a dialog are found in the finished page: a link written by hand in a block claims them without any code.
Every script starts through webx.mount(root), so a widget comes alive in a block the panel's preview swapped in and in HTML loaded later. Before removing such HTML, call webx.unmount(root).
Behaviours by attribute
No component needed — the attributes are enough, in a block template or in a theme's view:
| Attribute | What it does |
|---|---|
data-webx-disclosure="<id>" on a button | shows and hides #<id>; Esc and a click outside close it |
data-webx-dialog="<id>" | opens <dialog id> as a modal with a focus trap; [data-webx-dialog-close] inside closes it |
data-webx-tabs on a container | its [data-webx-tab] panels become tabs — arrows, Home, End; an anchor in the address opens one |
data-webx-accordion="single" | on <details>: one open at a time |
The components <x-webx-dialog> and <x-webx-tabs> print the same markup for you.
<x-webx-tabs transition="fade"> (data-webx-tabs-transition="fade") cross-fades the panels instead of switching at once. All panels then share one cell, so the tabs are as tall as the tallest panel: pictures of different proportions do not make the page jump, at the price of space under a shorter one. Under reduced motion the change is instant.
<x-webx-dialog id="call" title="Call me back" description="We call within 15 minutes." sheet> — description is a line under the title, the dialog's accessible description; sheet makes it a sheet from the bottom on a window narrower than 40rem: the whole width, rounded on top, scrolling inside, sliding in unless the visitor asked for less motion. Wider, and without sheet, it is the card in the middle it always was. The window and not a container decides here — a modal dialog lies over the viewport, outside every container of the page — so the runtime measures it and marks the open dialog is-sheet, turning it with the phone; without JavaScript it stays a card.
Header and mobile menu
<x-webx-header sticky="hide-on-scroll" collapse="auto">
<x-slot:brand><a href="/">Shop</a></x-slot:brand>
<x-webx-header.nav :items="menu('header')" />
<x-slot:actions><x-webx-phones /></x-slot:actions>
</x-webx-header>collapse="auto" measures instead of guessing: the navigation folds into the menu button exactly when its items no longer fit the bar. The mobile menu is built from the same parts — the brand on top, the menu's tree in the body (drill or accordion), the actions at the bottom; it closes on a link, on "Back" and on a swipe. --webx-header-height stays live, so an anchor under a sticky header keeps its heading in view.
In an accordion a section that is a page itself is repeated as the first line of its branch. parent="split" — on <x-webx-mobile-menu.nav> or on <x-webx-header> — makes the section's name the link and opens the branch with an arrow beside it, «Submenu: …» to a screen reader, so the same page is not offered twice — nor is a child that leads to the section's own address («All showers» under «Showers»; a branch left empty loses its arrow). A section without a page of its own opens by its name either way; drill keeps the section's name as a link on top of its level.
Dropdown and form in a dialog
<x-webx-dropdown> is a <details> — a click opens it without JavaScript; with it the panel is placed from its button and turned over at the window's edge, and one is open on the page.
Any link to #webx-form-<slug> — typed into a menu item or a block's button in the panel — opens that module-inbox form in a dialog, printed once per page however many buttons lead to it. The form's description stands under the dialog's title. data-webx-sheet on any of its buttons (or Widgets::form('callback', sheet: true), or webx-widgets.form_dialog.sheet for every form) opens it as a sheet from the bottom on a phone.
Cookie consent
The banner offers only the categories something on the site asks for: necessary (always), preferences, statistics, marketing, media. "Reject all" is the same button as "Accept all"; "Customize" opens the categories; "Cookie settings" in the footer (<x-webx-consent-link />) opens them again. The answer is the webx_consent cookie, which the server reads too — that is how a video's notice is printed without a flash.
The banner and the dialog take their button words from keys of their own, so a site words them apart in lang/vendor/webx-widgets/<locale>/widgets.php — no copy of the consent view, which would stop getting the package's changes. Out of the box both say the same; a design that words them apart:
return [
'consent' => [
// The banner
'reject' => 'Decline',
'accept' => 'Accept',
'customize' => 'Manage preferences',
// The dialog
'dialog_reject' => 'Reject optional',
'dialog_accept' => 'Accept all',
'save' => 'Save choices',
],
];Laravel merges the file with the package's key by key: a key the site leaves out keeps the package's words. Keep the two buttons of a pair equally plain — the view gives them one class.
Third-party code of the site waits for its category in one of three ways:
{{-- Anything, as it is: printed as it stands once the visitor agrees --}}
<x-webx-consent category="statistics">
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXX"></script>
</x-webx-consent>
{{-- Or by hand: a script the browser does not run, an iframe without its src --}}
<script type="text/plain" data-webx-consent="marketing" src="https://example.com/pixel.js"></script>
<iframe data-webx-consent="media" data-src="https://www.youtube-nocookie.com/embed/…"></iframe>From the site's own scripts:
webx.consent.has('media') // true once the visitor agreed
webx.consent.open() // the dialog with the categories
document.addEventListener('webx:consent', (event) => console.log(event.detail.categories))On the server, Consent::has('media'). Google Consent Mode v2 default is printed in the head, before any Google tag. The banner's texts, the policy page, its version ("Ask everyone again") and the categories are on the Cookie tab of the settings (consent.*, also over MCP); without module-settings, in config/webx-widgets.php. Switching the banner off is for a site that needs no consent — the site audit notices it when something third-party is on the site.
Contacts
The phones, e-mails, addresses, hours and networks live once, on the Contacts tab of the settings; the widgets, the map and the SEO markup read them from there, and print nothing while it is empty. Which sections the tab draws is what the theme, the packages and the project declare (Settings): a site with <x-webx-hours> or <x-webx-socials> in its own views lists hours, messengers or socials in its theme's settings or in webx-settings.contacts.sections.
| Component | What it shows |
|---|---|
<x-webx-phones> | the main number as a tel: link in E.164, the others in a dropdown, messengers beside them |
<x-webx-hours> | "Open until 7:00 PM" in the site's time zone, the week in a dropdown or a table |
<x-webx-contact-button> | a round button in a corner: chats, the number, the form — above the cookie banner |
<x-webx-contact-bar> | "Call / Write / Request" along the bottom of a phone — one of the two, not both |
<x-webx-socials> | the networks as icons |
The package puts the contact button on every page that has contacts — the node widgets.contact-button of the composition layout, after footer. A site that wants none sets 'contact_button' => false in config/webx-widgets.php: the button is not printed wherever it is placed, and the contacts script is not loaded for it — other contact widgets on the page still load it for themselves. A theme that wants it elsewhere, or not in the layout at all, patches the node: {"remove": ["widgets.contact-button"]}. No need to override its view with an empty file, nor to copy the layout.
Language switcher
<x-webx-language-switcher /> names each language in itself and leads to the same page in it — the addresses come from the routing registry, like hreflang. A page not translated yet stays a page: the link leads to the same path under that language's prefix, where the page is shown in the default language inside the chosen language's header and footer, closed to the index. Where that is not possible — a 404, an entity hidden in the language, a type that does not show its untranslated entities, such as blog articles — the link leads to that language's home page and is marked is-fallback. A one-language site prints nothing.
Slider and lightbox
<x-webx-slider variant="cards" :per-view="['sm' => 1.2, 'md' => 2, 'lg' => 3]">
@foreach ($services as $service)
<x-webx-slide>…</x-webx-slide>
@endforeach
</x-webx-slider>Variants: cards, hero (fade and autoplay), gallery (thumbnails), logos (a running strip). "Per view" counts by the slider's own width, so a slider in a narrow column behaves like one. Whatever moves by itself has a pause button. Swiper is built in; nothing to install.
A finger, a mouse and a touchpad page it. A drag let go pages past 15% of a slide, or at any length when it is a flick — faster than 0.4 px/ms; past the first or the last slide it gives way. A touchpad's sideways scroll pages one slide a gesture. The feel is the package's, one for every slider and the photos of every card — webx-widgets.swipe in the config:
| Key | Default | What it is |
|---|---|---|
threshold | 0.15 | the share of the width a slow drag must pass to page |
velocity | 0.4 | px/ms: a drag faster than this is a flick and pages at any length |
resistance | 0.3 | how far a drag past the first or the last follows the finger |
wheel | 60 | px of a touchpad's sideways scroll that make one step |
pause | 400 | ms of quiet after a step before the next gesture counts (its momentum is waited out) |
A theme sets them in its service provider — config(['webx-widgets.swipe.threshold' => 0.2]) — a site in its published config; a key left out keeps the default. One slider's own Swiper settings (longSwipesRatio and the rest) are still its options prop, over everything.
pagination is true (dots), false, or "fraction" — a counter "1/6" between the arrows in place of the dots, for the photos of a flat or a product:
<x-webx-slider variant="gallery" pagination="fraction">…</x-webx-slider>The counter (.webx-slider__count, __current, __total) follows the slide in view — in a loop too, and a running strip's copies are not counted. A screen reader does not hear it: the slides are named "2 / 6" and Swiper announces the move already. Its colours and size are --webx-slider-count-color, --webx-slider-count-current, --webx-slider-count-size; one slide prints no controls at all. Kitchen sink › Slider › Photos with a counter shows it.
A pane that stands still over the slides — the words of each slide fading one into the next while the pictures move under it — is the overlay slot. It is printed hidden and shown by the script; its .webx-slider__caption elements, one per slide in order inside a .webx-slider__captions, follow the slide in view: the current one has is-current, the others are inert and hidden from a screen reader. The crossfade lasts --webx-slider-caption-fade (none with reduced motion). pagination-in names an element of the overlay that takes the dots, each saying "Slide 2 of 4":
<x-webx-slider :arrows="false" :autoplay="5000" :pause="false" pagination-in=".plate__dots">
<x-webx-slide>…</x-webx-slide>
<x-slot:overlay>
<div class="plate">
<div class="webx-slider__captions" aria-live="polite">
<div class="webx-slider__caption is-current">…</div>
<div class="webx-slider__caption" inert aria-hidden="true">…</div>
</div>
<div class="plate__dots"></div>
</div>
</x-slot:overlay>
</x-webx-slider>:pause="false" leaves the pause button out; the slider still stops under the pointer and with the focus inside, and the site audit does not count it as a lost button. Every change of the slide is an event on the slider's root, for whatever a theme draws around it:
slider.addEventListener('webx:slide', (event) => {
const { index, count, auto } = event.detail // index from 0; auto — autoplay moved it
})The lightbox (PhotoSwipe) opens any link with data-webx-lightbox; links with the same value page together. <x-webx-lightbox :image="$picture"> takes a picture of the media library and writes its size; a link by hand needs data-width and data-height — without them the picture is downloaded first to be measured, and the audit says so.
- A name — a picture without an alt leaves its link nameless, so the link is named for what it does, in the page's language: "Open picture 2 of 5" with
:indexand:total(its place in the group — thegalleryblock passes them), "Open the picture" without. Anaria-labelof yours, words or a described picture in the slot win. - A frame —
ratio="4:3"(data-webx-lightbox-ratioon a link, "Frame over the page" in thegalleryblock): the picture opens in a frame of that shape, whole and undistorted inside it, on--webx-lightbox-frame. Nothing — the picture as it is. - The backdrop is opaque;
--webx-lightbox-backdrop-opacitylowers it for a theme or a section,opacity(data-webx-lightbox-opacity) for one link's group. - The window fits the picture whole, in its own shape: wide, into min(100vw − 200px, 1600px) × 84vh; on a phone (a window up to 768px) into 100vw − 24px × 75vh, with the two arrows side by side right under the picture — PhotoSwipe alone hides them on a touch screen. The picture grows out of its thumbnail and goes back into it. The margins are
webx-widgets.lightboxin the config, set the wayswipeis:narrow(768), and forwideandphoneeachside(100 / 12 px, the least margin left and right),max(1600 / 0 — no limit),height(0.84 / 0.75 of the window) andbelow(false / true — the arrows under the picture). Their look:--webx-lightbox-arrow-size,--webx-lightbox-arrows-gap. - Closing leaves the page where it stood, whichever picture of the group it closed on; the focus goes to that picture's link without scrolling to it — or to the opener, when that link is hidden.
Video and map
<x-webx-video src="https://www.youtube.com/watch?v=…" :poster="$image" title="The tour" />
<x-webx-video :file="$media" :poster="$image" />
<x-webx-map from="settings" />
<x-webx-map :lat="52.5163" :lng="13.3777" :zoom="16" marker="Pariser Platz" />YouTube and Vimeo are a poster and a play button; the player (youtube-nocookie.com) comes only on a click. Before consent to media the server prints a notice over the poster — "Load" (this one) and "Always load videos" (consent). With no poster set, the video's own preview is fetched once into the media library, so the visitor never asks YouTube even for the picture. A file of the site is a <video preload="none"> and needs no consent.
<x-webx-video variant="background" :file="$media" :poster="$image" ratio="21/9">
<h1>Made to move</h1>
</x-webx-video>The background of a first screen is a file of the site only — a provider's video behind a hero would be asked on every showing — muted, looping, without controls, behind whatever the tag wraps; the ratio is the least the frame takes. It plays only while on screen and with the tab in front, and never by itself under reduced motion or on a connection saving data: then the poster stays, as it does without JavaScript, and the file is not even asked for. A pause button is always in its corner (WCAG 2.2.2); a pause is remembered for the next page. The video is decor, hidden from screen readers: what it says, the page's markup over it says.
The map is Leaflet over OpenStreetMap tiles, with no key. Before consent it is the address, "Open in maps" and the same two buttons; the wheel scrolls the page until the map is clicked.
An owner who decided the site needs no consent for the map's tiles lifts the wait for maps alone: the switch "Maps without asking" of the Cookie tab, or 'map' => ['consent' => false] in the config — either one is enough. The map then loads at once for every visitor, with no notice and no buttons, and the banner no longer offers "media" for it; the banner itself and the other categories stay as they were, and the site audit lists the pages with such maps as a notice, so the decision stays visible. <x-webx-map :consent="false"> (or true) decides for one map, whatever the site says.
Another provider of tiles is a config entry:
// config/webx-widgets.php (php artisan vendor:publish --tag=webx-widgets-config)
'map' => [
'provider' => 'maptiler',
'providers' => [
'maptiler' => [
'label' => 'MapTiler',
'tiles' => 'https://api.maptiler.com/maps/streets-v2/256/{z}/{x}/{y}.png?key={key}',
'key' => env('WEBX_MAP_KEY'),
'attribution' => '…',
'max_zoom' => 20,
],
],
// Where "Open in maps" leads when the address has no link of its own.
'open' => 'https://www.openstreetmap.org/?mlat={lat}&mlon={lng}#map={zoom}/{lat}/{lng}',
],{key} is replaced by the entry's key; a provider named but not described, or a {key} with no key, is an error at once rather than a map that silently asks for tiles without one.
Google Maps
Google Maps is the other provider of the same <x-webx-map>, with the same frame, notice, sleep and "Open in maps" (to Google Maps). It is not a tile entry: Google's terms keep its tiles in its own Maps JavaScript API, so the page claims map-google.js instead of Leaflet. Choose it on the Map tab of the settings: «Map service» → Google Maps, then the API key and, optionally, a Map ID. Without module-settings the config does the same:
'map' => [
'provider' => 'google',
'google' => ['key' => env('WEBX_GOOGLE_MAPS_KEY'), 'map_id' => null],
// …
],- The key is a browser key — every visitor sees it in the page. Restrict it in the Google Cloud console to the site's domains (HTTP referrers) and to the Maps JavaScript API.
- Before consent to
medianothing of Google is on the page — no script, no preconnect; the API is asked for on «Load», «Always load maps» or a consent given earlier, and then only as the frame comes near the screen. One script for every map of the page. - No key — the map is the place: the address (or the coordinates) and a link to Google Maps, never Google's grey window; the Map tab warns that the key is missing. A key Google refuses (or a script that does not come) — the same place, with «The map could not be loaded».
- Asleep the map is Google's «cooperative»: the wheel and one finger scroll the page, Google says how to zoom; a click or the focus makes it «greedy», a press elsewhere puts it back.
- The pin is the package's SVG in
--webx-map-marker: a classic marker, or an advanced one with a Map ID. The scheme follows the site — dark underdata-theme="dark"or a darkcolor-scheme, the system's where the site follows it — once, when the map is made: a switch of the theme afterwards applies on the next page. With a Map ID the style is the one given to it in the console. - CSP — a site with a Content Security Policy allows
script-src https://maps.googleapis.com,img-src https://*.googleapis.com https://*.gstatic.com data:,connect-src https://*.googleapis.comandfont-src https://fonts.gstatic.com. Do not preconnect to Google in the<head>: that is a request with the visitor's address before consent.
Google Maps embed, with no key
A site whose owner cannot get a key for the Maps JavaScript API puts Google's own frame instead — Share → Embed a map in Google Maps. It is a mode of the same <x-webx-map>, not another widget: the same frame, notice, buttons and consent to media.
<x-webx-map :embed="$code" address="Sample Square, Sample City" title="Map of the office"
link="https://maps.app.goo.gl/…" height="28rem" height-narrow="18rem" />- What it takes — Google's whole
<iframe …>or only its address. The address is taken out and onlyhttps://www.google.com/maps/embed?pb=…(and the oldermaps.google.com/maps?…&output=embed) pass; a frame of another site, the keyed/maps/embed/v1/…,http:or HTML with more than the one frame in it is refused. - In a block — the Map block's «Place» → «Google Maps embed», then «Map code or link». Its field is the panel's
wx-embed(props.source: "google-maps"): the code is pasted as it is, the save keeps the address alone and refuses another site's code with a line saying where to get the right one. The same holds for an agent writing throughblocks_*. - «Open in Google Maps» —
link, else read from the address when it says where: the centre of apbcode, the search of an old one. Apbwithout a centre has no link unless one is given. - Before consent there is no
<iframe>in the page at all: the address, the link, the notice and «Load» (this map) / «Always load maps» (the consent). After it the script puts Google's frame in with thetitle,loading="lazy"andreferrerpolicy="no-referrer-when-downgrade", filling the frame the server reserved — nothing below moves. - «Show the map without consent» — a switch of each Map block, off by default (and off for blocks saved before it). On, the block passes
:consent="false": Google's<iframe>is in the page's HTML at once — no notice, no wait, without JavaScript too. Off, the site decides: the Cookie tab's «Maps without asking», which by default waits. The block that is on wins over the site; the block that is off does not overrule a site that lifted the wait. Its hint says why it is off: the map hands the visitor's IP address to the map service and may set cookies, which needs consent in the EU. - The placeholder is a drawing of streets in the theme's own colours with a card on the theme's surface over it — the pin, the address, the notice, the buttons, the link. No picture and no request: before consent the page asks the map service for nothing.
height-narrow— the height in a column narrower than 36em, for any map: a phone gets a shorter map than a monitor. The block's «Height on a phone» sets it; «Width» → «Edge to edge» takes the map to the window's sides (site-bleed).
Where the manager gets the code: Google Maps → the place → Share → Embed a map → Copy HTML, and paste it into the block.
Page tools
What a long page needs, each loading only where it stands:
<x-webx-share title="Our new workshop" />
<x-webx-back-to-top />
<div class="cards" data-webx-reveal="stagger" data-webx-reveal-effect="up">…</div>
<section data-webx-reveal="fade">…</section>
<section class="promo"><img class="promo__picture" data-webx-parallax="strong" src="…" alt=""></section>
<section class="offer" data-wx-block="offer"@webxOverlap($overlap)>@webxOverlapEdge($overlap, $edge, $edge_narrow)…</section>- Tables of prose — nothing to write. Every
<table>without a class on a page — what a rich text field stores, whichever module prints it — is put by the server in a frame that scrolls sideways when the table is wider than the column. Its caption is taken out above the frame, so it stays in place while the table scrolls, and still names the table. A shadow shows the side there is more behind; a table that fits is no tab stop. A table a template wrote has a class and is left alone. - Reveal on scroll —
data-webx-reveal="up",fadeorscaleon any element, orstaggeron a container to bring its children in one after another. In the runtime, no component. Only the script hides anything, and only what is below the screen when the page opens: without JavaScript or with reduced motion everything is simply there. - Parallax —
data-webx-parallaxon a picture that fills its frame (the parent withoverflow: hidden): it moves slower than the page as the frame crosses the screen, taller than the frame so its edges stay out of sight. Scroll-driven CSS (a view timeline named on the frame) where the browser has it, a small script elsewhere; the motion istranslateonly, so nothing shifts around it. The value is the strength:soft,medium(or empty) andstrongtravel 10, 20 and 30% of the frame's height each way, half that in a container under 40rem (--webx-parallax-shift20,--webx-parallax-shift-narrow10,--webx-parallax-soft0.5,--webx-parallax-strong1.5). A picture placed absolutely is made taller rather than scaled, so it stays sharp; one in the flow is scaled. Without JavaScript, with reduced motion and in print the picture simply stands there. Withscreenamong its words (screen,screen soft) it is the picture of the first screen: it goes down k · scrollY and grows to 1 + z from the top of the page until its frame is gone from the screen — also while the next section slides over it and the frame is pinned. Its knobs:--webx-parallax-screen-rate(k, 0.2),--webx-parallax-screen-rate-narrow(0.1),--webx-parallax-screen-zoom(z in percent, 3) and--webx-parallax-screen-overscan(the room above the frame in percent of its height, 20 — never less than how far the picture goes). - A section that slides over the one above —
data-webx-overlapon a section: the section before it (a hero banner, any block) stays where it is,position: sticky, while this one comes up over it; the elements of that section markeddata-webx-overlap-fadefade out as they are covered, then it goes up with the page under this one. The top of this section can be a picture — fog, clouds — as wide as the page:@webxOverlap($on)prints the attribute on the root,@webxOverlapEdge($on, $edge, $edgeOnAPhone)the picture as its first child. Scroll-driven CSS where the browser has it, a small script elsewhere; the pin isstickyon both, so it does not shake. Focus that comes back into the pinned section scrolls the page to where its words are whole. Without JavaScript, with reduced motion and in print the sections stand one after another and the picture lies over the bottom of the one above. The root of the section must be positioned (theme-defaultdoes it), and must not crop: an edge over a root withoverflow: hiddenis cut. - Share — each network's own address for sharing as a plain link (Facebook, X, LinkedIn, Telegram, WhatsApp, e-mail by default; also Viber, Reddit, Pinterest, Threads, Bluesky, VK) and Copy link. No network's script, so nothing to ask consent for. On a phone one Share button opens the system's share sheet instead.
urlis the page by default. - Back to top — a round button in a corner that comes after two screens (
:after), goes up smoothly unless the visitor asked for reduced motion and leaves the focus at the top. It stands above the cookie banner, the contact bar and the quick contact of its corner. Without JavaScript it is a link to#topwhere the template put it.
Smooth scrolling
A notch of the mouse wheel moves the page in one stretched glide that eases out, instead of a jump of a hundred pixels — what designs made with Lenis show. Off by default; the theme switches it on with one attribute on the layout's <html> (or <body>), and writes no script of its own. The attribute is a patch of the composition layout — no copy of the layout:
{ "attrs": { "html": { "data-webx-smooth-scroll": true } } }in theme/compositions/layout/default.json (or layout/blog.article.json for the articles only). A setting goes beside it: "data-webx-smooth-scroll-duration": "1.4s". A layout of the theme's own, written by hand, puts the attribute on its <html> as it is.
The server sees the attribute and loads the widget's own file, Lenis built in; a page without it never loads Lenis. The settings, each an attribute beside the switch or a token in the theme's CSS (the attribute wins):
| Attribute | Token | Default | What |
|---|---|---|---|
data-webx-smooth-scroll-duration | --webx-smooth-scroll-duration | 1.1s | the length of a glide (1.1, 1.1s, 1100ms) |
data-webx-smooth-scroll-easing | --webx-smooth-scroll-easing | quart | quart, cubic, expo or sine, eased out |
data-webx-smooth-scroll-wheel | --webx-smooth-scroll-wheel | 0.9 | how far a notch goes, against the browser's |
data-webx-smooth-scroll-anchor-duration | --webx-smooth-scroll-anchor-duration | 1.4s | the way to an anchor, eased in and out |
It switches itself off, and the page scrolls natively:
- with reduced motion asked for by the visitor;
- on a touch screen — no hover and a coarse pointer: the finger has the system's own inertia;
- without JavaScript — anchors slide with the theme's own
html { scroll-behavior: smooth }, if it has one: the widget sets it aside only while the glide runs (html.webx-smooth-scroll); - under a modal — a dialog, the mobile menu, a form in a dialog (
html.webx-scroll-locked) pause it; closing resumes it.
What scrolls inside the page scrolls itself: any element that can scroll that way, dialogs, the lightbox, the map, the panels of the dropdown and the suggestions. Anything else of the theme's that takes the wheel — a canvas, a custom list — gets data-webx-scroll-native.
A link to an anchor of the same page (#prices, /#prices on the home page) glides to it and stops under a sticky header: the header keeps the page's scroll-padding-top, and an anchor's own scroll-margin-top counts too. The anchor goes into the address, so Back returns. A link activated from the keyboard keeps the browser's jump, which also moves the focus there. The page still scrolls itself — position: sticky, data-webx-reveal and the header's hide-on-scroll see the usual scroll events. A script of the theme may glide too: webx.scrollTo(target, options) (Lenis' scrollTo) exists while the widget runs.
Inertial scrolling is this widget only: a theme does not bring Lenis or another library of its own.
Counters and countdown
<x-webx-counter :value="3000" suffix="+" />
<x-webx-counter value="4.9" prefix="★ " :duration="1500" />
<x-webx-countdown to="2026-12-31 18:00" ended="The sale is over" />- Counter — the server prints the final number the way the page's language writes it (3,000; 3.000 in German): that is what search engines index, a screen reader says and a page without JavaScript shows. The script counts up to it when the counter comes into view — only a counter below the screen when the page opens; one already in view keeps its number rather than flash and drop to zero. Decimals are the ones the value was written with. Reduced motion: final at once.
- Countdown — to a wall time of the site's time zone (the one of the opening hours on the Contacts tab, else
app.timezone): the sale ends at six where the shop is, wherever it is read. A moment with its offset, or aDateTimeInterface, is that moment. The server prints the time left, the script counts down every second from the clock — a page out of a cache is right. At the end theendedtext takes its place; without one the timer goes, and so does the nearest[data-webx-countdown-scope]around it (the Countdown block is one). Without JavaScript it is the line "Ends on …" rather than digits standing still; with it, that line is what a screen reader hears.
The photos of a card
<x-webx-photos :images="$flat->photos" ratio="3/2" :label="$flat->title" sizes="(min-width: 832px) 34vw, 100vw" />
<x-webx-photos :images="$pictures" :autoplay="8000" />
<x-webx-photos :images="$pictures" :autoplay="false" />- Several photos in one frame turn on their own — every 5 seconds by default — with a bar under each that fills while its photo is shown and shows it on a click. A finger or a mouse drags the photo, the next one coming in beside it; let go, it pages past 15% of the frame or by a flick, and gives way (0.3) past the first and the last — a drag does not go round, the time does. A touchpad pages a photo a gesture (60px of sideways scroll, then 400 ms of quiet). In a slider of cards the gesture over the photos is theirs alone — the slider stands; one that starts past the first or the last photo is the slider's and pages the cards instead. The click a drag ends in opens nothing. The feel is
webx-widgets.swipe, as for the slider. The pointer over it, the focus inside it or the page scrolled past stop the time, and the pause button stops it for good. With reduced motion nothing turns until the button is pressed. imagestakes what a template has: values of a media field, objects withurl(), addresses — the empty ones are left out. One photo is a plain<img>with the attributes you gave and no script; none prints nothing. The frame has the shape ofratio, else of the first photo.sizesis how wide a photo stands — the card's share of the row,100vwby default: every photo is offered as the library's copies by width and in the formats the site cuts, the ones past the first without an address until they are shown.- Without JavaScript the first photo stands alone.
- A card whose link is stretched over it says so with
data-webx-photos-surfaceon the card: a swipe over the photos turns them, a tap still follows the link, and a slider of such cards moves with the rest of the card.
<li class="card" @if ($href) data-webx-photos-surface @endif>
<x-webx-photos :images="$photos" ratio="3/2" />
<h3><a class="card__link" href="{{ $href }}">{{ $title }}</a></h3>
</li>Before and after, table of contents
<x-webx-compare :before="$old" :after="$new" :start="30">Two weeks apart</x-webx-compare>
<x-webx-toc>…a long text with h2 and h3…</x-webx-toc>
<x-webx-toc for="terms" :depth="2" title="Contents" />- Before and after —
beforeandafterare what<x-webx-lightbox :image>takes: a media field's value, an object withurl(), an address. The frame has the shape of the first picture with sizes (orratio), so nothing below it moves while they load; the after picture lies over the before one, cut at the divider. The divider is an<input type="range">: the arrows move it (5%, 1% with Shift, Home and End), a screen reader hears a slider; a mouse drags it, a finger too once it moves sideways — up and down still scrolls the page. Labels arebefore-labelandafter-label, "Before" and "After" in the page's language by default. Without JavaScript the two pictures stand side by side, or one under the other in a narrow column. - Table of contents — the list is made by the server from the finished page: of the tag's own slot, of the element
fornames (an id, without#) or of<main>. Headings without an id get one from their words, unique on the page, so every link works without JavaScript and can be shared; an id you gave is kept, a heading withdata-webx-toc-skipis left out.depth2 lists theh2, 3 (the default) theh3under them. With a slot, a wide container puts the list beside the text (side="end"orstart), sticky under the header; a narrow one — a phone, a column 20rem wide — puts it above, folded into a bar that names the section being read and opens the list.fold="never"keeps it open. The section being read is markedis-currentas the page scrolls.
Zoom
<x-webx-zoom :image="$photo" :src="$photo->thumbUrl(1200)" mode="side" group="product-{{ $product->id }}" />
<x-webx-lightbox :image="$picture" group="g" data-webx-zoom data-zoom-mode="inner" />- The picture is a link to the original that opens the lightbox: that is the way in for a keyboard and a screen reader, which have no hover, and without JavaScript the link opens the file.
imageis what<x-webx-lightbox :image>takes; its address is the large picture,srcthe one shown — a smaller copy where you have one (a product photo'sthumbUrl()), else the original itself. The original is fetched on the first hover or touch only; until it comes the shown picture stands in, magnified. - A mouse magnifies it
scaletimes (2.5 by default):mode="inner"inside its own frame, following the cursor — the point under the cursor stays under it;mode="side"as a lens on the picture and the magnified part in a panel to its right, the frame's height. The panel needs room inside the picture's container — the nearest ancestor with acontainer-typethat is not a widget's own, else the page — for at least 60% of the frame's width; where there is none (a narrow column, a phone, a gallery as wide as its column)sideisinner. A press hides it: a click is the lightbox's, a drag the slider's. - A picture in a frame of another shape — a portrait photo standing in the middle of a gallery's 4:3 — is magnified in a strip of the frame only, since
innerlays its window over the picture's own box.frame="container"(data-zoom-frame="container") makes the window the whole.webx-zoom, with its rounding — theme that element as the frame. The copy is the picture's box ×scaleand the point under the cursor stays under it as far as the window's edges let: along an axis where the copy is longer than the window it rests against the edges and always covers the window, where it is shorter it stands in the middle on--webx-zoom-bg.sideand fingers are as they were: two fingers magnify inside the picture's box. The default,picture, prints nothing. - Fingers — two pinch it (up to 4×) and move it about inside the frame; one finger pans a magnified picture and holds the slider under it still; a double tap is 2× around the point and back; pinched back to its size it is as it was. One finger on a picture at its own size is the page's and the slider's, as before. A single tap still opens the lightbox, 300ms later — the time a second tap has to come. Reduced motion: no easing.
data-webx-zoomon any element that holds a picture and a link — usually the lightbox's own link — does the same without the component; its value is the large picture (empty: the link's address),data-zoom-modeanddata-zoom-scalethe rest. The Gallery block's slider uses it (its field "Magnify under the mouse"), and so doesmodule-catalog's product page.
Pages of a list, "Show more", the notice bar
<x-webx-pagination :paginator="$articles" />
<x-webx-load-more :paginator="$articles" pages="shown">
<ul class="cards" data-webx-load-more-list>
@foreach ($articles as $article) <li>…</li> @endforeach
</ul>
</x-webx-load-more>
<x-webx-notice-bar />- Pagination — what
->paginate()answered, as it is: previous, the numbers around this page (around, 2 by default) with the first and the last always there, next.->simplePaginate()gets previous and next. The first page links to the list's own address, not?page=1— one address per page. A stylesheet, no script. - Show more — the list and its pagination, which is what a page without JavaScript and a search engine get. The script shows a button: it fetches the next page as any visitor gets it, takes the items of the list with the same page parameter out of its HTML and adds them, focuses the first new item, says "Page 2 of 4 loaded." to a screen reader and replaces the address with
?page=2. Back leaves the list; a reload lands on the page last loaded, whose links lead back. No endpoint and no JSON: an item is what the module prints, a theme's override included. The list is the element markeddata-webx-load-more-list(its children are the items); without one the slot is the items.pages="covered"(the default) — the button stands in for the links;pages="shown"— both, the pages already on the screen marked. A module's own links go in thelinksslot. A failure says so and uncovers the links. - Notice bar — above the header (the default theme's layout prints it after "Skip to content": the node
notice-barof the compositionlayout, its stacknotice.stack; a theme moves it with{"move": [{"id": "notice-bar", "to": "body", "after": "header"}]}), a region named "Announcement" with a close button. It says the first banner of the placenoticeofwebx-ui/module-banners— a place of words, where a banner needs no picture — else its slot, else nothing. Closing it remembers the version of its words inlocalStorage(versionnames one of your own); new words come back for everybody. A closed bar is hidden by a line in the head before the page is painted, so it never flashes. It is in the flow and does not stick: the sticky header and--webx-header-heightare what they were.
Forms
The fields of every form of the site — <x-webx-field> of fourteen types, its value from old() and its error from $errors by a dotted name, the ARIA, the hints for an autofill — and the form around them, <x-webx-form>, sent in place over a plain POST with one answer for every form, FormResponse: Forms.
Blocks
On a site with module-blocks and module-media the package offers nine block types — php artisan webx:blocks:offered --install --module=widgets installs them (webx:setup prints the line, it does not run it). Installed, they belong to the site: an update never overwrites them.
| Block | Fields | Inside |
|---|---|---|
gallery | heading, pictures of the library, grid, slider or mosaic, columns, zoom, frame, magnify; the slider: slides at a time (1–3), slide or fade, arrows, dots, thumbnails, loop, autoplay and its seconds (5); the mosaic: still or a carousel of threes | slider gallery, lightbox |
logos | heading, a name, a logo and a link each | slider logos |
video | heading, a link or a file (a switch), poster, caption, shape 16:9 4:3 1:1 9:16 | <x-webx-video> |
map | heading, the contacts or coordinates with an address, zoom, height | <x-webx-map> |
counters | heading, a number, what stands before and after it, a label each | <x-webx-counter> |
countdown | heading, text, a date and a time of the site's zone, at the end a text or hide | <x-webx-countdown> |
compare | heading, before, after, their labels, where the divider starts, caption | <x-webx-compare> |
toc | title, the whole page or a text of its own (a switch), side, depth | <x-webx-toc> |
tabs | a line above the heading, heading, a title, a picture and a text each, picture above or beside, alignment, tabs in rows on a narrow column, the picture to the edges of a narrow screen, change at once or fade, slide over the section above | <x-webx-tabs> |
The mosaic of gallery is one large picture and two smaller ones: the large on the left and the two one above the other beside it, or — in a column narrower than 36em — the large on top and the two side by side under it. Every picture is cut to its cell; the caption (the picture's title) stands under it. "Still" shows the first three, and the lightbox still pages through all of them: the rest are links without a picture in a hidden box. "Carousel of threes" puts three on each slide with the slider's arrows, dots, loop and autoplay; three pictures or fewer stay still. The last slide holds what is left, one or two pictures at the height of three.
Loading of the grid and the mosaic: only the block that opens the page fetches its first pictures at once — the first row of the grid, the first three of the mosaic; every other picture waits until it nears the screen (loading="lazy"), and all decode off the main thread. Each one offers the media library's copies by width (640 and 1280 px, the ones narrower than the picture) and says how wide it stands: a grid's cell by the columns the block really shows — two on a phone, the whole width with one column — the mosaic's large picture two thirds of the block and the small ones a third. A copy not cut yet is cut after the page has gone out, and the next page offers it. A picture without an alt leaves its lightbox link named "Open picture 2 of 5".
A block with nothing to show — no pictures, an unknown address, a deleted file — prints nothing.
Changing the look without forking
| You want | Do this |
|---|---|
| Other colours, radius, spacing | the site tokens in theme/tokens.json — every widget follows |
| A widget's own measure | its --webx-<name>-* token (--webx-slider-gap, --webx-video-radius…) on :root or on its class |
| Another look of a part | the same class in theme/src/css — .webx-slider__pause { … }: it comes later in the cascade, no !important |
| Other markup | theme/views/vendor/webx-widgets/components/<name>.blade.php |
| A widget of the layout gone or moved | theme/compositions/layout/default.json: {"remove": ["widgets.contact-button"]} — by its id, no copy of the layout |
| An icon | theme/views/vendor/webx-widgets/icons/<name>.blade.php |
| A word | the component's prop, or lang/vendor/webx-widgets/<locale>/widgets.php |
The classes — webx-<name>, webx-<name>__<part>, states is-* — are the public contract. Style a part by its one class, not through a chain: one class beats the theme's prose and is beaten by the theme's own rule, which comes later. An overridden view keeps what the package's view promised — a slider that moves needs its pause button, and the audit checks it.
In the site audit
With webx-ui/module-audit installed, every crawled page is also read for what the widgets promise:
| Check | Severity | Finds | Fix by a button |
|---|---|---|---|
widgets.before_consent | error | a YouTube, Vimeo, Google Maps or OpenStreetMap iframe, a known counter or pixel asked at once | pasted into content: rewritten to wait for consent |
| notice | maps the owner lets load without consent ("Maps without asking") — one notice with their pages | — | |
widgets.banner_off | warning | the banner off while something third-party is on the site | turns the banner on |
widgets.lightbox_size | warning | a lightbox link without data-width / data-height | — |
widgets.slider_pause | warning | a slider that moves with no pause button — a theme's override that lost it | — |
widgets.video_pause | warning | a background video with no pause button — an override that lost it | — |
widgets.counter_number | notice | a counter whose markup does not hold its number — an override that left it to the script | — |
widgets.compare_range | warning | before and after without its range input — an override that lost it: no keyboard, no screen reader | — |
widgets.toc_target | warning | a link of a table of contents to an id the page does not have | — |
widgets.load_more_link | warning | "Show more" with a next page and no link to it — only a button, which no search engine presses | — |
widgets.zoom_link | warning | a zoom that is no link and holds none — an override that lost it, or the attribute on a bare picture | — |
widgets.form_script | warning | a form of <x-webx-form> on a page that loads no form.js — no @webxTheme or @webxWidgets | — |
widgets.contact_both | notice | the quick-contact button and the bottom bar on one page | — |
"Pasted into content" means a text block, a page's body or any field a module hands to the audit: the fix finds the code there and rewrites it — an iframe's src becomes data-src, a script becomes type="text/plain", both get data-webx-consent of their category. Code that a template prints is not in any field; wrap it in <x-webx-consent> or use the video and map blocks. A third party the audit does not know is added in webx-widgets.audit.third-party ('widget.example.com' => 'marketing').
The Kitchen sink
theme-default brings a showcase, seeded by php artisan webx:demo and removed with it: under Kitchen sink a page per widget — Header and menu, Cookie consent, Dropdown and form in a dialog, Contacts, Language switcher, Slider, Lightbox, Video, Map, Page tools, Background video, Counters and countdown, Before and after, Table of contents, Show more, Notice bar, Zoom, Forms › Fields — with every variant, a narrow column, what to try and the markup to copy. It is the place to look at a change in the theme before a real page does, and the pages the starter site's browser tests measure.