Ir al contenido
Español
Centro de notificaciones viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

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.

Úsalo para

  • Apps with activity from other people or systems: mentions, approvals, build results.
  • A persistent place to catch up on what changed.

Busca otra opción cuando

  • Immediate feedback for the user's own action: use a toast or snackbar.
  • Critical alerts that must be read: show them in the page.

Uso

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}
    />
  )
}

Propiedades

PropiedadTipoPor defectoQué hace
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.
labelsobject—Replaces title, bell ({n}), bellNone, markAll, markRead, dismiss, unread, empty and emptyHint.
defaultOpenbooleanfalseOpen the panel on first render.
defaultTabstringfirst tabInitially selected tab.
emptyIconReactNode—Replaces the all-caught-up icon.

Accesibilidad

  • 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.

Movimiento

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.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

NotificationCenter.jsxnotification-center.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Avisos
Lluvia de confeti viene con Pro. La vista previa aparece al desbloquearlo.