UIR

AccessRequest

A notification pill with stacked avatars that grows into a list. Each avatar travels from the stack to its own row, then the name and Approve / Reject buttons fade in one by one.

Preview

Preview coming soon

Try it live: run the CLI command below in an Expo app, or open the Code tab.

Installation

npx @codewithrabby/ui@latest add access-request

Usage

import { AccessRequest } from "@/components/uir/access-request";

const [people, setPeople] = useState([
  { id: "1", name: "Louis Griffen", color: "#a855f7" },
  { id: "2", name: "Peter Griffen", color: "#ef4444", image: require("./peter.jpg") },
]);
const remove = (p) => setPeople((list) => list.filter((x) => x.id !== p.id));

{people.length > 0 && (
  <AccessRequest
    people={people}
    onApprove={(p) => { approve(p.id); remove(p); }}
    onReject={remove}
    onDismiss={() => setPeople([])}
  />
)}

Props

PropTypeDefault
people

{ id, name, color, image? }. The colour shows behind the initial when there's no image.

AccessRequestPerson[]—
title

Header when open.

string"Access Request"
summary

First line when closed.

ReactNode"<first> and N others"
subtitle

Second line when closed.

string"requested access"
approveLabel

Approve button label.

string"Approve"
rejectLabel

Reject button label.

string"Reject"
onApprove

Approve pressed on a row.

(person) => void—
onReject

Reject pressed on a row.

(person) => void—
onDismiss

Shows the × button. Hide the component yourself when it's called.

() => void—
defaultOpen

Start expanded.

booleanfalse
onOpenChange

Called when the chevron is pressed.

(open: boolean) => void—
backgroundColor

Card background.

string"#141414"