Skip to main content

Styling

Workbench is headless. It ships and imports no CSS, gives its elements no class names, and exposes structure and state as data-* attributes instead, so any styling tool works. Boolean attributes are present (as "true") when active and absent otherwise. The editor's interior belongs to the editor renderer: ui-kit CodeEditor brings its own CodeMirror styles and themes, and Workbench's selectors stop at [data-workbench-content].

Inline styles​

Only styles that the behavior itself depends on are inline. Inline styles win over stylesheet rules, so override them only with !important.

ElementInline styleWhy
[data-workbench-sidebar]width: N%, flex-shrink: 0The width is the resize state. Not set with renderLayout
[data-workbench-resize-handle]touch-action: noneA touch drag would scroll the page instead
[data-workbench-tree]height: 100%, width: 100%, min-height: 0The virtualized tree measures this box
[data-workbench-node]position, top, height (22px), width, min-width: max-contentSet by react-arborist for virtualization. min-width: max-content makes long names scroll sideways; the example below overrides it to truncate them
[data-workbench-node-content]padding-left (16px per level)Indentation by depth, set by react-arborist

Attributes​

SelectorMeaning
[data-workbench]Widget root
[data-workbench][data-theme]dark or light, from colorTheme
[data-workbench][data-readonly]Read-only widget
[data-workbench][data-resizing]Present while the sidebar is being resized
[data-workbench-sidebar]Region that holds the tree
[data-workbench-resize-handle]Sidebar separator (role="separator"); data-dragging while dragged
[data-workbench-main]Region that holds the tabs and the editor; aria-busy while a file opens
[data-workbench-tree]Tree <nav>; data-loading while the root loads
[data-workbench-tree-error]Load error inside a standalone FileTree without onError; Workbench shows it in [data-workbench-error] instead
[data-workbench-node]Tree row (role="treeitem"); data-kind is file or directory, plus data-selected and data-expanded
[data-workbench-node-content]Row content, indented by depth
[data-workbench-node-arrow]Directory disclosure arrow; data-open while expanded
[data-workbench-node-icon]Consumer icon wrapper, omitted when renderIcon returns nothing
[data-workbench-node-name]File or directory name
[data-workbench-tabs]Tab list (role="tablist")
[data-workbench-tab]One tab; data-active, data-dirty, data-dragging and data-drop-target reflect its state
[data-workbench-tab-label]Button that activates the tab (role="tab")
[data-workbench-tab-icon]Consumer icon wrapper, omitted when renderIcon returns nothing
[data-workbench-tab-name]File name
[data-workbench-tab-close]Close button
[data-workbench-save]Save button for the active tab; data-dirty while it has unsaved edits
[data-workbench-error]Error message (role="alert")
[data-workbench-empty]Shown while no file is open
[data-workbench-editor]Editor wrapper owned by Workbench; data-readonly when read-only
[data-workbench-content]Element that contains the renderer's output

data-dirty is a shared state attribute: it appears on both the save button and a tab.

Tailwind CSS v4 example​

A complete stylesheet for Tailwind CSS v4 with @tailwindcss/vite or @tailwindcss/postcss. Import it once in the app; it styles the tree, tabs, separator, save button, messages and editor area in both themes. The wb-dark variant keys dark colors on Workbench's own data-theme, so it does not depend on how the app handles dark mode.

@import 'tailwindcss';

/* Matches elements inside a Workbench whose colorTheme is 'dark'. */
@custom-variant wb-dark (&:where([data-workbench][data-theme='dark'], [data-workbench][data-theme='dark'] *));

@layer components {
/* Layout. The widget fills its parent, which must have a height. */
[data-workbench] {
@apply flex h-full bg-white text-sm text-zinc-800 wb-dark:bg-zinc-900 wb-dark:text-zinc-200;
}
[data-workbench][data-resizing] {
@apply cursor-col-resize select-none;
}
[data-workbench-sidebar] {
@apply min-w-0 py-1;
}
[data-workbench-resize-handle] {
@apply w-1 shrink-0 cursor-col-resize bg-zinc-200 outline-none hover:bg-sky-500 focus-visible:bg-sky-500 wb-dark:bg-zinc-700;
}
[data-workbench-resize-handle][data-dragging] {
@apply bg-sky-500;
}
[data-workbench-main] {
@apply flex min-w-0 flex-1 flex-col;
}

/* Tree. Row position, height and indentation are inline styles. */
[data-workbench-node] {
@apply cursor-pointer outline-none hover:bg-zinc-100 wb-dark:hover:bg-zinc-800;
/* Rows are inline min-width: max-content, which scrolls long names
sideways. Overriding it truncates them instead. */
min-width: 0 !important;
}
[data-workbench-node][data-selected] {
@apply bg-sky-100 wb-dark:bg-sky-900/60;
}
[data-workbench-node]:focus-visible {
@apply ring-1 ring-sky-500 ring-inset;
}
[data-workbench-node-content] {
@apply flex h-full min-w-0 items-center gap-1.5 overflow-hidden pr-2 whitespace-nowrap;
}
/* Indentation is an inline padding-left, so files line up with directory
names through a margin instead. */
[data-workbench-node][data-kind='file'] [data-workbench-node-name] {
@apply ml-4;
}
[data-workbench-node-arrow] {
@apply w-2.5 text-center text-zinc-500;
}
[data-workbench-node-name] {
@apply min-w-0 truncate;
}
[data-workbench-tree][data-loading] {
@apply opacity-60;
}

/* Tabs. */
[data-workbench-tabs] {
@apply flex overflow-x-auto border-b border-zinc-200 bg-zinc-50 wb-dark:border-zinc-700 wb-dark:bg-zinc-800;
}
[data-workbench-tab] {
@apply flex shrink-0 items-center border-r border-zinc-200 text-zinc-500 wb-dark:border-zinc-700;
}
[data-workbench-tab][data-active] {
@apply bg-white text-zinc-900 wb-dark:bg-zinc-900 wb-dark:text-zinc-100;
}
[data-workbench-tab][data-dragging] {
@apply opacity-50;
}
[data-workbench-tab][data-drop-target] {
@apply border-l-2 border-l-sky-500;
}
[data-workbench-tab-label] {
@apply flex items-center gap-1.5 py-1.5 pr-1 pl-3;
}
[data-workbench-tab-close] {
@apply mr-1 rounded px-1 leading-none opacity-60 hover:bg-zinc-200 hover:opacity-100 wb-dark:hover:bg-zinc-700;
}
/* A dot replaces the close mark on unsaved tabs until hovered. */
[data-workbench-tab][data-dirty]:not(:hover) [data-workbench-tab-close] {
@apply text-[0px] before:text-sm before:content-['●'];
}

/* Save button, messages and the editor. */
[data-workbench-save] {
@apply m-2 self-start rounded border border-zinc-300 px-3 py-1 hover:bg-zinc-100 disabled:opacity-40 disabled:hover:bg-transparent wb-dark:border-zinc-600 wb-dark:hover:bg-zinc-800;
}
[data-workbench-save][data-dirty] {
@apply border-sky-500 text-sky-600 wb-dark:text-sky-400;
}
[data-workbench-error] {
@apply mx-2 rounded bg-red-50 px-3 py-2 text-red-700 wb-dark:bg-red-950 wb-dark:text-red-300;
}
[data-workbench-empty] {
@apply m-auto text-zinc-400;
}
[data-workbench-editor],
[data-workbench-content] {
@apply flex min-h-0 flex-1 flex-col;
}
[data-workbench-content] > * {
@apply min-h-0 flex-1;
}
}