Tabs
Task: split a page into sections, one visible at a time.
yaml
# Recipe: sections of a page in tabs.
paths:
components: ./componentsEach ui:tab is a section with a title; the first one opens with the page. The content of every tab is on the page, so a hidden tab is still there for search and for tests.
xml
<q:component name="Settings">
<q:set name="plan" value="Pro" />
<ui:window title="Settings">
<ui:vbox padding="lg">
<!-- One ui:tab per section; the first one is open. -->
<ui:tabpanel>
<ui:tab title="Profile">
<ui:text>Name: Ana Lima</ui:text>
<ui:text>E-mail: ana@example.com</ui:text>
</ui:tab>
<ui:tab title="Plan">
<ui:text>Current plan: {plan}</ui:text>
<ui:badge variant="success">active</ui:badge>
</ui:tab>
<ui:tab title="Security">
<ui:text>Two-step sign-in is off.</ui:text>
</ui:tab>
</ui:tabpanel>
</ui:vbox>
</ui:window>
</q:component>xml
<q:test name="every tab has its title" page="/">
<test:visit />
<test:expect text="Profile" />
<test:expect text="Plan" />
<test:expect text="Security" />
</q:test>
<q:test name="every tab's content is on the page" page="/">
<test:visit />
<test:expect text="Name: Ana Lima" />
<test:expect text="Current plan: Pro" />
<test:expect text="Two-step sign-in is off." />
</q:test>text
tests/tabs.test.q
PASS every tab has its title
PASS every tab's content is on the page
2 passed, 0 failedui:tabpanel is in the Core set drawn by the browser, the console and the desktop window: UI-7.