Peek
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#
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.
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>Sidebar#
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.
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.
| Prop | Type | Default | Description |
|---|---|---|---|
| open | boolean | - | Controlled. Whether the detail is showing. |
| defaultOpen | boolean | false | Initial 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. |
| views | PeekView[] | ["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.
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-label | string | - | 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 attribute | Description |
|---|---|
| data-view | sidebar, floating or fullscreen. |
| data-open | Present 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| label | string | ((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.