Components / Disclosure
Tabs
Layered sections of content displayed one at a time.
Make changes to your account here.
Change your password here.
<div class="tabs">
<div role="tablist" aria-orientation="horizontal">
<button type="button" role="tab" id="tab-account" aria-selected="true" aria-controls="panel-account">Account</button>
<button type="button" role="tab" id="tab-password" aria-selected="false" aria-controls="panel-password" tabindex="-1">Password</button>
</div>
<div role="tabpanel" id="panel-account" aria-labelledby="tab-account">
<p>Make changes to your account here.</p>
</div>
<div role="tabpanel" id="panel-password" aria-labelledby="tab-password" hidden>
<p>Change your password here.</p>
</div>
</div>Installation
pnpm dlx loseta add tabsnpx loseta add tabsExamples
Line variant
An overview of your project.
Recent activity in your project.
<div class="tabs">
<div role="tablist" aria-orientation="horizontal" data-variant="line">
<button type="button" role="tab" id="tab-overview" aria-selected="true" aria-controls="panel-overview">Overview</button>
<button type="button" role="tab" id="tab-activity" aria-selected="false" aria-controls="panel-activity" tabindex="-1">Activity</button>
</div>
<div role="tabpanel" id="panel-overview" aria-labelledby="tab-overview">
<p>An overview of your project.</p>
</div>
<div role="tabpanel" id="panel-activity" aria-labelledby="tab-activity" hidden>
<p>Recent activity in your project.</p>
</div>
</div>Accessibility and behavior
- Requires JavaScript to switch aria-selected and the hidden attribute. CSS styles the visual states.
Files
components/tabs.cssbasestyles/nova/tabs.cssstyleInstall contract
The CLI writes the base file under components/, the visual file for the selected style under styles/<name>/, and any primitive dependency underprimitives/. The generated index.css imports them in the right layer order.