Foundation
PackagesUIComponentsButtons

ActionButton

アクション実行用のボタンコンポーネント。variantでスタイルを切り替える。

いつ使うか

  • フォーム送信、データ保存、キャンセル、削除など、画面内のアクション実行に使用する
  • ダイアログの確定アクション(「保存」「送信」「作成」)に使用する
  • variant で視覚的な重要度を使い分ける

いつ使わないか

  • ページ遷移やナビゲーションには使わない。ActionLinkButton を使用する
  • インラインのテキストリンクには使わない。テキストリンクコンポーネントを使用する

Usage

import { ActionButton } from '@bi-shop-it/ui/action-button';

<ActionButton label="送信" />
<ActionButton label="キャンセル" variant="secondary" />
<ActionButton label="削除" variant="destructive" />

Props

Propデフォルト説明
labelstringボタンに表示するテキスト
variant'primary' | 'secondary' | 'destructive' | 'ghost' | 'outline''primary'ボタンのスタイル
iconIconNameラベルに併せて表示するアイコン名
iconPosition'start' | 'end''start'アイコンの表示位置
isLoadingbooleanfalseローディング状態。Spinnerを表示し、操作を無効化する
disabledbooleanfalseボタンを無効化する
size'sm' | 'md' | 'lg''md'ボタンのサイズ
type'button' | 'submit' | 'reset''button'HTMLのbutton type属性
onClick() => voidクリック時のコールバック

variant の使い分け

variant用途
primary画面内で最も重要なアクション。1画面に1つが原則送信、保存、作成
secondary副次的なアクション。primary と並べて使うキャンセル、戻る
destructive破壊的操作。取り消しが困難なアクション削除、解除
ghost控えめなアクション。ツールバーやテーブル行内編集、コピー
outline枠線のみのアクション。secondary より控えめフィルター、オプション

状態

Variants

<ActionButton label="送信" variant="primary" />
<ActionButton label="キャンセル" variant="secondary" />
<ActionButton label="削除" variant="destructive" />
<ActionButton label="編集" variant="ghost" />
<ActionButton label="フィルター" variant="outline" />

With Icon

icon にアイコン名を文字列で指定する。iconPosition でアイコンの位置を変更できる。

<ActionButton icon="Mail" label="メール送信" />
<ActionButton icon="ChevronRight" iconPosition="end" label="次へ" />

Loading

isLoadingtrue のとき、アイコンがSpinnerに置き換わり、ボタンが無効化される。

<ActionButton isLoading label="送信中..." />

Disabled

<ActionButton disabled label="送信" />

Size

<ActionButton label="小" size="sm" />
<ActionButton label="中" size="md" />
<ActionButton label="大" size="lg" />

アクセシビリティ

コンポーネントが内部で処理すること

  • isLoading 時に disabled 属性を自動付与し、操作を防止する
  • 装飾アイコンに aria-hidden="true" を自動付与し、スクリーンリーダーから隠す
  • ローディング中は Spinnerrole="status" でスクリーンリーダーに状態を通知する
  • type のデフォルトを 'button' に設定し、フォーム内での意図しない送信を防止する

利用者が対応すること

  • ボタンのラベルは操作内容が明確に伝わるテキストにすること(「送信」「保存」等。「クリック」は避ける)
  • フォーム送信に使う場合は type="submit" を明示すること

関連コンポーネント

  • ActionLinkButton — ページ遷移を伴うアクションに使用する。見た目はActionButtonと同じだが、リンクとして動作する

On this page