Component
Split button
A primary action button paired with a dropdown toggle for alternative actions. Composes two .pl-c-button segments with a Popover API menu.
On this page
The .pl-c-split is a composite action control: a primary button (the default
action) fused with a dropdown toggle that opens a menu of alternative actions.
The canonical “Save ▼” pattern - click the label to perform the default
action, click the chevron to pick a variant.
Both segments are .pl-c-button, so every variant, state, and density tier
inherited from the button component works without extra effort. The split
button only adds the layout, the seam divider, and the Popover API menu.
Semantic HTML
<div class="pl-c-split">
<button class="pl-c-button pl-c-split__primary" data-variant="primary">
Save
</button>
<button
class="pl-c-button pl-c-split__toggle"
data-variant="primary"
popovertarget="sb-1"
aria-label="More save options"
>
<svg class="pl-c-split__chevron" viewBox="0 0 24 24" ...>
<path d="m6 9 6 6 6-6" />
</svg>
</button>
<div popover class="pl-c-split__menu" id="sb-1">
<button class="pl-c-split__option">Save as PDF</button>
<button class="pl-c-split__option">Save as draft</button>
<hr class="pl-c-split__divider" />
<button class="pl-c-split__option" data-tone="danger">
Discard changes
</button>
</div>
</div>
Class contract
| Selector | Role |
|---|---|
.pl-c-split |
Flex container that fuses the two segments. |
.pl-c-split__primary |
The primary .pl-c-button (default action). Trailing radius set to 0. |
.pl-c-split__toggle |
The dropdown .pl-c-button (opens the menu). Leading radius set to 0. |
.pl-c-split__chevron |
Arrow icon inside the toggle (rotates 180° when open). |
.pl-c-split__menu |
The popover menu (anchored to the toggle). |
.pl-c-split__option |
A menu item (button or link). |
.pl-c-split__divider |
Optional divider between menu groups. |
[data-tone="danger"] |
Destructive item (discard, delete). |
Both buttons must carry the same data-variant so the fill, text, and
border match across the seam.
For selected CSS imports, load core.css, components/button.css, then
components/split-button.css. The split-button segments require the button
component’s base and variant rules. porchlight copy --components split-button
includes button.css automatically. The divider is styled by split-button.css;
older markup using .pl-c-menu__divider inside a split button still works
without importing popover-menu.css.
Repeated split buttons
Each menu needs a unique HTML id and matching popovertarget. The browser
anchors it to its own toggle, so server-rendered lists and HTMX fragments need
no per-instance CSS anchor names:
<div class="pl-c-split">
<button class="pl-c-button pl-c-split__primary" data-variant="primary">
Approve
</button>
<button
class="pl-c-button pl-c-split__toggle"
data-variant="primary"
popovertarget="request-actions-42-menu"
aria-label="More request actions"
>
<svg class="pl-c-split__chevron" viewBox="0 0 24 24">...</svg>
</button>
<div popover class="pl-c-split__menu" id="request-actions-42-menu">...</div>
</div>
For HTMX/server-rendered lists, a stable row/request id is a good suffix for
the HTML id. If the menu must use a different named anchor, set
--pl-c-split-anchor on its root as an explicit override. Programmatic opens
should call showPopover({ source: toggle }).
Tokens exposed (component-local)
| Token | Default | Purpose |
|---|---|---|
--pl-c-split-anchor |
implicit trigger | Optional explicit CSS anchor name. |
--pl-c-split-min-inline |
10rem |
Minimum menu width. |
--pl-c-split-max-block |
20rem |
Maximum menu height (scrolls if exceeded). |
--pl-c-split-divider |
--pl-color-border |
Divider color between segments (per-variant override). |
Accessibility
- Keyboard: both segments are native
<button>elements - Enter/Space activates them. The toggle usespopovertargetfor zero-JS menu open. Menu items are buttons/links, so Tab/Shift+Tab navigates within the popover. - Toggle label: the toggle must carry an
aria-labeldescribing what the menu contains (e.g."More save options"), since the icon alone is ambiguous. - Focus-visible: both segments inherit the base-layer focus outline; the primary variant also gets an accent glow.
- Disabled: set
disabledon both segments to disable the entire control. - Forced colors: falls back to
ButtonBorder/Highlight.
Theme, density, RTL, motion
- Light/dark: segment fills resolve via
light-dark(). The divider on filled variants uses a semi-transparent white rule (oklch(100% 0 0deg / 20%)) so it reads on both accent and dark fills. - Density: both segments inherit
--pl-control-block-size; set[data-pl-density]on an ancestor - no per-component work. - RTL: the flex container follows the writing mode; the divider and radius
squaring flip automatically via logical properties (
border-inline-start). - Reduced motion: the chevron rotation and menu transitions are zeroed by
the themes layer’s motion guard (
--pl-motion-scale: 0).