• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

CommandPalette

CommandPalette is a filterable grouped context menu: a searchable popup with categorized options, triggered by right-click on a target element. Based on stak-grouplist by newk5.

CommandPalette Tag Documentation

CommandPalette is a filterable grouped context menu triggered by right-click.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
filterPlaceholder String false Search... Placeholder text for the search/filter input.
for String true ID of the target component that triggers the command palette on right-click.
height String false 400 Maximum height of the palette in pixels or a CSS value.
label String false Header label text displayed at the top of the palette.
onSelect String false Client-side callback to execute when an item is selected. Signature: function(option).
showFilter boolean false true Whether to show the filter/search input.
showHeader boolean false true Whether to show the header section.
style String false Inline style of the component.
styleClass String false Style class of the component.
triggerEvent String false contextmenu Event type that triggers the palette. Default is contextmenu (right-click).
width String false 280 Width of the palette in pixels or a CSS value.

CommandPaletteItem Tag Documentation

Defines an item within a CommandPalette group; used as a child of CommandPalette.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
group String true Group name this item belongs to.
groupTitle String false Tooltip text for the group header.
itemTitle String false Tooltip text for the item.
label String true Display label of the item.
value String true Value of the item.
Tag Documentation Widget Source
Basic usage

Basic usage with right-click trigger and grouped items.

Right-click here to open the CommandPalette
▶File
New File
Open File
Save
Save As...
▶Edit
Undo
Redo
Cut
Copy
Paste
▶View
Zoom In
Zoom Out
Fullscreen
Selection Event

Using the select AJAX event to handle item selection on the server side.

Right-click here to select a Node action
▶Node1
Create Node1 Action1
Create Node1 Action2
▶Node2
Create Node2 Action1
Create Node2 Action2
Hotkey Trigger

Trigger the CommandPalette via a keyboard shortcut using p:hotkey (Ctrl+Shift+K). The palette also remains available via right-click on the target element.

Right-click or press Ctrl+Shift+K to open the CommandPalette
▶File
New File
Open File
Save
Save As...
▶Edit
Undo
Redo
Cut
Copy
Paste
▶View
Zoom In
Zoom Out
Fullscreen

Usage


<style>
    .palette-target {
        border: 2px solid var(--p-content-border-color);
        border-radius: 3px;
        padding: 40px;
        text-align: center;
        cursor: context-menu;
        background: light-dark(var(--p-surface-50), var(--p-surface-950));
        font-size: 14px;
        color: var(--p-text-color);
        user-select: none;
    }
</style>

<div class="card">
    <h5>Basic usage</h5>
    <p>Basic usage with right-click trigger and grouped items.</p>
    <h:form id="formBasicUsage">
        <h:panelGroup id="commandPaletteTarget" layout="block" styleClass="palette-target">
            Right-click here to open the CommandPalette
        </h:panelGroup>
        <pe:commandPalette id="palette" for="commandPaletteTarget"
                           label="Actions" filterPlaceholder="Search actions..." width="260" height="350">
            <pe:commandPaletteItem group="File" value="new" label="New File"/>
            <pe:commandPaletteItem group="File" value="open" label="Open File"/>
            <pe:commandPaletteItem group="File" value="save" label="Save"/>
            <pe:commandPaletteItem group="File" value="saveAs" label="Save As..."/>
            <pe:commandPaletteItem group="Edit" value="undo" label="Undo"/>
            <pe:commandPaletteItem group="Edit" value="redo" label="Redo"/>
            <pe:commandPaletteItem group="Edit" value="cut" label="Cut"/>
            <pe:commandPaletteItem group="Edit" value="copy" label="Copy"/>
            <pe:commandPaletteItem group="Edit" value="paste" label="Paste"/>
            <pe:commandPaletteItem group="View" value="zoomIn" label="Zoom In"/>
            <pe:commandPaletteItem group="View" value="zoomOut" label="Zoom Out"/>
            <pe:commandPaletteItem group="View" value="fullscreen" label="Fullscreen"/>
        </pe:commandPalette>
    </h:form>
</div>

<div class="card">
    <h5>Selection Event</h5>
    <p>Using the <i>select</i> AJAX event to handle item selection on the server side.</p>
    <h:form id="formSelectionEvent">
        <p:messages id="messages" showSummary="true" showDetail="true"/>
        <h:panelGroup id="paletteTarget" layout="block" styleClass="palette-target">
            Right-click here to select a Node action
        </h:panelGroup>
        <pe:commandPalette id="palette2" for="paletteTarget"
                           label="Nodes" filterPlaceholder="Search nodes..." width="260">
            <pe:commandPaletteItem group="Node1" value="1" label="Create Node1 Action1"
                                   itemTitle="Creates a new Node1 action"/>
            <pe:commandPaletteItem group="Node1" value="2" label="Create Node1 Action2"
                                   itemTitle="Creates another Node1 action"/>
            <pe:commandPaletteItem group="Node2" value="3" label="Create Node2 Action1"
                                   itemTitle="Creates a new Node2 action"/>
            <pe:commandPaletteItem group="Node2" value="4" label="Create Node2 Action2"
                                   itemTitle="Creates another Node2 action"/>
            <p:ajax event="select" listener="#{commandPaletteController.onItemSelect}"
                    update="messages"/>
        </pe:commandPalette>
    </h:form>
</div>

<div class="card">
    <h5>Hotkey Trigger</h5>
    <p>Trigger the CommandPalette via a keyboard shortcut using <code>p:hotkey</code> (<kbd>Ctrl+Shift+K</kbd>). The palette also remains available via right-click on the target element.</p>
    <h:form id="formHotkey">
        <p:messages id="messages" showSummary="true" showDetail="true"/>
        <h:panelGroup id="hotkeyTarget" layout="block" styleClass="palette-target">
            Right-click or press <kbd>Ctrl+Shift+K</kbd> to open the CommandPalette
        </h:panelGroup>
        <p:hotkey bind="ctrl+shift+k" handler="PF('hotkeyPaletteWidget').showCentered();"/>
        <pe:commandPalette id="hotkeyPalette" for="hotkeyTarget"
                           label="Actions" filterPlaceholder="Search actions..." width="260" height="350"
                           widgetVar="hotkeyPaletteWidget">
            <pe:commandPaletteItem group="File" value="new" label="New File"/>
            <pe:commandPaletteItem group="File" value="open" label="Open File"/>
            <pe:commandPaletteItem group="File" value="save" label="Save"/>
            <pe:commandPaletteItem group="File" value="saveAs" label="Save As..."/>
            <pe:commandPaletteItem group="Edit" value="undo" label="Undo"/>
            <pe:commandPaletteItem group="Edit" value="redo" label="Redo"/>
            <pe:commandPaletteItem group="Edit" value="cut" label="Cut"/>
            <pe:commandPaletteItem group="Edit" value="copy" label="Copy"/>
            <pe:commandPaletteItem group="Edit" value="paste" label="Paste"/>
            <pe:commandPaletteItem group="View" value="zoomIn" label="Zoom In"/>
            <pe:commandPaletteItem group="View" value="zoomOut" label="Zoom Out"/>
            <pe:commandPaletteItem group="View" value="fullscreen" label="Fullscreen"/>
            <p:ajax event="select" listener="#{commandPaletteController.onItemSelect}"
                    update="messages"/>
        </pe:commandPalette>
    </h:form>
</div>