Skip to Content
PatternsLayoutSplit View

Split View

A two-panel layout commonly used for list/detail views like email clients or file browsers. Built using Box, Row, and context for selection state.

Welcome to the appThanks for signing up...
Your weekly reportHere is your summary...
New features availableCheck out what is new...
Welcome to the appThanks for signing up! We're excited to have you here.

Source

'use client'; import { createContext, useContext, useState } from 'react'; import { Box, Row } from '@umami/react-zen'; const SplitViewContext = createContext({ selectedId: null, setSelectedId: () => {}, }); export function useSplitView() { return useContext(SplitViewContext); } export function SplitView({ defaultSelectedId = null, children, ...props }) { const [selectedId, setSelectedId] = useState(defaultSelectedId); return ( <SplitViewContext.Provider value={{ selectedId, setSelectedId }}> <Row height="100%" {...props}> {children} </Row> </SplitViewContext.Provider> ); } export function SplitViewList({ width = '20rem', children, ...props }) { return ( <Box width={width} height="100%" borderColor="muted" border="right" overflow="auto" flexShrink="0" {...props} > {children} </Box> ); } export function SplitViewItem({ id, children, ...props }) { const { selectedId, setSelectedId } = useSplitView(); const isSelected = selectedId === id; return ( <Box padding="3" borderColor="muted" border="bottom" backgroundColor={isSelected ? 'interactive' : undefined} className={`cursor-pointer ${!isSelected ? 'hover:bg-interactive' : ''}`} onClick={() => setSelectedId(id)} {...props} > {children} </Box> ); } export function SplitViewDetail({ children, emptyState, ...props }) { const { selectedId } = useSplitView(); return ( <Box flexGrow="1" height="100%" overflow="auto" {...props}> {selectedId ? children : emptyState} </Box> ); }

Variations

Email-style layout

John Doe2m ago
Project UpdateHey team, I wanted to share the latest updates on our project…
Jane Smith1h ago
Meeting NotesHere are the notes from our meeting yesterday…
System1d ago
Welcome!Thanks for joining. Here’s how to get started…
Project UpdateFrom John Doe • 2 minutes ago
Hey team, I wanted to share the latest updates on our project. We’ve made great progress this week and are on track to meet our deadline.

File browser style

Documents
Images
README.md
Documents3 items • Modified 2 days ago