Tab component is a web component that displays a tabbed interface. It can be used to switch between different sections of content.
Tab items must be used with the dap-ds-tab-group component. The
dap-ds-tab component is used to create a tab. The tabId attribute is used to identify the tab and it is mandantory. The content of the tab is placed inside the content slot.
Tabs can be customized with icons or other components. It can accept any component as a child.
Tabs can be small or large. Default size is sm
Tabs can be stacked on mobile devices with the mobile attribute.
import { DapDSTab } from 'dap-design-system'
import { DapDSTabReact } from 'dap-design-system/react'
For optimal bundle sizes, use the tree-shakeable import syntax:
import { DapDSTab } from 'dap-design-system/components'
| Property | Type | Default | Description |
|---|---|---|---|
tabId | string | The tab id. Required | |
disabled | boolean | false | The disabled state of the tab. |
| Name | Description |
|---|---|
(default) | The tab title template. |
content | The tab content. |
No custom events available.
| Part Name | Description |
|---|---|
base | The main tab content container. |
You can style CSS parts using the ::part() pseudo-element selector:
/* Target a specific part */
.my-custom-dap-ds-tab::part(base) {
/* Your custom styles */
}
Example usage:
<dap-ds-tab class="my-custom-dap-ds-tab">
Tab
</dap-ds-tab>
.my-custom-dap-ds-tab::part(base) {
border-radius: 12px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
CSS parts allow you to style internal elements of the component while maintaining encapsulation. Learn more in our styling guide.
No CSS custom properties available.
| Property | Type | Default | Description |
|---|---|---|---|
selectedTabId | string | The selected tab id. | |
size | 'sm', 'lg' | 'sm' | The size of the tab buttons. Default is sm. Can be sm or lg. |
mobile | boolean | false | If true, the tab group will be displayed in mobile mode. |
| Name | Description |
|---|---|
(default) | The tab items. |
| Event Name | Description | Type |
|---|---|---|
dds-tab-select | Fired when select a new tab. | void |
| Part Name | Description |
|---|---|
base | The main container. |
tab-nav | The tab navigation container. |
tab-content | The tab content container. |
| Property Name | Description |
|---|---|
--dds-tab-group-border-radius | Border radius of the tab group container |
--dds-tab-group-border-width | Border width of the tab navigation |
--dds-tab-group-border-color | Border color of the tab navigation |
--dds-tab-height-sm | Height of small tabs |
--dds-tab-height-lg | Height of large tabs |
--dds-tab-font-size-sm | Font size of small tabs |
--dds-tab-font-size-lg | Font size of large tabs |
--dds-tab-padding | Padding of the tab buttons |
--dds-tab-border-width | Border width for tabs |
--dds-tab-selected-border-color | Border color for selected tabs |
--dds-tab-text-color | Text color for tabs |
--dds-tab-hover-text-color | Text color for tabs on hover |
--dds-tab-disabled-text-color | Text color for disabled tabs |
--dds-tab-hover-background | Background color for tabs on hover |
--dds-tab-active-background | Background color for active tabs |