Skip to main content
2.0.55
Light Dark System
Compact Comfortable

Page

<zn-page> ZnPage
Since 1.0 experimental

Combines a page header with tab navigation and tab panels.

Active Email New Subscription margot.foster@example.com +44 20 7946 0958 Business, billed annually
<zn-page caption="Margot Foster" summary="Customer since March 2021 · London, UK">
  <zn-badge slot="caption-badges" type="success" dot>Active</zn-badge>
  <zn-button slot="actions" color="secondary" icon="mail@lu">Email</zn-button>
  <zn-button slot="actions" color="primary" icon="plus@lu">New Subscription</zn-button>

  <zn-tab caption="Overview">
    <zn-sp>
      <zn-panel caption="Contact">
        <zn-sp divide no-gap>
          <zn-item caption="Email">margot.foster@example.com</zn-item>
          <zn-item caption="Phone">+44 20 7946 0958</zn-item>
          <zn-item caption="Plan">Business, billed annually</zn-item>
        </zn-sp>
      </zn-panel>
    </zn-sp>
  </zn-tab>

  <zn-tab caption="Subscriptions">
    <zn-sp>
      <zn-empty-state caption="No subscriptions" description="Subscriptions for this customer appear here." icon="repeat@lu"></zn-empty-state>
    </zn-sp>
  </zn-tab>

  <zn-tab caption="Notes">
    <zn-sp>
      <zn-empty-state caption="No notes" description="Notes left by your team appear here." icon="sticky-note@lu"></zn-empty-state>
    </zn-sp>
  </zn-tab>
</zn-page>

Examples

Set caption and summary for the page title and its description, or use the caption and description slots for rich content. Put status badges in the caption-badges slot and controls in the actions slot.

Past due Download Record Payment
<zn-page caption="INV-2024-0042" summary="Issued 4 March 2024 · Due in 14 days">
  <zn-badge slot="caption-badges" type="warning">Past due</zn-badge>
  <zn-button slot="actions" color="secondary" icon="download@lu">Download</zn-button>
  <zn-button slot="actions" color="primary">Record Payment</zn-button>

  <zn-tab caption="Details">
    <zn-sp>
      <zn-cols>
        <zn-panel>
          <zn-stat caption="Amount due" amount="1250" currency="£"></zn-stat>
        </zn-panel>
        <zn-panel>
          <zn-stat caption="Paid" amount="0" currency="£"></zn-stat>
        </zn-panel>
      </zn-cols>
    </zn-sp>
  </zn-tab>
</zn-page>

Links in the breadcrumb slot show above the caption, separated by an icon. Breadcrumbs are hidden in nested and modal pages.

Settings Acme Inc Required for all members 12 hours
<zn-page caption="Security" summary="Sign-in and access settings for Acme Inc">
  <a href="#" slot="breadcrumb">Settings</a>
  <a href="#" slot="breadcrumb">Acme Inc</a>

  <zn-tab caption="Overview">
    <zn-sp>
      <zn-panel caption="Sign-in">
        <zn-sp divide no-gap>
          <zn-item caption="Two-factor authentication">Required for all members</zn-item>
          <zn-item caption="Session timeout">12 hours</zn-item>
        </zn-sp>
      </zn-panel>
    </zn-sp>
  </zn-tab>
</zn-page>

Header Metadata

previous-path adds a back button, and previous-target sets where it opens. entity-id and full-location add copy buttons, shown while Alt is held. Hold Alt over this example to see them.

margot.foster@example.com
<zn-page
  caption="Margot Foster"
  summary="Customer"
  previous-path="/customers"
  entity-id="cus_8F2kD91xQ"
  full-location="/customers/cus_8F2kD91xQ">
  <zn-tab caption="Overview">
    <zn-sp>
      <zn-panel caption="Contact">
        <zn-item caption="Email">margot.foster@example.com</zn-item>
      </zn-panel>
    </zn-sp>
  </zn-tab>
</zn-page>

Tabs

Each zn-tab becomes a tab. A tab gets its id from its caption, and a tab captioned Overview gets the empty id, which always shows first. Other tabs keep their source order unless priority is set: higher numbers come first. Add selected to open a tab other than the first.

Tabs stay in the page’s light DOM, so styles scoped to where they are written still apply.

Visa ending 4242 Owner Admin Europe (London)
<zn-page caption="Acme Inc" summary="Workspace">
  <zn-tab caption="Billing" priority="10">
    <zn-sp>
      <zn-panel caption="Billing">
        <zn-item caption="Payment method">Visa ending 4242</zn-item>
      </zn-panel>
    </zn-sp>
  </zn-tab>

  <zn-tab caption="Members" priority="20" selected>
    <zn-sp>
      <zn-panel caption="Members">
        <zn-sp divide no-gap>
          <zn-item caption="Margot Foster">Owner</zn-item>
          <zn-item caption="Sam Patel">Admin</zn-item>
        </zn-sp>
      </zn-panel>
    </zn-sp>
  </zn-tab>

  <zn-tab caption="Overview">
    <zn-sp>
      <zn-panel caption="Workspace">
        <zn-item caption="Region">Europe (London)</zn-item>
      </zn-panel>
    </zn-sp>
  </zn-tab>
</zn-page>

Tab Icons

Set icon on a zn-tab to show an icon before its caption.

margot.foster@example.com
<zn-page caption="Margot Foster" summary="Customer">
  <zn-tab caption="Overview" icon="layout-grid@lu">
    <zn-sp>
      <zn-panel caption="Contact">
        <zn-item caption="Email">margot.foster@example.com</zn-item>
      </zn-panel>
    </zn-sp>
  </zn-tab>

  <zn-tab caption="History" icon="history@lu">
    <zn-sp>
      <zn-empty-state caption="No history yet" icon="history@lu"></zn-empty-state>
    </zn-sp>
  </zn-tab>
</zn-page>

Dynamic Tabs

Set uri on a zn-tab to load its content from that address when the tab is first opened.

<zn-page caption="Reports" summary="Revenue and usage across your workspace">
  <zn-tab caption="Overview">
    <zn-sp>
      <zn-cols>
        <zn-panel>
          <zn-stat caption="Revenue" description="This month" amount="48250" previous="42100" currency="£" show-delta></zn-stat>
        </zn-panel>
        <zn-panel>
          <zn-stat caption="Active customers" amount="1284" previous="1210" show-delta></zn-stat>
        </zn-panel>
      </zn-cols>
    </zn-sp>
  </zn-tab>

  <zn-tab caption="Revenue" uri="/reports/revenue"></zn-tab>
  <zn-tab caption="Usage" uri="/reports/usage"></zn-tab>
</zn-page>

Nested Tabs

Put zn-tab elements inside a zn-tab to give that tab its own set of tabs. They show as a grey pill track below the main tab bar, so they read as secondary.

£1,250.00 · Past due £1,250.00 · Paid Default · Expires 08/27
<zn-page caption="Margot Foster" summary="Customer">
  <zn-tab caption="Billing">
    <zn-tab caption="Invoices">
      <zn-sp>
        <zn-panel caption="Invoices">
          <zn-sp divide no-gap>
            <zn-item caption="INV-2024-0042">£1,250.00 · Past due</zn-item>
            <zn-item caption="INV-2024-0031">£1,250.00 · Paid</zn-item>
          </zn-sp>
        </zn-panel>
      </zn-sp>
    </zn-tab>

    <zn-tab caption="Payment Methods">
      <zn-sp>
        <zn-panel caption="Payment methods">
          <zn-item caption="Visa ending 4242">Default · Expires 08/27</zn-item>
        </zn-panel>
      </zn-sp>
    </zn-tab>
  </zn-tab>

  <zn-tab caption="Notes">
    <zn-sp>
      <zn-empty-state caption="No notes" icon="sticky-note@lu"></zn-empty-state>
    </zn-sp>
  </zn-tab>
</zn-page>

A zn-page placed in a tab is a page of its own, with its own header and a normal tab bar.

navigation-style sets the tab design:

  • tabs – a tab bar below the header. This is the default.
  • pills – a pill track with no page header, for a page that only holds a second set of tabs. Nested tabs use it.
  • sidebar – for tabs shown outside the page, such as in an app sidebar. The page hides its tab bar unless the bottom slot has content, and still loads tabs and keeps their history as the outside navigation selects them.
£1,250.00 · Past due
<zn-page caption="Margot Foster" summary="Customer">
  <zn-tab caption="Billing">
    <zn-page nested navigation-style="pills">
      <zn-tab caption="Invoices">
        <zn-sp>
          <zn-panel caption="Invoices">
            <zn-item caption="INV-2024-0042">£1,250.00 · Past due</zn-item>
          </zn-panel>
        </zn-sp>
      </zn-tab>
      <zn-tab caption="Credit Notes">
        <zn-sp>
          <zn-empty-state caption="No credit notes" icon="receipt@lu"></zn-empty-state>
        </zn-sp>
      </zn-tab>
    </zn-page>
  </zn-tab>

  <zn-tab caption="Notes">
    <zn-sp>
      <zn-empty-state caption="No notes" icon="sticky-note@lu"></zn-empty-state>
    </zn-sp>
  </zn-tab>
</zn-page>

Linking to a Tab

Give any element in the page a tab attribute holding a tab’s id to open that tab when it is clicked. Links inside a nested zn-page or zn-tabs open tabs in that nested container.

£1,250.00 View invoices £1,250.00 · Past due
<zn-page caption="Margot Foster" summary="Customer">
  <zn-tab caption="Overview">
    <zn-sp>
      <zn-panel caption="Billing">
        <zn-item caption="Outstanding balance">£1,250.00</zn-item>
        <zn-button slot="actions" tab="invoices" color="secondary" size="small">View invoices</zn-button>
      </zn-panel>
    </zn-sp>
  </zn-tab>

  <zn-tab caption="Invoices">
    <zn-sp>
      <zn-panel caption="Invoices">
        <zn-item caption="INV-2024-0042">£1,250.00 · Past due</zn-item>
      </zn-panel>
    </zn-sp>
  </zn-tab>
</zn-page>

Put actions in the footer slot to pin them below the content while it scrolls. Give zn-form-actions a form attribute so it can submit a form it sits outside of. In a modal page the footer takes the dialog footer’s styling.

<zn-page caption="New Customer" summary="Add a customer to Acme Inc" modal style="height: 420px;">
  <zn-tab caption="Details">
    <form id="page-footer-form">
      <zn-sp>
        <zn-input label="Full name" name="name" required></zn-input>
        <zn-input label="Email" name="email" type="email" required></zn-input>
      </zn-sp>
    </form>
  </zn-tab>

  <zn-form-actions slot="footer" form="page-footer-form" with-cancel submit-text="Add customer"
                   submit-icon="plus@lu"></zn-form-actions>
</zn-page>

Full Width

The header, tabs and content are capped at the container width (--zn-container) and centred. Add full-width to let them span the whole page, such as for wide tables. A flush page always spans it.

<zn-page caption="Transactions" summary="All payments across your workspace" full-width>
  <zn-tab caption="Overview">
    <zn-sp>
      <zn-cols>
        <zn-panel>
          <zn-stat caption="Volume" description="Last 30 days" amount="182400" currency="£"></zn-stat>
        </zn-panel>
        <zn-panel>
          <zn-stat caption="Payments" description="Last 30 days" amount="3192"></zn-stat>
        </zn-panel>
        <zn-panel>
          <zn-stat caption="Declined" description="Last 30 days" amount="41"></zn-stat>
        </zn-panel>
      </zn-cols>
    </zn-sp>
  </zn-tab>
</zn-page>

Fill

Add fill for content that scrolls itself, such as a kanban board: the page stops scrolling and its content fills the height under the header. The content’s root needs grow to fill it.

Refund request Card declined Address change Invoice copy Cancel subscription Login trouble
<div style="height: 420px">
  <zn-page caption="Pipeline" summary="Every ticket by status" full-width fill>
    <zn-sp grow>
      <zn-kanban>
        <zn-kanban-column caption="Open">
          <zn-kanban-item>Refund request</zn-kanban-item>
          <zn-kanban-item>Card declined</zn-kanban-item>
          <zn-kanban-item>Address change</zn-kanban-item>
          <zn-kanban-item>Invoice copy</zn-kanban-item>
          <zn-kanban-item>Cancel subscription</zn-kanban-item>
          <zn-kanban-item>Login trouble</zn-kanban-item>
        </zn-kanban-column>
        <zn-kanban-column caption="Resolved"></zn-kanban-column>
      </zn-kanban>
    </zn-sp>
  </zn-page>
</div>

Importing

If you’re using the autoloader or the traditional loader, you can ignore this section. Otherwise, feel free to use any of the following snippets to cherry pick this component.

To import this component from the CDN using a script tag:

<script type="module" src="https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.55/dist/components/page/page.js"></script>

To import this component from the CDN using a JavaScript import:

import 'https://cdn.jsdelivr.net/npm/@kubex/zinc@2.0.55/dist/components/page/page.js';

To import this component using a bundler:

import '@kubex/zinc/dist/components/page/page.js';

Slots

Name Description
(default) Page content. Use zn-tab for named tabs; without any, the content is shown as the page’s only view. A zn-tab holding zn-tabs shows them as a second tab set, drawn as pills. Use header-action/header-actions for header actions. Clicking an element in the content with tab="<tab id>" opens that tab.
caption-badges Badges shown beside the caption, wrapping onto the next line as one group.
description Rich subtitle/description content. Falls back to the summary attribute when empty.
bottom Content rendered below the navbar row (e.g. chips, filters). Forwarded to the navbar’s bottom slot.
footer Actions pinned below the content, such as a form’s zn-form-actions. In a modal page it takes the dialog footer’s styling.
example An example slot.

Learn more about using slots.

Properties

Name Description Reflects Type Default
fill Fits the content to the height under the header instead of scrolling the page, for content that scrolls itself. boolean false
navigationStyle
navigation-style
The tab design: tabs (the default), pills for a second tab set below a main tab bar, shown without the page header, or sidebar when the tabs are shown outside the page, which hides the tab bar unless it has bottom content. 'tabs' | 'pills' | 'sidebar' | undefined -
panelTtl
panel-ttl
Seconds a uri tab’s panel may go unshown before it is unloaded, loading afresh when next opened. 0 keeps them all. number 0
selectAdded
select-added
With store-key, opens a tab that has appeared since the page was last shown, such as one for an item just added, in place of the remembered tab. boolean false
gap Spaces a left or right slot from the content, for side navigation laid out as its own card. boolean false
updateComplete A read-only promise that resolves when the component has finished updating.

Learn more about attributes and properties.

Events

Name React Event Description Event Detail
zn-event-name Emitted as an example. -

Learn more about events.

Methods

Name Description Arguments
getTabStoreKey() The key the active tab is persisted under. Null disables persistence. -
activateDefaultTab() Activates the tab the container starts on, ignoring any stored selection. -
unloadIdlePanels() Unloads every uri tab panel left unshown for longer than panel-ttl. now:
unloadPanel() Drops a uri tab’s panel while keeping its tab, which loads the panel afresh when next opened. tabId: string

Learn more about methods.

Custom Properties

Name Description Default
--example An example CSS custom property.

Learn more about customizing CSS custom properties.

Parts

Name Description
footer The footer wrapping the footer slot.
base The component’s base wrapper.

Learn more about customizing CSS parts.