Document Workspace
A notes or docs workspace: an explorer, tabs, breadcrumb, toolbar, the document (edit or read), an aside for backlinks, properties and the outline, a status bar with the save state, an alert slot and Ctrl/Cmd+P quick open. Resizable, collapsible columns when its container is wide, drawers when narrow; named landmarks and toggles agents can press. Also DocumentOutline and DocumentQuickOpen.
Example
Markdown. Formatting marks stay hidden until the caret is inside formatted text. Type / for blocks. Press Escape, then Tab, to leave the editor.
Installation
lucide-reactUsage
For any notes or docs app: put a MarkdownEditor (edit) or MarkdownView (read) in document, your file tree in explorer, DocumentOutline and backlinks in aside, and DocumentQuickOpen in quickOpen: items to filter in the browser, or a PageSource as source to search notes on the server, bodies included; an item's snippet shows the passage that matched under its title, with the query's words marked. Pass the editor's ref as editorRef, extractHeadings(markdown) as headings and the open note's id as documentId, so the narrow explorer drawer closes when any control opens a note. In a Shell, main fill (on the Shell or the route) lets it fill the height left.
API reference
DocumentQuickOpen
Takes DocumentQuickOpenProps<T>.
WorkspaceCenter
| Prop | Type | Default |
|---|---|---|
staterequired | DocumentWorkspaceState | – |
hasExplorerrequired | boolean | – |
hasAsiderequired | boolean | – |
hasQuickOpenrequired | boolean | – |
quickOpenShortcutrequired | string | false | – |
tabs | ReactNode | – |
breadcrumb | ReactNode | – |
toolbar | ReactNode | – |
statusBar | ReactNode | – |
saveState | DocumentSaveState | – |
documentAsrequired | "region" | "main" | – |
documentRefrequired | RefObject<HTMLElement | null> | – |
childrenrequired | ReactNode | – |
WorkspaceDrawer
| Prop | Type | Default |
|---|---|---|
openrequired | boolean | – |
onOpenChangerequired | (open: boolean) => void | – |
siderequired | "start" | "end" | – |
titlerequired | string | – |
finalFocusrequired | ComponentProps<typeof DrawerContent>["finalFocus"] | – |
onClosedrequired | () => void | – |
childrenrequired | ReactNode | – |
WorkspaceColumns
| Prop | Type | Default |
|---|---|---|
staterequired | DocumentWorkspaceState | – |
explorer | ReactNode | – |
aside | ReactNode | – |
childrenrequired | ReactNode | – |
WorkspaceDrawers
| Prop | Type | Default |
|---|---|---|
staterequired | DocumentWorkspaceState | – |
explorer | ReactNode | – |
aside | ReactNode | – |
DocumentOutline
| Prop | Type | Default |
|---|---|---|
headingsThe headings to list; the workspace's `headings` by default. | readonly DocumentHeading[] | – |
labelThe navigation landmark's name. | string | "Outline" |
maxLevelDeeper headings are left out. | number | 6 |
className | string | – |
DocumentWorkspace
| Prop | Type | Default |
|---|---|---|
documentrequiredThe open document: a `MarkdownEditor` in edit mode, a `MarkdownView` in read mode. | ReactNode | – |
documentIdThe open document's id, like its slug or path. When it changes, the narrow layout's explorer drawer closes and focus goes to the document, whatever opened it: a link, a button in your tree, quick open or a wikilink. | string | – |
explorerA file tree or list, inside a navigation landmark: a resizable column when wide, a drawer when narrow. | ReactNode | – |
tabsOpen documents, like a `TabsList`, in the header. | ReactNode | – |
breadcrumb | ReactNode | – |
toolbarDocument actions, like a menu or a `MarkdownEditorToolbar` of your own, beside the breadcrumb. | ReactNode | – |
statusBarWord count, cursor position: before the save status. | ReactNode | – |
asideBacklinks, properties, a `DocumentOutline`, in a complementary landmark. | ReactNode | – |
alertA message read out at once when it appears, like a conflict `Alert` with your actions. | ReactNode | – |
quickOpenA `DocumentQuickOpen`; with it, the header gets a Quick open button and `quickOpenShortcut`. | ReactNode | – |
mode | DocumentWorkspaceMode | – |
defaultMode | DocumentWorkspaceMode | – |
onModeChange | (mode: DocumentWorkspaceMode) => void | – |
explorerOpenWhether the explorer is shown: the column when wide, the drawer when narrow. Control it with `onExplorerOpenChange`. | boolean | – |
defaultExplorerOpen | boolean | – |
onExplorerOpenChange | (open: boolean) => void | – |
asideOpen | boolean | – |
defaultAsideOpen | boolean | – |
onAsideOpenChange | (open: boolean) => void | – |
narrowAt this container width (px) or below, the explorer and the aside become drawers. 760 by default. | number | – |
saveState | DocumentSaveState | – |
labels | Partial<DocumentWorkspaceLabels> | – |
storageKeyRemembers whether the explorer and the aside are open, and their widths, in localStorage under this key. | string | – |
editorRefThe editor's handle, for the outline, focus return and the reading position across modes. | RefObject<DocumentEditor | null> | – |
headingsThe document's headings, from `extractHeadings`: the outline lists them and a mode switch keeps to them. | readonly DocumentHeading[] | – |
quickOpenShortcut`false` turns it off. | string | false | – |
documentAs`"main"` when the workspace is the page's main content; inside an app shell's `<main>`, a named region. | "region" | "main" | – |
className | string | – |
Other exports
documentQuickOpenLabelsDocumentWorkspaceContextdocumentWorkspaceLabelsfindHeadingreadHeadingstextBoxInuseDocumentWorkspaceuseDocumentWorkspaceStatefocusWhenReadyopenSizesreadPanelsrevealHeadinguseContainerNarrowuseControllableuseModeScrolluseOnKeyChangeusePanelwatchLostFocuswritePanelstype DocumentQuickOpenItemtype DocumentQuickOpenItemsPropstype DocumentQuickOpenLabelstype DocumentQuickOpenPropstype DocumentQuickOpenSourcePropstype WorkspaceCenterPropstype DocumentEditortype DocumentHeadingtype DocumentSaveStatetype DocumentWorkspaceContextValuetype DocumentWorkspaceLabelstype DocumentWorkspaceModetype DocumentOutlinePropstype DocumentWorkspacePropstype DocumentWorkspaceStatetype WorkspaceIdstype StoredPanelsAccessibility
- The explorer is a navigation landmark, the document a named region (or main) and the aside a complementary landmark; the Files and Details toggles carry aria-expanded and aria-controls.
- It lays out by its own width: resizable, collapsible columns when wide, drawers when narrow. Drawers, quick open and menus give focus back to the document.
- The save state is a polite status; the alert slot is an assertive region that is always present, so a conflict is read once when it appears.
- Ctrl/Cmd+P opens quick open; the outline moves the caret to a heading in edit mode and focus to it in read mode, and switching modes keeps the heading you were reading at the top.
Agent actions
Agents switch the Mode segmented control, press Files, Details and Quick open by name, read a quick open item as its title, folder and snippet, run one, follow wikilinks and use the editor's own actions.
Runs agent.snapshot() from @ui-sdk/react/agent on the live preview above.