SplitButton

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.

NameElement
p-splitbuttonContainer element.
p-splitbutton-menubuttonDropdown button.
p-menuOverlay menu.

Screen Reader

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'}" />

Main Button Keyboard Support

KeyFunction
enterActivates the button.
spaceActivates the button.

Menu Button Keyboard Support

KeyFunction
enterToggles the visibility of the menu.
spaceToggles the visibility of the menu.
down arrowOpens the menu and moves focus to the first item.
up arrowOpens the menu and moves focus to the last item.

Menu Keyboard Support

KeyFunction
enterActives the menuitem, closes the menu and sets focus on the menu button.
escapeCloses the menu and sets focus on the menu button.
down arrowMoves focus to the next item, if it is the last one then first item receives the focus.
up arrowMoves focus to the previous item, if it is the first one then last item receives the focus.
homeMoves focus to the first item.
endMoves focus to the last item.