Skip to the page
Supply UI

Notification

A part of Notifications: use it inside one.

One notification. children is the sentence under the title.

Preview

Use

The code of the preview above
import { useState } from 'react';
import {
  Button,
  Count,
  Notification,
  Notifications,
  PatternAvatar,
  Popover,
  PopoverContent,
  PopoverTrigger,
} from '@/components/ui';
import { Bell, Star } from 'lucide-react';

function NotificationsDemo() {
  const [read, setRead] = useState(false);
  return (
    <Popover>
      <PopoverTrigger render={<Button icon aria-label={read ? 'Notifications' : 'Notifications, 2 not read'} />}>
        <Bell />
        {read ? null : <Count>2</Count>}
      </PopoverTrigger>
      <PopoverContent className="ui-notifications-panel" aria-label="Notifications">
        <div className="ui-notifications-head">
          <span className="ui-notifications-title">Notifications</span>
          <Button variant="link" className="ui-small" onClick={() => setRead(true)}>Mark all as read</Button>
        </div>
        <Notifications>
          <Notification unread={!read} media={<PatternAvatar name="Noor Haddad" />} title="Noor Haddad booked a haircut" time="2 min ago">
            Friday 27 November at 09:30
          </Notification>
          <Notification unread={!read} media={<PatternAvatar name="Otis Brandt" />} title="Otis Brandt paid invoice 0412" time="1 hour ago" />
          <Notification media={<span className="ui-icon-tile ui-icon-tile--round"><Star /></span>} title="A new review: five stars" time="Yesterday">
            "Quiet room, and the tea was lovely."
          </Notification>
        </Notifications>
      </PopoverContent>
    </Popover>
  );
}

This page as text, for an AI

Options

OptionTypeWhat it does
title NeededReactNodeWhat happened: "New booking".
actions ReactNodeButtons under the text: "Accept", "View".
media ReactNodeIn front of the text: an <Avatar>, a <PatternAvatar> or an icon in a tile.
time ReactNodeWhen it happened: "2 min ago", "Yesterday 18:00".
unread booleanNot read yet: shows a dot.

It also takes the 280 attributes of the element or UI SDK part it draws: className, aria-label, events and the rest.

Without React

With the CSS in parts (/ui/css/), it needs these, besides the ones every page loads:

components/button.csscomponents/card.csscomponents/lists.csscomponents/icons.csscomponents/input-group.csscomponents/small-things.csscomponents/button-group-toggle.csscomponents/chip-you-can-remove.csscomponents/collapsible.csscomponents/rating.csscomponents/carousel.csscomponents/banner.csscomponents/scroll-area-ratio-divider.csscomponents/table-sorting-chosen-rows.csscomponents/tab-bar.csscomponents/checklist.csscomponents/pick-tiles.csscomponents/prose.csscomponents/burger.csscomponents/carousel-arrows.csscomponents/page-transitions.cssparts/collapsible.cssparts/rating.cssparts/carousel.cssparts/scroll-area.css

On top of the page: states, do and don’t

States. Closed, opening (fades and rises), open, closing (fades before what it changed appears: afterClose). While open, focus is inside and Escape closes it; when it closes, focus goes back to what opened it.

Do

  • Name every dialog, drawer and popover (DialogTitle, DrawerTitle, or aria-label).
  • Use AlertDialog for anything that cannot be undone, with the action named on its button ("Delete 3 files").
  • Use a Drawer on a phone for what a Popover does on a computer.

Don't

  • Don't open a dialog from a dialog; change what the open one shows instead.
  • Don't put the only way to do something in a right-click menu or a tooltip.
  • Don't use a toast for something the person must not miss: that is an Alert on the page.