Peek

Pro

Open the detail of something without leaving where you are. It shows beside the chat, floating over it or full screen, and the switch in its header moves it between the three: the surface reshapes from one place to the next and what you were doing stays put.

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 peek

Usage#

Put Peek anywhere inside the Split View, next to whatever opens it. It owns where the detail shows; you own whether it is open and what it says.

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 { Peek, PeekBody, PeekClose, PeekContent, PeekHeader, PeekTitle, PeekViewSwitch } from "@/components/ui/peek"<Peek>  <PeekContent>    <PeekHeader>      <PeekClose />      <PeekTitle />      <PeekViewSwitch />    </PeekHeader>    <PeekBody />  </PeekContent></Peek>

Beside the chat, in the Split View pane. The conversation narrows and stays readable; below 40rem the pane slides over it.

Full screen#

For reading or editing at full size. It sits 8px inside the window on desktop and fills a phone screen.

Two views#

Pass two views and the switch becomes one button that moves the detail to the other. Email Draft edits the email in a Peek with all three.

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

API reference#

Peek

Holds whether the detail is open and where it shows. Renders nothing itself. Inside a SplitView the sidebar view uses its pane; outside one, sidebar is dropped from the views.

PropTypeDefaultDescription
openboolean-Controlled. Whether the detail is showing.
defaultOpenbooleanfalseInitial state when uncontrolled.
onOpenChange(open: boolean) => void-Called on close, Escape and a click outside the floating view.
view"sidebar" | "floating" | "fullscreen"-Controlled. Where the detail shows.
defaultView"sidebar" | "floating" | "fullscreen""floating"Where it opens when uncontrolled.
onViewChange(view: PeekView) => void-Called when the view switch moves it.
viewsPeekView[]["sidebar", "floating", "fullscreen"]The views it may use. Two give a single toggle button, three give a menu.
size"md" | "lg" | "xl""lg"Width of the floating view.

PeekContent

The surface. It lands in the Split View pane, in a floating dialog or in a full screen one, and reshapes from one to the next. Content remounts between the sidebar and the dialog views, so keep state above it. Forwards native <section> props.

PropTypeDefaultDescription
aria-labelstring-Names the surface.
onEscapeKeyDown(event) => void-Escape in any view. Call preventDefault() to keep it open.
onOpenAutoFocus(event: Event) => void-Dialog views only. Prevent it to place focus yourself.
onCloseAutoFocus(event: Event) => void-Dialog views only. Prevent it to return focus yourself.
Data attributeDescription
data-viewsidebar, floating or fullscreen.
data-openPresent while it is showing.

PeekHeader

The 44px bar on top, with a hairline under it. Forwards native <header> props.

PeekTitle

The title. In a dialog view it is the dialog's accessible name. Forwards native <h2> props.

PeekClose

Back arrow in the sidebar, an X in the dialog views. Closes unless its onClick prevents it.

PropTypeDefaultDescription
labelstring | ((view) => string)"Back" / "Close"Accessible name and tooltip.

PeekViewSwitch

Moves the detail to another view: a toggle when there are two, a menu with Sidebar, Floating and Full screen when there are three. Focus follows it to the new surface.

PeekBody

The scrolling area under the header. Forwards native <div> props.

usePeek

Returns { open, view, views, switched, setOpen, setView }. switched is true when the current view was reached with the switch.

FAQ#

Each answers a different moment. Floating is a quick look that keeps the chat behind it. Sidebar keeps both readable while you work. Full screen is for reading or editing at size. The person picks; you only pick where it starts.