suiss/ui ยท Block
Chat Thread
A single message thread inside a phone frame, with heart reactions and simulated replies.
Chat Thread 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 single conversation in a phone frame, with a contact header, message bubbles, heart reactions and a composer. Double-clicking a bubble, or pressing Enter on it, toggles a heart. The frame appears from small tablets up while the smallest screens show the thread edge to edge, and on desktop a caption sits beside the phone. It works for showing off a chat feature on a marketing page or as the base of a one-to-one chat view.
Replace opening with your initial messages, each with an id, sender, text and an optional liked flag. The send function fakes a typing indicator and a reply from replies, so wire it to your messaging backend instead. Update the contact name and initials, and point the #contact link at a real profile.
Each bubble is a button whose label includes the message and how to toggle the heart, so reactions work from the keyboard.
Installation
Works in any project with a components.json. See Installation for the one-line registry setup. Or use the suiss/ui CLI:
Usage
Web preview
Composes Screen, Avatar, Message, Bubble with BubbleReactions, MessageScroller, Attachment, InputGroup, Button and BottomBar. Double-tapping a bubble toggles a heart, the attach button adds a sample photo preview that can be removed before sending, and each sent message gets a sample reply after a typing indicator.
Replace OPENING, REPLIES and PHOTO with your messages and attachment source. Wire onSend, onAttach, onOpenContact and onLikeChange to your messaging backend.
Installation
The CLI also adds what it builds on: Attachment, Avatar, Bottom Bar, Bubble, Button, Icon, Input Group, Message, Message Scroller, Screen, Text. It also adds the animated view components/ui/animated-view.tsx.
- Install the following dependencies:
-
Add the pieces it builds on: Attachment, Avatar, Bottom Bar, Bubble, Button, Icon, Input Group, Message, Message Scroller, Screen, Text.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/chat-thread.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Attachment, Avatar, Bottom Bar, Bubble, Button, Icon, Input Group, Message, Message Scroller, Screen, Text.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/chat-thread.tsx:
- Update the import paths to match your project setup.
- Install the following dependencies:
-
Add the pieces it builds on: Attachment, Avatar, Bottom Bar, Bubble, Button, Icon, Input Group, Message, Message Scroller, Screen, Text.
-
Copy the animated view into
components/ui/animated-view.tsx:
- Copy and paste the following code into
components/blocks/chat-thread.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.