Raft 设计系统

组件 · 收件箱

NotificationCenter

The list that opens from the bell and holds the state of the whole server — a computer offline, a quota nearly full, an update — until it changes.

稳定也叫 Notifications
import { NotificationCenter } from "@botiverse/raft-ui";
本页尚未翻译
译文完成之前,这里显示英文原文。 阅读英文版

The NotificationCenter is the list that opens from the bell. It holds the state of the whole server (a computer offline, a quota nearly full, an update) and keeps each notice until the situation changes. An attention dot on the bell says that something is unread.

When to use

SituationUse
A problem or a change that affects the whole serverNotificationCenter
Something happened elsewhere that the person should seeActivity (ActivityInbox)
Something in one panel failedPanelNotice under the panel header (Panel)
The result of an action the person tookToast

Errors by scope are in Feedback. Where a product puts the bell is on the product's own page.

Anatomy

  • NotificationCenter: the root. A non-modal popover.
  • NotificationCenterTrigger: the bell. By default it draws the bell and the attention dot.
  • NotificationCenterPopup: the list's popup, next to the bell.
    • NotificationCenterHeader: NotificationCenterTitle (Notifications) and NotificationCenterCount.
    • NotificationCenterScroller and NotificationCenterList: the notices.
    • NotificationCenterEmptyState: what the list says when it is empty (EmptyState).
  • NotificationCenterItem: one notice, in a NotificationCenterItemRow:
    • NotificationCenterItemIcon: a tile with an icon. A notice from the system has no who, so a tile stands where an avatar would (InboxItem).
    • NotificationCenterItemContent: NotificationCenterItemTitle, NotificationCenterItemBody and NotificationCenterItemActions with NotificationCenterActionButtons.

Variants

VariantUse for
status="error" on the iconSomething stopped working: a computer offline, an agent that can't start. warning-soft tile, octagon-alert icon
status="warning"Something will stop working soon: a quota nearly full, a key about to expire. warning-soft tile, triangle-alert icon
status="info"News: an update. info-soft tile, info icon
viewport="mobile" on the popupThe narrower popup on a phone
size on the popupThe popup's height: sm, md or lg

States

StateLook
Unread (default)The title in foreground at weight 700, and a pink attention dot on the right
readThe title in foreground-muted at weight 600; no dot

Behavior

  • Sort notices by severity: errors first, then warnings, then information.
  • When the person dismisses a notice, don't show it again until the situation changes.
  • Show the attention dot on the bell only while a notice is unread. The default trigger always draws the dot, so pass the bell alone as the trigger's children when nothing is unread.
  • Float the popup next to the bell; it doesn't take space in the layout (Elevation).

Content

  • Write the notice in the same order as an inbox item: where (the computer, the server), then what happened, then at most 2 lines of detail (InboxItem).

Accessibility

  • NotificationCenter wraps the Base UI Popover, non-modal by default; the popup doesn't take focus when it opens.
  • The popup is named "Notification center" and the list "Notifications" unless you pass another aria-label.
  • Give the trigger an accessible name, and include the unread state: aria-label="Notifications, 2 unread". The bell and the dot are hidden from assistive technology.
  • NotificationCenterItemIcon is an image (role="img") named by its status (Error, Warning, Info).

Rules

  • Make the actions in a notice ink-outline small buttons, never pink; NotificationCenterActionButton does this (InboxItem).
  • Use orange tiles for errors and warnings, not red (Color).

API

NotificationCenter

Prop类型默认值
actionsRefA ref to imperative actions. - `unmount`: Manually unmounts the popover. Call this after any externally controlled closing animation finishes. - `close`: Closes the popover imperatively when called.RefObject<PopoverRootActions | null>
childrenThe content of the popover. This can be a regular React node or a render function that receives the `payload` of the active trigger.ReactNode | PayloadChildRenderFunction<unknown>
defaultOpenWhether the popover is initially open.booleanfalse
defaultTriggerIdID of the trigger that the popover is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open popover.string
handleA handle to associate the popover with a trigger. If specified, allows external triggers to control the popover's open state.BasePopover.Handle<unknown>
modalDetermines if the popover enters a modal state when open. - `true`: user interaction is limited to the popover: document page scroll is locked, and pointer interactions on outside elements are disabled. - `false`: user interaction with the rest of the document is allowed. - `'trap-focus'`: focus is trapped inside the popover, but document page scroll is not locked and pointer interactions outside of it remain enabled.boolean | "trap-focus"false
onOpenChangeEvent handler called when the popover is opened or closed.(open: boolean, eventDetails: BasePopover.Root.ChangeEventDetails) => void
onOpenChangeCompleteEvent handler called after any animations complete when the popover is opened or closed.(open: boolean) => void
openWhether the popover is currently open.boolean
triggerIdID of the trigger that the popover is associated with. This is useful in conjunction with the `open` prop to create a controlled popover. There's no need to specify this prop when the popover is uncontrolled (that is, when the `open` prop is not set).string

NotificationCenterActionButton

Prop类型默认值
loadingboolean
loadingLabelstring
focusableWhenDisabledWhether the button should be focusable when disabled.booleanfalse
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`).booleantrue
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

NotificationCenterCount, NotificationCenterEmptyState, NotificationCenterHeader

Prop类型默认值
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

NotificationCenterItem

Prop类型默认值
readbooleanfalse
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

NotificationCenterItemActions, NotificationCenterItemBody, NotificationCenterItemContent

Prop类型默认值
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

NotificationCenterItemIcon

Prop类型默认值
status"warning" | "success" | "error" | "info""info"
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

NotificationCenterItemRow, NotificationCenterItemTitle, NotificationCenterList

Prop类型默认值
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

NotificationCenterPopup

Prop类型默认值
portalPropsPopoverPortalProps
size"sm" | "md" | "lg""md"
viewport"desktop" | "mobile""desktop"
alignHow to align the popup relative to the specified side.Align"center"
alignOffsetAdditional offset along the alignment axis in pixels. Also accepts a function that returns the offset to read the dimensions of the anchor and positioner elements, along with its side and alignment.number | OffsetFunction0
anchorAn element to position the popup against. By default, the popup will be positioned against the trigger.Element | VirtualElement | RefObject<Element | null> | (() => Element | VirtualElement | null)
arrowPaddingMinimum distance to maintain between the arrow and the edges of the popup.number5
collisionAvoidanceDetermines how to handle collisions when positioning the popup.CollisionAvoidance
collisionBoundaryAn element or a rectangle that delimits the area that the popup is confined to.Boundary'clipping-ancestors'
collisionPaddingAdditional space to maintain from the edge of the collision boundary.Padding5
disableAnchorTrackingWhether to disable the popup from tracking any layout shift of its positioning anchor.booleanfalse
finalFocusDetermines the element to focus when the popover is closed.boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => void | boolean | HTMLElement | null)
initialFocusDetermines the element to focus when the popover is opened. By default, focus moves to the first tabbable element inside the popup, except when the popover is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard.boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => void | boolean | HTMLElement | null)false
positionMethodDetermines which CSS `position` property to use."fixed" | "absolute""fixed"
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)
sideWhich side of the anchor element to align the popup against. May automatically change to avoid collisions.Side"bottom"
sideOffsetDistance between the anchor and the popup in pixels. Also accepts a function that returns the distance to read the dimensions of the anchor and positioner elements, along with its side and alignment.number | OffsetFunction4
stickyWhether to maintain the popup in the viewport after the anchor element was scrolled out of view.booleanfalse

Also takes the attributes of its element.

NotificationCenterScroller, NotificationCenterTitle

Prop类型默认值
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

NotificationCenterTrigger

Prop类型默认值
closeDelayHow long to wait before closing the popover that was opened on hover. Specified in milliseconds.number0
delayHow long to wait before the popover may be opened on hover. Specified in milliseconds.number300
handleA handle to associate the trigger with a popover.BasePopover.Handle<unknown>
nativeButtonWhether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (e.g. `<div>`).booleantrue
openOnHoverWhether the popover should also open when the trigger is hovered.booleanfalse
payloadA payload to pass to the popover when it is opened.{}
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

改动

  • 0.7.0 · FixedEmptyStateIcon is hidden from assistive technology, and NotificationCenterItemIcon is announced as an image named by its status.
  • 0.6.0 · Breaking ChangesProps that no longer change anything are removed: Badge uppercase; Checkbox size, variant, color; Status pulse, attention (status never animates); Switch / SwitchThumb size; SidebarItem variant; SidebarItemCount / SidebarItemIndicator variant and appearance (the count is always the pink sticker, the indicator the yellow @); NotificationCenterActionButton variant; DrawerContent width (one-go forms use the wide Dialog); AppRailItemIndicator attention; AppRailItemAttention children; Steps size, track, renderIndicator, renderTraveler; FilePreviewBadge type, color. Remove them at call sites.