suiss/ui ยท Block
Inbox Categories
A mail inbox sorted into Primary, Transactions, Updates, and Promotions, with a message reader and inline reply.
Inbox Categories is an open-source block from suiss/ui for React, React Native, SwiftUI and Jetpack Compose. The @esuiss/ui CLI copies its source into your project, so you own the code.
A mail inbox that sorts messages into Primary, Transactions, Updates and Promotions, switched with icon chips that show a dot when they hold unread mail. Selecting a message opens a reader with reply, star, archive and delete actions and an inline reply box. On mobile the list and reader show one at a time with a back button. Use it for notification centers, categorized inboxes or any feed that needs tabs.
Replace initialMail with your messages, each with a sender, subject, body, time, avatar hue, category and unread and starred flags; categories sets each chip's icon and tint. Archive and Delete both just remove the message, and the reply form only clears on submit, so connect them to your mail API. The To: Jamie Rivera recipient line is hard-coded.
The reply box receives focus when it opens, and unread dots include hidden Unread text for screen readers.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
- Install the following dependencies:
-
Add the pieces it builds on: Avatar, Button, Split View, Textarea, Toggle Group.
-
Copy and paste the following code into your project.
- Update the import paths to match your project setup.
Usage
Web preview
A mail screen built on SplitView: the list column shows a ToggleGroup of four categories with unread dots, and rows with an Avatar, sender and preview; the detail column shows the selected message. On wide screens the list and reader sit side by side; on phones the reader opens as its own column. Swipe a row with SwipeActions to archive it, or swipe fully to delete. The reader has Reply, Star, Archive and Delete buttons, and Reply opens a Textarea to write a response.
Replace INITIAL_MAIL with your messages and adjust CATEGORIES if you sort mail differently. Wire onCategoryChange, onReply, onStarChange, onArchive and onDelete to your mail service; the screen updates its own state either way.
Installation
The CLI also adds what it builds on: Avatar, Button, Icon, Screen, Split View, Swipe Actions, Text, Textarea, Toggle Group. It also adds the animated view components/ui/animated-view.tsx.
- Install the following dependencies:
-
Add the pieces it builds on: Avatar, Button, Icon, Screen, Split View, Swipe Actions, Text, Textarea, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/inbox-categories.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Avatar, Button, Icon, Screen, Split View, Swipe Actions, Text, Textarea, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/inbox-categories.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Avatar, Button, Icon, Screen, Split View, Swipe Actions, Text, Textarea, Toggle Group.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/inbox-categories.tsx:
- Update the import paths to match your project setup.
-
Target iOS 17 or later.
-
Add the Swift package to your app:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Add the files to your app target.
- Apply the Compose compiler plugin, enable Compose, set
compileSdkto 37 or higher andminSdkto 24 or higher, and add the dependencies:
- Copy the theme files every view uses:
- Copy the source and every file it uses:
- Update the
com.esuiss.uipackage names to match your project.