Skip to content

hd-tabs

Attributes and example

hd-tabs

on change

Panes (hd-tab) of which one shows at a time, switched by tapping the tab bar, swiping across the pane or the arrow keys. To remember the choice per screen, bind selected to the widget’s state and keep each change: selected="{{ state.period }}" data-hd-on-change="setState('period', event.value)".

AttributeWhat it is
selectedThe name of the tab to show; empty or unknown shows the first.
labelWhat the tabs choose between, for screen readers, e.g. “Period”.
variantThe tab bar: a pill track, an underline, a segmented track, plain (the Navigation bar’s look: a soft wash behind the current tab, or behind its icon with layout="stacked"), glass (frosted with the theme’s blur), dots (the labels are read out), or none: no bar, the panes swipe.One of pill, underline, segmented, plain, glass, dots, none. Default pill.
placementWhere the tab bar sits. On the left or right it is a rail the pane’s height, at least 48, 56 or 72 px wide by size (or --hd-tabs-rail-width); the pages come in from above or below.One of top, bottom, left, right. Default top.
fillSpreads the tabs along the bar: over its width at the top or bottom, over its height on a side. Left out, each tab is as big as it needs; spread out on a crowded bar, a tab narrower than 72 px shows its icon only.Default false.
alignWhere tabs that don’t fill the bar sit: at its start, centre or end (top, middle or bottom on a side).One of start, center, end. Default start.
layoutThe icon beside the name (inline) or over it (stacked), as an app’s tab bar.One of inline, stacked. Default inline.
floatingStands the bar off the box, centred and with a shadow, instead of part of it.Default false.
transitionHow a new page comes in after a tap: sliding (the default), fading or at once. Reduced motion fades and e-ink cuts whatever this says.One of slide, fade, cut. Default slide.
startThe name of the tab shown while selected names none, and the one idle goes back to; left out, the first.
idleGoes back to the start tab after this many seconds without a touch (at least 5), saying so as change. For wall panels; not on e-ink.
axisWhich way the panes turn: sideways (swipe across), or up and down like a smart display’s stack (swipe up for the next, down for the one before; the next pane comes up from below). Put the bar on a side (placement="right") or hide it for the look.One of horizontal, vertical. Default horizontal.
loopA swipe goes round the ends: past the last pane comes the first, before the first the last (the timer always does).Default false.
showWhat the tabs show of each pane: both its icon and label, only the label, or only the icon (a tab without an icon keeps its label; screen readers always hear the label).One of both, label, icon. Default both.
sizeHow big the tabs (and the dots) are to tap: small, medium for a tablet, large for a wall panel across the room, or auto, medium on a touch screen and small with a mouse.One of small, medium, large, auto. Default small.
swipeSwiping across the pane goes to the next or previous tab (and never pages a wall panel).Default true.
everyTurns to the next tab by itself every this many seconds (3 to 300), round to the first after the last. It pauses for 30 seconds after a touch, stops while the page is out of sight and on a screen that doesn’t animate (e-ink). With full motion a thin line (part="countdown") runs down to the next turn, hidden while it waits after a touch. Left out, the tabs only turn when someone does.
<hd-tabs label="Period" selected="{{ state.period }}"  data-hd-on-change="setState('period', event.value)">  <hd-tab name="today" label="Today"><p>Today</p></hd-tab>  <hd-tab name="week" label="Week"><p>This week</p></hd-tab></hd-tabs>

Styling

Set CSS variables on the component element. Its internal elements live in Shadow DOM; only the exposed named parts can be styled with ::part.

--hd-accent
The theme’s accent: active controls, links, highlights.
--hd-blur
The frosted-glass filter behind tiles, or none.
--hd-border
Lines round tiles and between parts.
--hd-border-width
How thick borders are.
--hd-danger
Act now: smoke, a leak, an alarm.
--hd-ease-out
The easing of most movement.
--hd-ease-spring
A springy easing, for things that bounce into place.
--hd-flat
1 on e-ink: no colours, glows or gradients, only black and white.
--hd-focus
The outline round what has keyboard focus.
--hd-font-ui
The font of labels and running text.
--hd-motion-base
An ordinary change, like a value sliding.
--hd-motion-fast
A quick change, like a press. 0ms when nothing may move.
--hd-on-accent
Text and icons on the accent.
--hd-radius-md
Medium corners: buttons, fields.
--hd-radius-pill
CSS input read by hd-tabs.
--hd-radius-sm
Small corners: chips, small buttons.
--hd-shadow
A tile’s shadow.
--hd-surface
A tile’s colour.
--hd-surface-raised
Something on a tile that stands out from it, like a button.
--hd-tab-active-bg
CSS input read by hd-tabs.
--hd-tab-active-color
CSS input read by hd-tabs.
--hd-tab-color
CSS input read by hd-tabs.
--hd-tab-icon-size
CSS input read by hd-tabs.
--hd-tab-own
CSS input read by hd-tabs.
--hd-tab-pad
CSS input read by hd-tabs.
--hd-tab-radius
CSS input read by hd-tabs.
--hd-tabs-badge-alert
CSS input read by hd-tabs.
--hd-tabs-badge-alert-color
CSS input read by hd-tabs.
--hd-tabs-badge-bg
CSS input read by hd-tabs.
--hd-tabs-badge-color
CSS input read by hd-tabs.
--hd-tabs-bar-bg
CSS input read by hd-tabs.
--hd-tabs-bar-pad
CSS input read by hd-tabs.
--hd-tabs-bar-radius
CSS input read by hd-tabs.
--hd-tabs-gap
CSS input read by hd-tabs.
--hd-tabs-indicator
CSS input read by hd-tabs.
--hd-tabs-indicator-color
CSS input read by hd-tabs.
--hd-tabs-pane-bg
CSS input read by hd-tabs.
--hd-tabs-pane-border
CSS input read by hd-tabs.
--hd-tabs-pane-pad
CSS input read by hd-tabs.
--hd-tabs-pane-radius
CSS input read by hd-tabs.
--hd-tabs-rail-width
CSS input read by hd-tabs.
--hd-tabs-space
CSS input read by hd-tabs.
--hd-text
Text and big numbers.
--hd-text-faint
The quietest text: hints, units, times.
--hd-text-muted
Labels and secondary text.
--hd-track
The empty part of a slider, bar or ring.

Exposed parts

hd-tabs::part(add) {  /* Your styles */}hd-tabs::part(badge) {  /* Your styles */}hd-tabs::part(bar) {  /* Your styles */}hd-tabs::part(countdown) {  /* Your styles */}hd-tabs::part(indicator) {  /* Your styles */}hd-tabs::part(pane) {  /* Your styles */}hd-tabs::part(tab) {  /* Your styles */}

Style the host

hd-tabs {  --hd-accent: #2563eb;  max-width: 100%;}
Theme variables