Workbench widgets

Compose controls for settings, file loading, pane layouts, and large data explorers. Start with the focused examples and API guides for TreeView, JsonTree, SplitPane, VirtualList, and FileInput. The combined explorer below shares selection and settings between its panes.

NumberRangeInput

Draft text stays local until it is finite and within bounds. Clearing retains the value; use empty="undefined" for optional fields. commit="change" waits for Enter, blur, or change. on_commit receives accepted changes. Native input attributes go in number_props and range_props.

Committed: 0.5

SplitPane and TreeView

SplitPane sizes its parent through --split-pane-size. Bind ratio or first_px; min_px, max_px, and second_min_px constrain it. Arrow keys resize, Home/End reach the limits, and Enter collapses or restores when collapsible is set. Save bindings or on_resize values in your own store for persistence.

TreeView accepts stable unique IDs, labels, children, or an async load(signal) function. It renders expanded nodes only and supports arrow keys, Home/End, selection, and type-to-focus. JsonTree adds search, copy, paths, editing callbacks and comparison highlighting for object data.

VirtualList

Only visible rows plus overscan are mounted. Set a fixed item_size that fits your content and call scroll_to_index to reveal a row. The exported virtual_window helper supports custom table and grid markup. Variable-height rows require a different layout.

1: Item 1
2: Item 2
3: Item 3
4: Item 4
5: Item 5
6: Item 6
7: Item 7
8: Item 8
9: Item 9
10: Item 10
11: Item 11
12: Item 12
13: Item 13
14: Item 14
15: Item 15
16: Item 16
17: Item 17
18: Item 18
19: Item 19
20: Item 20

FileInput

Picker and drop validation share accept, max_size, max_files, and multiple. Rejections include type, size, or count reasons. Supply on_files(files, signal) to parse or upload; replacement, cancellation, and unmount abort the signal. Supply a children snippet for custom previews, including FileDetails for text.

Progress and TaskStatus

Progress uses a native progress element; omit value for indeterminate work. TaskStatus adds a live label and caller-owned cancellation/retry callbacks, so it can be used inside an action, pane, or toast without owning your operation.

Processing files

CodeBlock and StatGrid

CodeBlock accepts plain code or an optional highlight(code, language, signal) callback. Return tokens with raw text and an optional CSS class (the component escapes the text), or trusted highlighted HTML. Changes cancel pending work; failures leave the source visible and show the error. Set wrap for long lines.

const total = values.reduce((sum, value) => sum + value, 0)

StatGrid accepts items with label, value, optional unit, delta and hint. A custom format callback controls value formatting. Non-finite values and changes display as unavailable.

Completed 1,234 ▲ 28 Since the previous run
Latency 12.5ms ▼ 2.1
State Ready

Feedback

Loading preview
Your changes were saved.

StatusMessage supports info, success, warning and error announcements. Dismissal clears its bindable message. Spinner adds an accessible status around CircleSpinner.

DragOverlay fills a positioned parent; ClickFeedback uses viewport coordinates. The caller owns visibility and timing.

Canvas and keyboard primitives

create_canvas_surface from svelte-widgets/canvas takes reactive canvas and optional overlay getters, an optional CSS height, draw callbacks and repaint_deps. Create it during component initialization. Frames receive a 2D context and CSS width/height. The base is cleared before drawing; the overlay clears itself. schedule(false) redraws only the overlay. Parent resizes and DPR changes update both backing stores; cleanup stops observers and pending frames.

create_roving_focus from svelte-widgets/roving-focus takes container and items getters. Give each item a unique data-roving-key, and use tabindex(key). Forward the container's keydown and focusin events. Arrow keys wrap through DOM order; Home and End reach its ends. Modified keys and editable children retain their normal behavior.