Repository navigation
Feature Developer API
Every Tabdeck deck on the page registers itself with one object, window.tabdeck. Use it from the browser console while you build a dashboard, or from another custom card, browser_mod or your own JavaScript. Nothing else is added to window, and there is nothing to turn on.
> tabdeck.list()
[ { id: "main", tab: "Home", index: 0, tabs: 5, names: ["Home", "Lights", …] },
{ id: "kitchen", tab: "Recipes", index: 0, tabs: 3, names: [ … ] } ]
> tabdeck.get("main").select("Cameras")
trueA deck's id is its event_id, else its storage_key, else a hash of its config (shown in the debug panel as deck …). Give the decks you want to drive an event_id so the id doesn't change when you edit them. When two decks share an id (the same card on two views), get() returns the one on screen.
| Call | Returns |
|---|---|
tabdeck.list() |
every connected deck: { id, tab, index, tabs, names } (tab is the open tab's name, tabs the number of visible tabs) |
tabdeck.get(id?) |
a handle for one deck (without an id: the first one on screen), or undefined
|
tabdeck.select(id, target) |
true when the deck switched (or was already there) |
tabdeck.on(type, fn) |
a function that stops listening |
tabdeck.version |
the card's version |
A handle from get() has the same fields as a list() entry (read when you called get), plus element (the tabdeck-card element) and select(target), next(), previous(), back() and default().
target is a tab name, an index (0 = first visible tab), a slug (living-room), or one of the step words next, previous, back (the tab open before) and default (the deck's starting tab). A PIN-locked tab asks for its PIN and returns false, as a tap would (the same goes for selectTab() and selectDefault() on the element). next and previous step past locked tabs. Page code isn't held to the PIN in other ways (it can reach the tab's card directly), so the PIN is no protection against code you install.
tabdeck.on(type, fn) calls fn(detail); window.tabdeck is also an EventTarget, so addEventListener(type, e => e.detail) works too.
| Event | Detail |
|---|---|
tab-changed |
{ id, index, name, previous }, for every switch (taps, swipes, automations, select) |
added |
{ id }: a deck connected to the page |
removed |
{ id }: a deck left the page (another view opened) |
const stop = tabdeck.on("tab-changed", (d) => console.log(d.id, d.previous, "→", d.name));Each tabdeck-card element keeps its own API: selectTab(nameOrIndex), selectedTab, selectDefault(), breadcrumbPath() and the bubbling, composed tabdeck-tab-changed event (detail: { index, name, deck }). See Grouped tabs.
Concepts
Features
- All features
- Dynamic tabs
- Remote control & events
- PIN-locked tabs
- Reuse: defaults & templates
- Debug panel
- Developer access
- Pictures, animations & fonts
- State-driven icons & names
- Alert pulse
- Auto-rotate & idle return
- Navigation & action tabs
- Scroll-spy
- Collapsible deck
- Responsive layouts
- Style presets
- Tab-change actions
- Tab display mode
- Accent indicator
- Extra bar styles
- Indicator thickness
- Sticky tab bar
- Tab alignment
- Badge display mode
- Per-tab colour
- Tab subtitles
- Disabled tabs
- Multiple cards per tab
- One-line tab content
- Panel transitions
- Content layout
- Duplicate tab
- Expand/Collapse all
- Edit mode helpers
- Why is this tab hidden?
- Starter templates
- Convert from another card
- Languages
- YAML autocomplete
- Dock & floating action tabs
- Dots & content arrows
- Grouped tabs
- Overview grid
- Linked decks
- Tab as popup
- Wizard mode
- Search & shortcuts
- Gestures
- Arrange tabs