Notification
A small indicator notifying users of an unread message or event.
Usage
import { Notification } from "#/ui/components/Notification"
<Notification count={42}>
<div className="size-8 rounded-xl bg-gray-300 ring-inset ring-1 ring-gray-400/50"></div>
</Notification>
Notification acts as a wrapping component in order to position itself correctly. You can wrap any component in a Notification.
Props
Count
The only required prop is count
. This is the number of notifications you have to display.
<Notification count={50}>...</Notification>
Max
By default you’re limited to 99 notificatons, after which a + will be displayed.
<Notification count={200}>...</Notification>
You can adjust this using the max prop, which will create your new upper limit. Counts that go over the max prop will display the max prop with a +.
<Notification count={123} max={999}>
...
</Notification>
<Notification count={1000} max={999}>
...
</Notification>
Hide Plus
You can hide the plus if you prefer, while still limiting the max number displayed
<Notification count={200} hidePlus>
...
</Notification>
Hide Number
If you prefer not to show notification numbers, you can hide them.
<Notification count={200} hideNumber>
...
</Notification>
Show Zero
By default, if you have 0 notifications, nothing will be displayed. You can override this by setting showZero
to true.
<Notification count={0} showZero>
...
</Notification>
Interactivity
Notifications are not interactive. If you wish to link to a notification page or open a menu, it is recommended you pass this as a child to the Notification component.
<Notification count={50}>
<a href="#">Link</a>
</Notification>
Customization
Classes
You can customize notifications further by passing a className prop, which will override any styles already set. (this will style the notification indicator, not the wrapping container)
<Notification count={50} className="bg-indigo-500">
...
</Notification>