Tabs¶
setTabs(key, index, tabs) sets the dashboard tab bar for a page. Each tab is a native registered config page, { href, name }.
Decision¶
| When | Use |
|---|---|
A page that cannot use createConfigPage |
setTabs, inside viewshow. |
| A tab list that changes at runtime | A function for tabs, so the bar stays current. |
A page that passes tabs and tabsKey to createConfigPage |
Nothing. The lifecycle calls setTabs for you, so never call it yourself. |
| An in-page tab list | Sub Tabs. |
Usage¶
import { setTabs } from './configurationpage?name=myplugin_stolon.js';
view.addEventListener('viewshow', function () { setTabs('myplugin', 0, TABS); });
States and Modifiers¶
tabsis an array of{ href, name }, or a function that returns one and runs each time the dashboard shows the tabs.- The call does nothing when
LibraryMenuis not defined.
Reference¶
Generated from the code by scripts/build-docs.mjs. Edit the code, not this section.
setTabs¶
function setTabs(key: string, index: number, tabs: Tabs): void
Wires the dashboard tab bar for a config page. Call it inside viewshow with the active tab index.
Example¶
Example Code¶
<!-- title: Tabs -->
<div id="mount"></div>
<script type="module">
const base = await window.__baseReady;
const mount = document.getElementById('mount');
const list = base.createDefinitionList({ items: [] });
mount.appendChild(list.element);
// The dashboard supplies LibraryMenu. This stub shows what it receives.
window.LibraryMenu = {
setTabs: (key, index, getTabs) => list.setItems([
{ label: 'Key', value: key, mono: true },
{ label: 'Active', value: String(index) },
{ label: 'Tabs', value: getTabs().map((tab) => tab.name).join(', ') }
])
};
base.setTabs('myplugin', 1, [
{ href: 'configurationpage?name=myplugin_overview', name: 'Overview' },
{ href: 'configurationpage?name=myplugin_settings', name: 'Settings' }
]);
</script>