Updated
Read Receipts
NewCustomize
Step delay0.9s
Read colour
Radius20px
Installation
npx shadcn@latest add https://uibrik.com/r/read-receipts.jsonInstall the packages
npm install motionAdd the cn helper
Imports
cnfrom@/lib/utils, whichshadcn initcreates. Add it by hand without shadcn.Copy the source into your project
components/uibrik/read-receipts/read-receipts.tsx"use client"; import { AnimatePresence, motion, useAnimationControls, useReducedMotion } from "motion/react"; import { useEffect, useRef, useState } from "react"; import { cn } from "@/lib/utils"; const EASE_OUT: [number, number, number, number] = [0.23, 1, 0.32, 1]; export type ReceiptStatus = "sending" | "sent" | "delivered" | "read"; const ORDER: ReceiptStatus[] = ["sending", "sent", "delivered", "read"]; const LABELS: Record<ReceiptStatus, string> = { sending: "Sending", sent: "Sent", delivered: "Delivered", read: "Read", }; export type ReadReceiptsProps = { /** The message in the bubble. */ message?: string; /** Time shown beside the ticks. */ time?: string;
Adds the files to
components/uibrik/read-receipts and installs motion. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/read-receipts.Usage
import { ReadReceipts } from "@/components/uibrik/read-receipts/read-receipts";<ReadReceipts message="On my way, see you at the station." time="9:41" simulate stepDelay={0.9} readColor="#2f7cf6" showLabel radius={20} defaultStatus="sending" // status="sending" // onStatusChange="sending"/>Where to use Read Receipts
Chat and support inboxes
Each step draws itself in, so people can tell a message has landed without reading a label.
Pairs with Typing Dots and Streaming Chat
Sent email and invites
The same four states show whether an invite was delivered and opened.
Pairs with Email Composer
Order and request updates
A quiet status beside the time tells a customer their request reached the team.
Props
ReadReceipts- message
- Type string
- "On my way, see you at the station."
- The message in the bubble.
- time
- Type string
- "9:41"
- Time shown beside the ticks.
- simulate
- Type boolean
- true
- Step through sending, sent, delivered and read on its own. Click the bubble to play it again.
- stepDelay
- Type number
- 0.9
- Seconds between steps while simulating.
- readColor
- Type string
- "#2f7cf6"
- Colour of the ticks once read.
- showLabel
- Type boolean
- true
- Show the status word under the bubble.
- radius
- Type number
- 20
- Corner radius of the bubble.
- status / onStatusChange
- Type "sending" | "sent" | "delivered" | "read"
- –
- Controlled status. Simulation turns off while controlled.
- defaultStatus
- Type ReceiptStatus
- "sending"
- Status on mount when uncontrolled.
- className
- Type string
- –
- Classes for the wrapper.