Widgets of your own
The built-in widgets cover the standard kinds of devices. When you need one that shows a value the way your lab wants it, or that combines several devices, write your own. A widget is a React component in a file of your workspace. You do not need Node or a build setup: LabOrchestra builds it when you save the file.
Make one
Section titled “Make one”-
On the dashboard, click Edit, then Add widget, and at the end of the panel New widget….


-
Choose a template, name the widget in
snake_case(big_pressure), and click Create. The filewidgets/big_pressure.tsxis in your workspace; a type file,laborchestra-widget.d.ts, is put next to it so that your editor knows the SDK (the server keeps it there up to date, also for a workspace whose widgets you write by hand). -
Open the file in your editor and change it. Every time you save, the dashboard loads the new version without a reload.
-
Your widget appears in the Add widget panel, next to every device it fits. Click it, or drag it to its place.
What a widget looks like
Section titled “What a widget looks like”import { Tile, useDevice } from '@laborchestra/widget';
export const meta = { title: 'Big pressure', size: 'S', profile: 'pressure_sensor' };
export default function BigPressure({ device }: { device: string }) { const d = useDevice(device); const pressure = d?.state.channels?.[0]?.pressure; return ( <Tile label={device} testId="big-pressure"> <span className="text-3xl font-bold text-accent">{pressure == null ? '–' : pressure.toExponential(1)}</span> </Tile> );}defaultis the component. It receives{ id, device, info, props }: the device it is shown for, its current status and state, and the settings of this instance.metatells the Add widget panel what the widget is.title;size:'main'(fills a pane, like an oscilloscope),'S'(a small tile) or'M'(a wider one);profile: offer it only for devices of that profile, or leave it out for any device;needsDevice: falsefor widgets that belong to no device;description: one line for the panel (keep thetitleshort: a long one is cut off);props: settings that the ⚙ dialog of the widget edits (name, label, type, default, limits).useDevice(id)gives the status and state of a device, anddevice.action("set_power", 0, -10)calls one of its actions.useStreamgives a live stream,useRecordingthe recording status. The widget SDK reference lists everything.- Tailwind classes work. The server builds one stylesheet from the dashboard and all widgets, with the same colours as the rest (
bg-panel,text-muted,text-accent, …). Class names that you assemble from pieces (`bg-${color}-500`) are not found; write them out. - Other npm packages (a plotting library, say) are bundled into your widget: run
npm installin thewidgets/folder.reactand@laborchestra/widgetcome from the page, so there is only one React.
A widget can also be a folder, widgets/big_pressure/index.tsx, with more files in it.
Mistakes
Section titled “Mistakes”A mistake in the file is shown in place of the widget, where you will see it: a build error with the line, or the error that the widget threw while it ran. Other widgets are not affected. The build error is just esbuild’s message (file, line, column, the line itself). The same errors go to the server’s log, with the source client; an AI assistant sees build errors with the MCP tools get_problems and list_widgets.
Building needs esbuild
Section titled “Building needs esbuild”The server builds widgets with esbuild, which comes with the release. If it cannot be found (a source checkout without it), the widgets say “esbuild was not found” instead of failing quietly. The setting esbuild names another program; see server settings.
Widgets can also come with a device package.
Something wrong or missing on this page? Open a GitHub issue or use the form (no account needed).