Raft Design System

Components · Overlays

AnnouncementDialog

A dialog that tells people about something new in the product, with a small label, a title, an optional picture, a few lines of text and an action to try it.

ExperimentalAlso called What's new
import { AnnouncementDialog } from "@botiverse/raft-ui/wip";

An announcement dialog tells people about something new in the product once: a small label, a title, an optional picture, a few lines of text and one action that takes them to it. It is a Dialog with a fixed layout, so it has the dialog's scrim, Esc and focus handling. It is exported from @botiverse/raft-ui/wip, and its API can change in any release.

dialog/compositions/announcement

When to use

SituationUse
A new feature people should hear about once, with an action to try itAnnouncementDialog
The state of the whole server: a computer offline, a quota, an updateThe notification center (NotificationCenter)
The result of something the person just didToast
A decision people must make before they continueDialog; AlertDialog only for the confirmations a product lists
Something people must read before they act, inside a dialog or formBanner

The full choice of how to tell people something is in Choosing a component.

Anatomy

  • AnnouncementDialog: the root, the same as Dialog. Owns the open state. Required.
  • AnnouncementDialogTrigger: the button that opens it, when people open it themselves.
  • AnnouncementDialogContent: the centered surface, with the scrim behind it. Required.
  • AnnouncementDialogBody: everything above the footer. It scrolls when the content is taller than 70% of the window. Required.
    • AnnouncementDialogHeader: the row with the label and the close button.
    • AnnouncementDialogLabel: a short label in text-caption and foreground-muted, after an attention dot that is drawn for you.
    • AnnouncementDialogClose: the × icon button. It is DialogClose.
    • AnnouncementDialogTitle: the title, in text-headline. Required.
    • AnnouncementDialogPicture: a picture of the feature on fill-muted, with a hairline and radius-container. The image inside is contained, not cropped. Optional.
    • AnnouncementDialogText: the text, in text-subhead and foreground-muted. It takes paragraphs, lists and headings.
  • AnnouncementDialogFooter: the actions, with no line above it.
    • AnnouncementDialogSecondaryAction: a frameless button that dismisses the announcement, because the dialog draws its own edge (Button). Optional, and rarely needed: × already dismisses (Rules).
    • AnnouncementDialogAction: the pink action, at the end of the footer. Required.

Behavior

  • On open, focus goes to AnnouncementDialogAction instead of the close button, so Enter takes people to the feature. Pass initialFocus to change it.
  • When the dialog is narrower than 448px, the footer stacks its buttons and each one takes the full width.
  • Long titles, labels and button labels wrap instead of being cut off.
  • Esc and × close the dialog. The two actions don't close it by themselves: each calls its own handler, and the caller closes the dialog from it.

Content

  • Write the label as the kind of announcement, in sentence case: What's new.
  • Write the title as what people can now do, in sentence case: Work together across servers.
  • Make the action say where it goes, in sentence case: Create joint channel (Writing).
  • When there is nothing to try, the one action is the acknowledgment: Got it.

Accessibility

  • AnnouncementDialog is the Base UI Dialog, through Dialog. It provides the dialog role, the focus trap, Esc and focus return.
  • AnnouncementDialogTitle names the dialog. Every announcement needs one.
  • Give AnnouncementDialogClose an aria-label that says what it closes: Close update.
  • The attention dot in the label is hidden from assistive technology.
  • Give the picture a text alternative, or hide it when the text already says the same thing.

Rules

  • Use exactly one AnnouncementDialogAction. It is the screen's one pink button (Button).
  • With an action that takes people to the feature, show it alone: no Got it beside it. × already dismisses the announcement, so a Got it there would be a second button that does what × does.
  • With nothing to try, keep the pink action as Got it, and keep ×. The dialog still has one clear button to end on, even when all it does is close.
  • Don't put a form in it. When the feature needs input, open its form from the action.

API

AnnouncementDialogContent

Experimental
PropTypeDefault
layer0 | 1
overlayfalse | DialogOverlayProps
placementWhere the card sits in the window. `"center"` (the default): in the middle. `"top"`: centred across, its top edge at `var(--dialog-top, 8vh)`, and never taller than the window less that top and 16px, so it never runs past the window's bottom; its width is still `size`'s. To anchor the card to something on the page (search under the top bar's field), measure it and set `--dialog-top` in `style`. Desktop and tablet only: below 768px every centred dialog sits in the middle and moves up only while the on-screen keyboard is open (dialog.md, "On a phone")."center" | "top"
portalPropsAlertDialogPortalProps
size"sm" | "md" | "lg" | "wide"
finalFocusDetermines the element to focus when the dialog is closed.boolean | RefObject<HTMLElement | null> | ((closeType: InteractionType) => boolean | HTMLElement | null | void)
initialFocusDetermines the element to focus when the dialog is opened. By default, focus moves to the first tabbable element inside the popup, except when the dialog is opened by touch — then the popup itself is focused to avoid opening the virtual keyboard.boolean | RefObject<HTMLElement | null> | ((openType: InteractionType) => boolean | HTMLElement | null | void)
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.

AnnouncementDialogBody

Experimental
PropTypeDefault
actionsRefMethods to scroll from code that the container doesn't have natively.((instance: ScrollAreaActions | null) => void | (() => void | { [UNDEFINED_VOID_ONLY]: never; }) | DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES[keyof DO_NOT_USE_OR_YOU_WILL_BE_FIRED_CALLBACK_REF_RETURN_VALUES]) | RefObject<ScrollAreaActions | null>
childrenThe scrolling content, in ScrollArea's own container.ReactNode
contentClassNameClass of a content element around `children`, inside the container: put padding and the content's own layout (grid, flex, `gap`, `stack-y-*`) here, so the scrollbars stay at the edges and the gutters layer is never one of the laid-out children. Only with it, `contentStyle` or `fade` is there one.string
contentRefAn element whose size is the content's, watched for size changes (such as a hidden mirror of a textarea's text). Without it each element child of the container is watched, and children added or removed.RefObject<HTMLElement | null>
contentStyleStyle of the content element; renders it, as `contentClassName` does.CSSProperties
fadeFade the content out toward an edge that has more past it. The scrollbars don't fade.boolean
hideDelayHow long the scrollbars stay after scrolling stops, in ms. At least 100 with `trigger="scroll"`.number
onEdgeChangeCalled when the area reaches or leaves an edge, and after mounting when the content overflows.(edges: ScrollAreaEdges) => void
onScrollThe container's scroll events.UIEventHandler<HTMLDivElement>
orientationThe directions the area scrolls in. Content too wide for a vertical area is cut off.ScrollAreaOrientation
overscrollWhat a scroll that reaches the end does: stop there with no bounce (`none`, the default), stop there but let Mac trackpads and iOS bounce the area (`contain`), or carry on to the page behind (`auto`, which leaves the container's own `overscroll-behavior` alone). Only in the directions the area overflows right now.ScrollAreaOverscroll
railInsetRoom in px the scrollbars keep clear at each end, such as a sticky header's height, so they don't run over it. Also settable in CSS, on the root: `--r-scroll-area-rail-inset-{top,bottom,left,right}`, which don't inherit.ScrollAreaRailInset
renderAnother element in place of ScrollArea's own `<div>`, as the container (an element or a function that gets the props). It must hold children: the gutters are its first child.ReactElement | ((props, state) => ReactElement)
sizeThumb thickness: `small` is 5px, `medium` 7px; both grow while pointed at or dragged.ScrollAreaSize
tabIndexThe container's: by default `0` while there is something to scroll.number
triggerWhen the scrollbars show. They always show while scrolling or dragging.ScrollAreaTrigger

Also takes the attributes of its element.

AnnouncementDialogHeader, AnnouncementDialogLabel

Experimental

Takes the attributes of its element.

AnnouncementDialogTitle

Experimental
PropTypeDefault
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.

AnnouncementDialogPicture, AnnouncementDialogText, AnnouncementDialogFooter

Experimental

Takes the attributes of its element.

AnnouncementDialogAction, AnnouncementDialogSecondaryAction

Experimental
PropTypeDefault
loadingBusy: shows the spinner and blocks activation (click, Enter, Space and form submission) while keeping the button focusable. A busy button is `aria-disabled`, not natively `disabled`, so the focus a press left on it stays there and is still there when the wait ends.boolean
loadingLabelThe spinner's accessible name while `loading`: say what is happening.string
size`md` (32px) and `icon-md` for rows, cards, banners, toolbars and panel headers; `lg` and `icon-lg` (the control height) for dialog footers, forms and beside a field; `xl` for a full-width call to action; `icon-sm` (28px, a 44px hit area) for an icon-only action on a line of a row or a card, such as a comment header's More, never in a toolbar. The size follows the place: see Button › Size by place."md" | "lg" | "xl" | "icon-sm" | "icon-md" | "icon-lg" | DeprecatedButtonSize
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.

Changes

  • 0.73.0 · ChangedEvery region that scrolls is a ScrollArea: PanelScrollViewport, ActivityInboxViewport, SearchShellViewport, NotificationCenterScroller, FilesViewport, TasksPanelViewport, ChoiceList's scroller, MobileNavServerPopoverList, ComposerSuggestionList, AnnouncementDialogBody, MessageActionCardScopeListViewport and DialogNav show ScrollArea's overlay scrollbar instead of the platform's. Native scrolling stays only in the places scroll-area.md lists, each with its reason, and a test fails on any other.
  • 0.8.0 · Breaking ChangesAnnouncementDialogSecondaryAction is a ghost button instead of an underlined link. Its API is unchanged, and it now looks like the frameless minor action of a dialog.