SplitButton groups a set of commands in an overlay with a default action item.
import { SplitButtonModule } from 'primeng/splitbutton';
SplitButton has a default action button and a collection of additional options defined by the model property based on MenuModel API.
<p-splitButton
label="Save"
(onClick)="save('info')"
[model]="items" />
SplitButton has a default action button and a collection of additional options defined by the model property based on MenuModel API.
<p-splitButton
label="Save"
(onClick)="save('info')"
[model]="items" />
The severity property defines the type of button.
<p-splitButton
label="Save"
(onClick)="save('info')"
[model]="items" />
<p-splitButton
label="Save"
(onClick)="save('info')"
[model]="items"
severity="secondary" />
<p-splitButton
label="Save"
(onClick)="save('success')"
[model]="items"
severity="success" />
<p-splitButton
label="Save"
(onClick)="save('info')"
[model]="items"
severity="info" />
<p-splitButton
label="Save"
(onClick)="save('warn')"
[model]="items"
severity="warning" />
<p-splitButton
label="Save"
(onClick)="save('info')"
[model]="items"
severity="help" />
<p-splitButton
label="Save"
(onClick)="save('error')"
[model]="items"
severity="danger" />
Raised buttons display a shadow to indicate elevation.
<p-splitButton
label="Primary"
[model]="items"
(onClick)="save('info')"
raised />
<p-splitButton
label="Secondary"
[model]="items"
(onClick)="save('info')"
raised
severity="secondary" />
<p-splitButton
label="Success"
[model]="items"
(onClick)="save('info')"
raised
severity="success" />
<p-splitButton
label="Info"
[model]="items"
(onClick)="save('info')"
raised
severity="info" />
<p-splitButton
label="Warning"
[model]="items"
(onClick)="save('info')"
raised
severity="warning" />
<p-splitButton
label="Help"
[model]="items"
(onClick)="save('info')"
raised
severity="help" />
<p-splitButton
label="Danger"
[model]="items"
(onClick)="save('info')"
raised
severity="danger" />
Rounded buttons have a circular border radius.
<p-splitButton
label="Primary"
[model]="items"
(onClick)="save('info')"
rounded />
<p-splitButton
label="Secondary"
[model]="items"
(onClick)="save('info')"
rounded
severity="secondary" />
<p-splitButton
label="Success"
[model]="items"
(onClick)="save('info')"
rounded
severity="success" />
<p-splitButton
label="Info"
[model]="items"
(onClick)="save('info')"
rounded
severity="info" />
<p-splitButton
label="Warning"
[model]="items"
(onClick)="save('info')"
rounded
severity="warning" />
<p-splitButton
label="Help"
[model]="items"
(onClick)="save('info')"
rounded
severity="help" />
<p-splitButton
label="Danger"
[model]="items"
(onClick)="save('info')"
rounded
severity="danger" />
Text buttons are displayed as textual elements.
<p-splitButton
label="Primary"
[model]="items"
(onClick)="save('info')"
text />
<p-splitButton
label="Secondary"
[model]="items"
(onClick)="save('info')"
text
severity="secondary" />
<p-splitButton
label="Success"
[model]="items"
(onClick)="save('info')"
text
severity="success" />
<p-splitButton
label="Info"
[model]="items"
(onClick)="save('info')"
text
severity="info" />
<p-splitButton
label="Warning"
[model]="items"
(onClick)="save('info')"
text
severity="warning" />
<p-splitButton
label="Help"
[model]="items"
(onClick)="save('info')"
text
severity="help" />
<p-splitButton
label="Danger"
[model]="items"
(onClick)="save('info')"
text
severity="danger" />
Text buttons can be displayed as raised as well for elevation.
<p-splitButton
label="Primary"
[model]="items"
(onClick)="save('info')"
raised
text />
<p-spliButton
label="Secondary"
[model]="items"
(onClick)="save('info')"
raised
text
severity="secondary" />
<p-splitButton
label="Success"
[model]="items"
(onClick)="save('info')"
raised
text
severity="success" />
<p-splitButton
label="Info"
[model]="items"
(onClick)="save('info')"
raised
text
severity="info" />
<p-splitButton
label="Warning"
[model]="items"
(onClick)="save('info')"
raised
text
severity="warning" />
<p-splitButton
label="Help"
[model]="items"
(onClick)="save('info')"
raised
text
severity="help" />
<p-splitButton
label="Danger"
[model]="items"
(onClick)="save('info')"
raised
text
severity="danger" />
Outlined buttons display a border without a background initially.
<p-splitButton
label="Primary"
[model]="items"
(onClick)="save('info')"
outlined />
<p-splitButton
label="Secondary"
[model]="items"
(onClick)="save('info')"
outlined
severity="secondary" />
<p-splitButton
label="Success"
[model]="items"
(onClick)="save('info')"
outlined
severity="success" />
<p-splitButton
label="Info"
[model]="items"
(onClick)="save('info')"
outlined
severity="info" />
<p-splitButton
label="Warning"
[model]="items"
(onClick)="save('info')"
outlined
severity="warning" />
<p-splitButton
label="Help"
[model]="items"
(onClick)="save('info')"
outlined
severity="help" />
<p-splitButton
label="Danger"
[model]="items"
(onClick)="save('info')"
outlined
severity="danger" />
SplitButton provides small and large sizes as alternatives to the standard.
<p-splitButton
label="Small"
[model]="items"
(onClick)="save('info')"
size="sm" />
<p-splitButton
label="Normal"
[model]="items"
(onClick)="save('info')" />
<p-splitButton
label="Large"
[model]="items"
(onClick)="save('info')"
size="lg" />
When the disabled attribute is present, the element is uneditable and unfocused. Additionally, the disabled states of the button and menu button can be handled independently. The button is disabled when buttonDisabled is present, and the menu button is disabled when menuButtonDisabled is present.
<p-splitButton
label="Save"
icon="pi pi-plus"
(onClick)="save('info')"
[model]="items"
[disabled]="true" />
SplitButton has a default action button and a collection of additional options defined by the model property based on MenuModel API.
<p-splitButton
label="Save"
(onClick)="save('info')"
severity="contrast"
[model]="items">
<ng-template pTemplate="content">
<span class="flex align-items-center font-bold">
<img
alt="logo"
src="https://primefaces.org/cdn/primeng/images/logo.svg"
style="height: 1rem; margin-right: 0.5rem" />
<span>PrimeNG</span>
</span>
</ng-template>
</p-splitButton>
Following is the list of structural style classes, for theming classes visit theming page.
Name | Element |
---|---|
p-splitbutton | Container element. |
p-splitbutton-menubutton | Dropdown button. |
p-menu | Overlay menu. |
SplitButton component renders two native button elements, main button uses the label property to define aria-label by default which can be customized with buttonProps. Dropdown button requires an explicit definition to describe it using menuButtonProps option and also includes aria-haspopup, aria-expanded for states along with aria-controls to define the relation between the popup and the button.
The popup overlay uses menu role on the list and each action item has a menuitem role with an aria-label as the menuitem label. The id of the menu refers to the aria-controls of the dropdown button.
<p-splitButton
[buttonProps]="{'aria-label': 'Default Action'}"
[menuButtonProps]="{'aria-label': 'More Options'}" />
Key | Function |
---|---|
enter | Activates the button. |
space | Activates the button. |
Key | Function |
---|---|
enter | Toggles the visibility of the menu. |
space | Toggles the visibility of the menu. |
down arrow | Opens the menu and moves focus to the first item. |
up arrow | Opens the menu and moves focus to the last item. |
Key | Function |
---|---|
enter | Actives the menuitem, closes the menu and sets focus on the menu button. |
escape | Closes the menu and sets focus on the menu button. |
down arrow | Moves focus to the next item, if it is the last one then first item receives the focus. |
up arrow | Moves focus to the previous item, if it is the first one then last item receives the focus. |
home | Moves focus to the first item. |
end | Moves focus to the last item. |
API defines helper props, events and others for the PrimeNG SplitButton module.
SplitButton groups a set of commands in an overlay with a default command.
Defines the input properties of the component.
Defines emit that determine the behavior of the component based on a given condition or report the actions that the component takes.
Defines the templates used by the component.