仕組み
The root covers its positioned container with position: absolute and inset: 0 and passes pointer events through, so it adds nothing to the layout. Opening fades in a scrim of the surface colour at 64% over a constant 10px backdrop blur (only opacity animates), turns the + by 135° into ×, and raises the actions: each starts 18px plus 10px per row lower at 55% size and transparent, and springs into place over 520ms, the nearest to the button first, 45ms apart. Hover or focus lifts a row onto a white pill with the card shadow. Closing reverses the order, farthest first, in 180ms ease-in.
向いている場面
- The few things people start most often from one screen: send, request, add, scan.
- Mobile screens and compact panels where a toolbar would crowd the content.
- Creation shortcuts in a dashboard card or a map view.
向かない場面
- More than five or six actions: use a menu or a page.
- The one primary action of a page: show it as a button.
- Actions that need explaining before they run: use a dialog.
使い方
import { QuickActions } from './QuickActions.jsx'
const actions = [
{ id: 'send', label: 'Send', icon: <SendIcon />, tone: 1 },
{ id: 'request', label: 'Request', icon: <RequestIcon />, tone: 3 },
{ id: 'topup', label: 'Top up', icon: <CardIcon />, tone: 6 },
]
export function WalletScreen({ navigate }) {
return (
// The container is the positioned, rounded box the scrim covers
<section style={{ position: 'relative', overflow: 'hidden', borderRadius: 28 }}>
<Balance />
<RecentActivity />
<QuickActions actions={actions} onSelect={(id) => navigate(`/wallet/${id}`)} />
</section>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
actions | { id, label, icon, tone?, description? }[] | — | The actions, top to bottom. icon is a 20px element shown in a 40px square tinted with chart colour tone (1–8); description adds a second, quieter line. |
onSelect | (id) => void | — | Called with the chosen action's id; the menu then closes and focus returns to the button. |
open / defaultOpen / onOpenChange | boolean / boolean / (open) => void | - / false / - | Controlled or uncontrolled open state, and a callback when it changes. |
placement | 'bottom-end' | 'bottom-start' | 'bottom-end' | The corner of the container the button sits in; the actions stack above it and line up with it. |
offset | number | 16 | Distance in px from the container's edges. |
scrim | boolean | true | Frost and dim the container behind while open; a press on it closes. |
tone | 'ink' | 'accent' | 'ink' | Colour of the round button. |
labels | object | — | Replaces built-in text: open (button and menu name), close (button name while open). Shallow-merged over the English defaults. |
...rest | HTMLAttributes | — | Other attributes go to the root <div>, which covers the container. |
アクセシビリティ
- The button has aria-haspopup, aria-expanded and aria-controls, and its name switches between labels.open and labels.close.
- The actions are a menu of menuitem buttons: opening focuses the first one, Up and Down arrows, Home and End move, Enter or Space chooses, Escape closes and returns focus to the button, Tab closes.
- While closed the menu is hidden from screen readers and cannot be focused.
- Icons are decorative; each action is named by its label text.
- Rows are at least 48px tall (52px on touch screens) and the button is 52px.
- Reduced motion fades the scrim and the actions in place without travel or stagger.
モーション
Open: scrim opacity 360ms ease-out; + turns 135° with a spring over 360ms; actions spring up over 520ms with a slight overshoot, nearest first, 45ms apart. Close: actions 180ms ease-in, farthest first, 22ms apart; scrim 240ms ease-in after 60ms.
プロジェクトに追加
Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。
QuickActions.jsxquick-actions.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。



