Searching Puzzle Pieces

Type to search Puzzle Pieces.

Split Button

A primary action fused to a caret that opens a menu of secondary actions — the classic "Save ▾" pattern. It is a compound family whose menu half is a Dropdown Menu, so the keyboard model, the dismissal and the ARIA all come from the web component underneath rather than from 250 lines of ported machinery.

The two halves stay cleanly separated: pressing the primary fires @press and never opens anything, and choosing a row fires @select on the menu half.

More save actions

Last event: nothing yet

Installation

Copy the family into your app. It pulls dropdown-menu — whose rows it re-exports — and the shared dropdown-panel base along with it:

puzzle add piece split-button

That base has a runtime dependency — the web component it wraps. Menu mode is 2.1.0's, so the range matters:

npm install @magic-spells/dropdown-panel

Then merge its stylesheets into your app's style entry. The first is required; the second adds the entrance effects:

/* app/styles/styles.css */
@import "tailwindcss";
@import "@magic-spells/dropdown-panel/css" layer(components);         /* required */
@import "@magic-spells/dropdown-panel/css/effects" layer(components); /* optional */

Requires the pieces.css tokens merged into your app styles (see Introduction).

Usage

import SplitButton from '@/components/ui/SplitButton';
<SplitButton>
  <SplitButton.Action variant="primary" size="md" @press={ save }>
    Save
  </SplitButton.Action>

  <SplitButton.Menu variant="primary" size="md" label="More save actions" @select={ run }>
    <SplitButton.Item value="save-as" @press={ run }>Save as…</SplitButton.Item>
    <SplitButton.Separator />
    <SplitButton.Item value="discard" variant="danger" @press={ run }>Discard</SplitButton.Item>
  </SplitButton.Menu>
</SplitButton>

Rows go straight inside Menu — it supplies the trigger and the panel itself, because those are the two direct children the component has to find and neither is yours to place.

Variants and sizes

More publish options
More share options
More export options
More delete options

Keyboard

The primary half is a plain button. The caret half is a menu button, and everything it does is the web component's menu mode:

TabMoves onto the primary half, then the caret. Inside an open menu it closes the menu and moves on.
Enter / SpaceOn the primary: fire @press. On the caret: open the menu and focus the first row. On a row: choose it.
ArrowDown / ArrowUpOn the closed caret: open and focus the first (or last) row. Inside the menu: move row focus, wrapping and skipping disabled rows.
Home / End · a–zFirst / last row, and typeahead by the row text.
EscapeClose the menu and return focus to the caret.

Reference

SplitButton

The layout shell: `relative inline-flex`, which fuses the halves and anchors the panel.

classMerged onto the wrapper, after the layout.

SplitButton.Action

The primary half — a real button wearing Button's recipes, rounded on the left only.

variant'primary' (default) | 'secondary' | 'outline' | 'ghost' | 'destructive'.
size'sm' | 'md' (default) | 'lg'.
disabledGreys it out and swallows the press. Disable the Menu half too.
classMerged onto the button, after the chrome.
@presspress(event) — the primary action. It never opens the menu.

SplitButton.Menu

The caret half and the menu it opens. Rows go straight inside it; it supplies its own trigger and panel.

variantMatch Action's — there is no context to share it through.
sizeMatch Action's.
labelThe caret's accessible name, default 'More actions'. Rendered as an sr-only span.
disabledGreys the caret out and blocks pointer presses; disable the whole pair to stop the keyboard.
classMerged onto the caret, after the chrome.
@show / @hideThe menu opened or closed.
@selectValue-first: select(value, event). Fires once; the menu then closes and focus returns to the caret.

Rows — Item · Link · Group · Label · Separator · Shortcut · Sub

Re-exported from the DropdownMenu family, so SplitButton.Item and DropdownMenu.Item are the same component. See the Dropdown Menu reference for their props.

valuePassed to @press and reported by the Menu half's @select.
variant'default' | 'danger'.
disabledGreys the row out and takes it out of the keyboard walk.