Skip to content
Sign upPro
ShellMobile shellMenu

Mobile shell (Pro)

ProIncluded in $99

The phone shell for a chat app: swipe the chat aside for the sidebar, on a spring that carries the flick, with safe areas handled.

ProSwipe the chat to the right, or tap the menu, for the sidebar. Flick it back or tap the chat to close.

Installation

$ pnpm dlx shadcn@latest add @chatcn-pro/mobile-shell

Needs chatcn Pro

This command works with a Pro license, along with every Pro component.

Or start free: sign up and get three Pro components on us, with a new one every month.

Usage

tsx
import { MobileShell, MobileShellTrigger } from "@/components/ui/chatcn/pro/mobile-shell"

<MobileShell sidebar={<ChatList />}>
  <ChatScreen header={<MobileShellTrigger />} />
</MobileShell>

Swipe the chat toward the end side and it slides over to show the sidebar underneath, which eases out a little behind it; the chat dims, goes inert and closes on a tap. The swipe follows the finger, resists past fully open, and on release carries its velocity into a critically damped spring that a new touch can catch. Only a clearly sideways move starts it, and a swipe toward the start on the closed shell is left to the chat, so swipe-actions rows keep working; swipe="edge" opens only from the start edge. MobileShellTrigger is the menu button for everyone not swiping, Escape closes, focus moves into the sidebar on open and back to the trigger on close. Safe areas come from the phone frame's --chatcn-safe-* or env(safe-area-inset-*). Mirrored in right to left layouts. useMobileShell reads and sets the open state from your own controls.

Examples

States

ProOpen at real phone width, with swiping from the edge only.

Props

PropTypeNotes
sidebarReactNodeWhat slides in from the start side
open, defaultOpen, onOpenChangebooleanControlled or not
widthnumberSidebar width as a fraction of the screen. Default 0.84
swipe"anywhere" | "edge"Where an opening swipe may start
labelsPartial<MobileShellLabels>The sidebar's name

Keyboard

KeyAction
Enter on the triggerOpen or close
EscapeClose; focus returns to the trigger

Accessibility

  • The sidebar is a labelled region that is inert while closed; the chat is inert while it is open.
  • The trigger reports whether the sidebar is expanded.

Motion

A critically damped spring, about 350 ms to rest, carrying the release velocity; the sidebar moves at 28% of the chat's speed for depth. Under reduced motion it opens and closes in place.