Tab Panel
<ol-tab-panel> | OlTabPanel
Tab panels are used inside tab groups to display tabbed content.
<ol-tab-group> <ol-tab slot="nav" panel="general">General</ol-tab> <ol-tab slot="nav" panel="custom">Custom</ol-tab> <ol-tab slot="nav" panel="advanced">Advanced</ol-tab> <ol-tab slot="nav" panel="disabled" disabled>Disabled</ol-tab> <ol-tab-panel name="general">This is the general tab panel.</ol-tab-panel> <ol-tab-panel name="custom">This is the custom tab panel.</ol-tab-panel> <ol-tab-panel name="advanced">This is the advanced tab panel.</ol-tab-panel> <ol-tab-panel name="disabled">This is a disabled tab panel.</ol-tab-panel> </ol-tab-group>
import OlTab from '@onlive.site/ui/dist/react/tab'; import OlTabGroup from '@onlive.site/ui/dist/react/tab-group'; import OlTabPanel from '@onlive.site/ui/dist/react/tab-panel'; const App = () => ( <OlTabGroup> <OlTab slot="nav" panel="general"> General </OlTab> <OlTab slot="nav" panel="custom"> Custom </OlTab> <OlTab slot="nav" panel="advanced"> Advanced </OlTab> <OlTab slot="nav" panel="disabled" disabled> Disabled </OlTab> <OlTabPanel name="general">This is the general tab panel.</OlTabPanel> <OlTabPanel name="custom">This is the custom tab panel.</OlTabPanel> <OlTabPanel name="advanced">This is the advanced tab panel.</OlTabPanel> <OlTabPanel name="disabled">This is a disabled tab panel.</OlTabPanel> </OlTabGroup> );
Examples
Unmounted Tab Panels
Use unmount
to prevent tab panels from being rendered until they are activated.
<ol-tab-group> <ol-tab slot="nav" panel="general">General</ol-tab> <ol-tab slot="nav" panel="custom">Custom</ol-tab> <ol-tab slot="nav" panel="advanced">Advanced</ol-tab> <ol-tab-panel name="general" unmount>This is the general tab panel.</ol-tab-panel> <ol-tab-panel name="custom" unmount>This is the custom tab panel.</ol-tab-panel> <ol-tab-panel name="advanced" unmount>This is the advanced tab panel.</ol-tab-panel> </ol-tab-group>
import OlTab from '@onlive.site/ui/dist/react/tab'; import OlTabGroup from '@onlive.site/ui/dist/react/tab-group'; import OlTabPanel from '@onlive.site/ui/dist/react/tab-panel'; const App = () => ( <OlTabGroup> <OlTab slot="nav" panel="general"> General </OlTab> <OlTab slot="nav" panel="custom"> Custom </OlTab> <OlTab slot="nav" panel="advanced"> Advanced </OlTab> <OlTabPanel name="general" unmount> This is the general tab panel. </OlTabPanel> <OlTabPanel name="custom" unmount> This is the custom tab panel. </OlTabPanel> <OlTabPanel name="advanced" unmount> This is the advanced tab panel. </OlTabPanel> </OlTabGroup> );
Additional demonstrations can be found in the tab group 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.onlive.site/@onlive.site/ui@1.8.20/cdn/components/tab-panel/tab-panel.js"></script>
To import this component from the CDN using a JavaScript import:
import 'https://cdn.onlive.site/@onlive.site/ui@1.8.20/cdn/components/tab-panel/tab-panel.js';
To import this component using a bundler:
import '@onlive.site/ui/dist/components/tab-panel/tab-panel.js';
To import this component as a React component:
import OlTabPanel from '@onlive.site/ui/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
|
unmount
|
When true, the tab panel will be removed from the DOM when not active. |
|
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.