Tab Panel
<terra-tab-panel> | TerraTabPanel
Tab panels are used inside tabs to display tabbed content.
Tab panels are used inside tabs components to display tabbed content. Each
tab panel must have a name attribute that matches the panel attribute of its
corresponding tab.
<terra-tabs> <terra-tab slot="nav" panel="general">General</terra-tab> <terra-tab slot="nav" panel="custom">Custom</terra-tab> <terra-tab slot="nav" panel="advanced">Advanced</terra-tab> <terra-tab-panel name="general">This is the general tab panel.</terra-tab-panel> <terra-tab-panel name="custom">This is the custom tab panel.</terra-tab-panel> <terra-tab-panel name="advanced">This is the advanced tab panel.</terra-tab-panel> </terra-tabs>
Usage
Tab panels contain the content that is displayed when their corresponding tab is active. Only one tab panel is visible at a time.
Best Practices
-
Ensure each tab panel has a unique
namethat matches its corresponding tab’spanelattribute - Keep tab panel content focused and relevant to its tab label
- Use appropriate heading levels within tab panels for document structure
Accessibility
Tab panels use proper ARIA attributes (role="tabpanel") and are automatically hidden/shown
based on their active state. Screen readers will announce tab panel content when it becomes
active.
Additional demonstrations can be found in the tabs examples.
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/@nasa-terra/components@0.0.138/cdn/components/tab-panel/tab-panel.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.jsdelivr.net/npm/@nasa-terra/components@0.0.138/cdn/components/tab-panel/tab-panel.js';
To import this component using a bundler:
import '@nasa-terra/components/dist/components/tab-panel/tab-panel.js';
To import this component as a React component:
import TerraTabPanel from '@nasa-terra/components/dist/react/tab-panel';
Slots
| Name | Description |
|---|---|
| (default) | The tab panel’s content. |
Learn more about using slots.
Properties
| Name | Description | Reflects | Type | Default |
|---|---|---|---|---|
name
|
The tab panel’s name. |
|
string
|
''
|
active
|
When true, the tab panel will be shown. |
|
boolean
|
false
|
updateComplete
|
A read-only promise that resolves when the component has finished updating. |
Learn more about attributes and properties.
Custom Properties
| Name | Description | Default |
|---|---|---|
--padding
|
The tab panel’s padding. |
Learn more about customizing CSS custom properties.
Parts
| Name | Description |
|---|---|
base
|
The component’s base wrapper. |
Learn more about customizing CSS parts.