本文へ移動
日本語

仕組み

Two native buttons sit inside one rounded shape, separated by a hairline seam. Each half has its own hover and press layer, so it is always clear which part will act. The chevron opens a role="menu" that grows from its corner with a short ease-out, and the chevron itself turns with a spring. Items can carry an icon, a one-line description, a shortcut hint or a danger tone.

向いている場面

  • One action is clearly the most common and a few variations of it are needed, such as Publish with Schedule and Save as draft.
  • Toolbars and footers where space allows only one button.

向かない場面

  • The actions are equally important: show them as separate buttons.
  • More than about seven actions: use a full menu or a page.

使い方

import { SplitButton } from './SplitButton.jsx'

export function PublishActions({ onPublish, onSchedule, onSaveDraft, onDiscard }) {
  return (
    <SplitButton
      label="Publish"
      menuLabel="More publish options"
      onClick={onPublish}
      items={[
        { id: 'schedule', label: 'Schedule…', description: 'Pick a date and time', onSelect: onSchedule },
        { id: 'draft', label: 'Save as draft', shortcut: '⌘D', onSelect: onSaveDraft },
        { divider: true },
        { id: 'discard', label: 'Discard changes', danger: true, onSelect: onDiscard },
      ]}
    />
  )
}

プロパティ

プロパティ型既定値説明
labelReactNode—Text of the primary action.
onClick(event) => void—Runs the primary action.
itemsArray<{ id, label, description?, icon?, shortcut?, danger?, disabled?, divider?, onSelect? }>[]Menu entries. An entry with divider: true draws a separator. shortcut is shown only, it does not bind keys.
onSelect(item) => void—Called with the chosen item, after the menu closes.
variant'primary' | 'ink' | 'secondary''primary'Colour.
size'sm' | 'md' | 'lg''md'Height 32, 40 or 44px.
align'start' | 'end''end'Which edge the menu lines up with.
side'bottom' | 'top''bottom'Opens the menu below or above, for buttons in footers.
menuLabelstring'More options'Accessible name of the chevron and the menu.
loadingbooleanfalseShows a spinner on the primary half and disables it; the menu still works.
disabledbooleanfalseDisables both halves.

アクセシビリティ

  • The primary half and the chevron are separate native buttons; the chevron has aria-haspopup="menu", aria-expanded and an accessible name from menuLabel.
  • ArrowDown or ArrowUp on the chevron opens the menu on the first or last item; in the menu, arrows wrap, Home and End jump, typing a letter jumps to a matching item.
  • Enter or Space chooses; Escape closes and returns focus to the chevron; Tab or clicking outside closes.
  • Items use role="menuitem" with roving tabindex; disabled items are skipped and carry aria-disabled.
  • Reduced motion replaces the menu's scale with a fade and stops the chevron turning.

モーション

The menu fades in and grows from 96% over 240ms ease-out, from the chevron's corner. The chevron turns 180° in 240ms with a slight spring overshoot.

プロジェクトに追加

プロンプトを Codex または Claude Code に貼り付けます。エージェントが公開ソースを読み、書き込む内容を示したうえで、既存のコンポーネントの隣に追加します。

SplitButton.jsxsplit-button.csstokens.cssREADME.md

2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。

ボタン
「オーロラ縁ボタン」は Pro に含まれます。解除するとプレビューが表示されます。
「かじりボタン」は Pro に含まれます。解除するとプレビューが表示されます。