lara-light-indigo

SplitButton

SplitButton groups a set of commands in an overlay with a default command.

Basic
Severities
Raised Buttons
Rounded Buttons
Text Buttons
Raised Text Buttons
Outlined Buttons
Sizes
Import via Module

import { SplitButton } from 'primereact/splitbutton';
 
Import via CDN

<script src="https://unpkg.com/primereact/core/core.min.js"></script>
<script src="https://unpkg.com/primereact/splitbutton/splitbutton.min.js"></script>
 
Getting Started

SplitButton has a default command button and a collection of additional options defined by the model property.


export const SplitButtonDemo = () => {

    const items = [
        {
            label: 'Update',
            icon: 'pi pi-refresh',
            command: (e) => {
                toast.current.show({severity:'success', summary:'Updated', detail:'Data Updated'});
            }
        },
        {
            label: 'Delete',
            icon: 'pi pi-times',
            command: (e) => {
                toast.current.show({ severity: 'success', summary: 'Delete', detail: 'Data Deleted' });
            }
        },
        {
            label: 'React Website',
            icon: 'pi pi-external-link',
            command:(e) => {
                window.location.href = 'https://facebook.github.io/react/'
            }
        },
        {   label: 'Upload',
            icon: 'pi pi-upload',
            command:(e) => {
                window.location.hash = "/fileupload"
            }
        }
    ]

    const save = () => {
        toast.current.show({severity: 'success', summary: 'Success', detail: 'Data Saved'});
    }

        return (
            <SplitButton label="Save" icon="pi pi-plus" onClick={save} model={items}></SplitButton>
        )
    }
}

 
MenuModel API

SplitButton uses the common MenuModel API to define the items, visit MenuModel API for details.

Severity

Different color options are available as severity levels.

  • .p-button-secondary
  • .p-button-success
  • .p-button-info
  • .p-button-warning
  • .p-button-danger

<SplitButton label="Primary" />
<SplitButton label="Secondary" className="p-button-secondary" model={items} />
<SplitButton label="Success" className="p-button-success" model={items} />
<SplitButton label="Info" className="p-button-info" model={items} />
<SplitButton label="Warning" className="p-button-warning" model={items} />
<SplitButton label="Danger" className="p-button-danger" model={items} />

 
Raised and Rounded Buttons

SplitButton can be raised by having "p-button-raised" style class and similarly borders can be made rounded using "p-button-rounded" class.


<SplitButton label="Proceed" className="p-button-raised p-button-rounded" model={items} />
 
Properties
NameTypeDefaultDescription
idstringnullIdentifier of the component.
labelstringnullText of the button.
iconstringnullName of the icon.
modelobjectnullMenuModel instance to define the overlay items.
disabledbooleanfalseWhen present, it specifies that the component should be disabled.
visiblebooleantrueWhen present, it specifies that the element should be visible.
stylestringnullInline style of the component.
classNamestringnullClassName of the component.
buttonClassNamestringnullClassName of the button.
menuStylestringnullInline style of the overlay menu.
menuClassNamestringnullClassName class of the overlay menu.
menuButtonClassNamestringnullClassName of the menu dropdown button.
buttonPropsstringnullProps for the main button, any prop is passed implicity to the button element.
menuButtonPropsstringnullProps for the dropdown button, any prop is passed implicity to the dropdown button element.
tabIndexnumbernullIndex of the element in tabbing order.
appendToDOM element | stringdocument.bodyDOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
tooltipanynullContent of the tooltip.
tooltipOptionsobjectnullConfiguration of the tooltip, refer to the tooltip documentation for more information.
buttonTemplateanynullTemplate of the default button.
transitionOptionsobjectnullThe properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
dropdownIconstringpi pi-chevron-downIcon class of the dropdown icon.
loadingbooleanfalseDisplay loading icon of the button
loadingIconanynullName of the loading icon or JSX.Element for loading icon.
Events
NameParametersDescription
onClickevent: Browser eventCallback to invoke when main button is clicked.
onShow-Callback to invoke when overlay panel becomes visible.
onHide-Callback to invoke when overlay panel becomes hidden.
Styling

Following is the list of structural style classes, for theming classes visit theming page.

NameElement
p-splitbuttonContainer element.
p-splitbutton-buttonDropdown button.
p-menuOverlay menu.
Accessibility

This section is under development. After the necessary tests and improvements are made, it will be shared with the users as soon as possible.

Dependencies

None.

Component Scale

Input Style

Ripple Effect

Free Themes

Built-in component themes created by the PrimeReact Theme Designer.

Bootstrap
Blue
Purple
Blue
Purple
Material Design
Indigo
Deep Purple
Indigo
Deep Purple
Material Design Compact
Indigo
Deep Purple
Indigo
Deep Purple
Tailwind
Tailwind Light
Fluent UI
Blue
PrimeOne Design - 2022 NEW
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
Lara Indigo
Lara Blue
Lara Purple
Lara Teal
PrimeOne Design - 2021
Saga Blue
Saga Green
Saga Orange
Saga Purple
Vela Blue
Vela Green
Vela Orange
Vela Purple
Arya Blue
Arya Green
Arya Orange
Arya Purple
Premium Themes

Premium themes are only available exclusively for PrimeReact Theme Designer subscribers and therefore not included in PrimeReact core.

Soho Light
Soho Dark
Viva Light
Viva Dark
Mira
Nano

Legacy Free Themes

Nova
Nova Alt
Nova Accent
Luna Blue
Luna Green
Luna Amber
Luna Pink
Rhea

Premium Create-React-App Templates

Beautifully crafted premium create-react-app application templates by the PrimeTek design team.

Sakai
Atlantis
Freya
Ultima
Diamond
Sapphire
Serenity
Babylon
Avalon
Apollo
Roma