「通知センター」は Pro に含まれます。解除するとプレビューが表示されます。
仕組み
A swipe only starts after 8px of mostly horizontal travel, so vertical scrolling stays native; release past 35% of the width or faster than 0.6px/ms dismisses, and a red layer with a cross fades in under the row as it travels. Dismissed rows collapse with grid-template-rows before onDismiss is called. The tab ink measures its tab and slides between tabs.
向いている場面
- Apps with activity from other people or systems: mentions, approvals, build results.
- A persistent place to catch up on what changed.
向かない場面
- Immediate feedback for the user's own action: use a toast or snackbar.
- Critical alerts that must be read: show them in the page.
使い方
import { NotificationCenter } from './NotificationCenter.jsx'
export function HeaderBell({ items, markRead, markAllRead, remove }) {
return (
<NotificationCenter
items={items} // { id, title, body?, time, group?, unread?, avatar?, kind? }[]
tabs={[
{ id: 'all', label: 'All' },
{ id: 'mentions', label: 'Mentions', filter: (i) => i.kind === 'mention' },
{ id: 'unread', label: 'Unread', filter: (i) => i.unread },
]}
onRead={markRead}
onReadAll={markAllRead}
onDismiss={remove}
/>
)
}プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
items | { id, title, body?, time, group?, unread?, avatar? }[] | — | Notifications, newest first; consecutive items with the same group share a heading. |
tabs | { id, label, filter?: (item) => boolean }[] | — | Optional tabs; each shows its unread count. |
onRead | (id) => void | — | Mark one as read (check button or Enter). |
onReadAll | () => void | — | Mark all as read. |
onDismiss | (id) => void | — | Remove one; called after its row has collapsed. |
labels | object | — | Replaces title, bell ({n}), bellNone, markAll, markRead, dismiss, unread, empty and emptyHint. |
defaultOpen | boolean | false | Open the panel on first render. |
defaultTab | string | first tab | Initially selected tab. |
emptyIcon | ReactNode | — | Replaces the all-caught-up icon. |
アクセシビリティ
- The bell's accessible name includes the unread count; it has aria-expanded and aria-controls, and the panel is a role dialog labelled by its title.
- Tabs follow the tablist pattern with Left and Right; each item is focusable, Enter marks it read and Delete dismisses it.
- Row actions appear on hover and on keyboard focus, with accessible names and 32px targets; on touch screens swiping replaces them.
- Unread is shown by a dot, a tint and a spoken label, not colour alone; the empty state is a role status message.
- Escape closes the panel and returns focus to the bell; a click outside closes it.
- With reduced motion the bell does not swing, rows disappear at once and the panel only fades.
モーション
Panel 240ms cubic-bezier(0.32, 1.2, 0.5, 1) from 0.96 scale at the bell; bell swing 700ms; badge pop 420ms spring; tab ink 280ms; row collapse 280ms; swipe snap-back 320ms ease-out.
プロジェクトに追加
Pro メンバーはプロンプトをコピーし、コーディングエージェントが無料コンポーネントと同じ手順でソースを導入します。
NotificationCenter.jsxnotification-center.csstokens.cssREADME.md
2 つのファイルを一緒に導入します。スタイルは tokens.css の変数を読み、予備の値も持つため、単体でも表示できます。



