Split View
Open something from the chat beside it instead of on top of it. The conversation narrows, a pane takes the other half, and on a narrow screen the pane slides over. Anything in the thread can send its content to the pane.
Installation#
Usage#
Wrap the chat in a Split View and put one pane next to it. Whatever wants the pane, a report, an email being edited, an agent, renders through SplitViewPortal from wherever it lives in the thread. The pane belongs to the last thing that asked for it.
The preview is yours to explore. Its code comes with a Pro license, paid once and used in every project.
Have a license? Unlock it here
Anatomy#
import { SplitView, SplitViewMain, SplitViewPane, SplitViewPortal } from "@/components/ui/split-view"
<SplitView>
<SplitViewMain />
<SplitViewPane />
<SplitViewPortal />
</SplitView>Chat results that open here#
Email Draft uses it for editing: put the conversation in a Split View and EmailDraftEditor opens the email in the pane while the card folds to one line. Any result that you read or adjust at full size, a document, a table, a diff, the sources of an answer, can do the same with a portal.
API reference#
SplitView
The row that holds the chat and the pane, and the state they share. It is its own container: from 40rem wide the pane opens as a column beside the main area, below that it slides over it. Give it a height. Forwards native <div> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | Controlled. Whether the pane is showing. |
| defaultOpen | boolean | false | Initial state when uncontrolled. |
| onOpenChange | (open: boolean) => void | - | Called when the pane opens or closes. |
| paneWidth | string | "50cqw" | How wide the pane is when it sits beside the main area. Any CSS length; cqw is a share of the Split View itself. |
| Data attribute | Description |
|---|---|
| data-open | Present while the pane is showing. |
SplitViewMain
The main area, usually the conversation. It narrows while the pane is beside it. Forwards native <div> props.
SplitViewPane
The pane: a column with a hairline on its leading edge, inert and hidden while closed. Children render in it directly, and anything sent through SplitViewPortal lands in it too. Forwards native <div> props.
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-label | string | "Details" | Names the pane's landmark. |
| Data attribute | Description |
|---|---|
| data-state | open or closed. |
SplitViewPortal
Puts its children in the pane from anywhere inside the Split View, so a card deep in a message can own what the pane shows. While open it claims the pane and opens it; when it lets go the pane closes and the content stays until the pane has slid away. Outside a Split View it renders its children where it stands.
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | Whether this content wants the pane. |
useSplitView
Returns { open, setOpen } for the nearest Split View, or null outside one. For a close button or a toolbar toggle.
useSplitViewPortal
The hook under SplitViewPortal: pass whether you want the pane and get back the element to portal into (null while another owner has it, undefined outside a Split View).