Split View

Pro

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#

# One-time setup (tokens + lib helpers)npx koalaui-cli@latest init# Activate your Pro license (once per machine)npx koalaui-cli@latest login <key># Add this component (its dependencies come along)npx koalaui-cli@latest add split-view

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.

This example is part of Koala UI Pro

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.

PropTypeDefaultDescription
openboolean-Controlled. Whether the pane is showing.
defaultOpenbooleanfalseInitial state when uncontrolled.
onOpenChange(open: boolean) => void-Called when the pane opens or closes.
paneWidthstring"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 attributeDescription
data-openPresent 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.

PropTypeDefaultDescription
aria-labelstring"Details"Names the pane's landmark.
Data attributeDescription
data-stateopen 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.

PropTypeDefaultDescription
openboolean-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).

FAQ#

So the message that opened the pane stays in view. You read the thread and the result side by side. Below 40rem there is no room for both, so the pane slides over and its back button returns to the chat.