Primitives
Dynamically show and hide content based on an active tab.
Import the Tabs primitives from ng-primitives/tabs.
import { NgpTabset, NgpTabList, NgpTabButton, NgpTabPanel } from 'ng-primitives/tabs';
Assemble the tabs directives in your template.
<div ngpTabset>
<div ngpTabList>
<button ngpTabButton ngpTabButtonValue="tab1">Tab 1</button>
<button ngpTabButton ngpTabButtonValue="tab2">Tab 2</button>
<button ngpTabButton ngpTabButtonValue="tab3">Tab 3</button>
</div>
<div ngpTabPanel ngpTabPanelValue="tab1">Tab 1 content</div>
<div ngpTabPanel ngpTabPanelValue="tab2">Tab 2 content</div>
<div ngpTabPanel ngpTabPanelValue="tab3">Tab 3 content</div>
</div>
Create reusable components that uses the tab directives.
Generate a reusable tab components using the Angular CLI.
ng g ng-primitives:primitive tabs
path: The path at which to create the component file.prefix: The prefix to apply to the generated component selector.componentSuffix: The suffix to apply to the generated component class name.fileSuffix: The suffix to apply to the generated component file name. Defaults to component.exampleStyles: Whether to include example styles in the generated component file. Defaults to true.The following directives are available to import from the ng-primitives/tabs package:
The following data attributes are applied to the ngpTabset directive:
| Attribute | Description | Value |
|---|---|---|
data-orientation |
The orientation of the tabs. | horizontal | vertical |
The following data attributes are applied to the ngpTabList directive:
| Attribute | Description | Value |
|---|---|---|
data-orientation |
The orientation of the tabs. | horizontal | vertical |
The following data attributes are applied to the ngpTabButton directive:
| Attribute | Description | Value |
|---|---|---|
data-orientation |
The orientation of the tabs. | horizontal | vertical |
data-active |
Applied when the tab is active. | - |
data-disabled |
Applied when the tab is disabled. | - |
data-hover |
Applied when the tab is hovered. | - |
data-focus-visible |
Applied when the tab is focused. | - |
data-press |
Applied when the tab is pressed. | - |
The following data attributes are applied to the ngpTabPanel directive:
| Attribute | Description | Value |
|---|---|---|
data-active |
Applied when the tab is active. | - |
data-orientation |
The orientation of the tabs. | horizontal | vertical |
You can configure the default options for all tabs in your application by using the provideTabsConfig function in a providers array.
import { provideTabsConfig } from 'ng-primitives/tabs';
bootstrapApplication(AppComponent, {
providers: [
provideTabsConfig({
orientation: 'horizontal',
activateOnFocus: false,
wrap: false,
}),
],
});
The following options are available to configure the default tab options:
Adheres to the Tabs WAI-ARIA design pattern.
Copyright © 2026 Angular Primitives
This site is powered by Netlify