Built-in Controls
Gallery of shadcn-backed widget components
Installation
Install the widget controls along with the widget view infrastructure:
npx shadcn@latest add @nteract/widget-controlsNew to @nteract? pnpm dlx shadcn@latest registry add @nteract
Copy the controls/ directory to your project.
Requires: Widget Store
Usage
Import the controls module to register all built-in widgets:
// Import to register all built-in widgets
import "@/components/widgets/controls"
// Or import specific widgets
import { IntSlider, Button, VBox } from "@/components/widgets/controls"Widget Reference
Sliders
| Widget | Model Name | Description |
|---|---|---|
| IntSlider | IntSliderModel | Integer value with draggable handle |
| FloatSlider | FloatSliderModel | Floating point value with handle |
| FloatLogSlider | FloatLogSliderModel | Logarithmic scale slider |
| IntRangeSlider | IntRangeSliderModel | Integer range with two handles |
| FloatRangeSlider | FloatRangeSliderModel | Float range with two handles |
| SelectionSlider | SelectionSliderModel | Discrete option slider |
| SelectionRangeSlider | SelectionRangeSliderModel | Discrete option range slider |
Common props: value, min, max, step, description, disabled, orientation, readout, readout_format
FloatLogSlider props: base (default 10), value, min, max (exponents)
Selection sliders: index, _options_labels, readout
Progress Bars
| Widget | Model Name | Description |
|---|---|---|
| IntProgress | IntProgressModel | Integer progress bar |
| FloatProgress | FloatProgressModel | Float progress bar (0-1) |
Common props: value, min, max, description, bar_style ("success", "info", "warning", "danger")
Text Input
| Widget | Model Name | Description |
|---|---|---|
| Text | TextModel | Single-line text input |
| Textarea | TextareaModel | Multi-line text input |
| Password | PasswordModel | Masked text input |
Common props: value, description, placeholder, disabled, continuous_update
Numeric Input
| Widget | Model Name | Description |
|---|---|---|
| IntText | IntTextModel | Integer text input |
| FloatText | FloatTextModel | Float text input |
| BoundedIntText | BoundedIntTextModel | Bounded integer text input |
| BoundedFloatText | BoundedFloatTextModel | Bounded float text input |
Common props: value, min, max, step, description, disabled, continuous_update
Display
| Widget | Model Name | Description |
|---|---|---|
| Label | LabelModel | Plain text display |
| HTML | HTMLModel | Rendered HTML content |
| HTMLMath | HTMLMathModel | HTML with LaTeX math rendering |
| Image | ImageModel | Image display from kernel |
| Audio | AudioModel | Audio player with controls |
| Video | VideoModel | Video player with controls |
Label/HTML props: value, description, placeholder
HTMLMath props: value (supports $...$ and $$...$$ math), description
Image props: value (base64), format, width, height, description
Audio/Video props: value (base64), format, autoplay, loop, controls
Boolean
| Widget | Model Name | Description |
|---|---|---|
| Checkbox | CheckboxModel | Checkbox with label |
| ToggleButton | ToggleButtonModel | Toggle button |
Common props: value, description, disabled
Selection
| Widget | Model Name | Description |
|---|---|---|
| Dropdown | DropdownModel | Single-select dropdown |
| Select | SelectModel | Single-select listbox |
| Combobox | ComboboxModel | Text input with autocomplete |
| RadioButtons | RadioButtonsModel | Radio button group |
| ToggleButtons | ToggleButtonsModel | Button group for selection |
| SelectMultiple | SelectMultipleModel | Multi-select listbox |
Common props: index, _options_labels, description, disabled, rows
Combobox props: value, options, placeholder, ensure_option, continuous_update
Other
| Widget | Model Name | Description |
|---|---|---|
| Button | ButtonModel | Clickable button |
| ColorPicker | ColorPickerModel | Color selection input |
| Valid | ValidModel | Validation indicator (checkmark/X) |
| Play | PlayModel | Animation control with play/pause |
| DatePicker | DatePickerModel | Date input field |
| Datetime | DatetimeModel | Datetime input with timezone |
| NaiveDatetime | NaiveDatetimeModel | Datetime input without timezone |
| TimePicker | TimeModel | Time input field |
| FileUpload | FileUploadModel | File upload button |
Button props: description (button text), button_style, tooltip, disabled
ColorPicker props: value (hex color), description, concise, disabled
Valid props: value (boolean), readout (status message), description
Play props: value, min, max, step, interval (ms), _playing, repeat
DatePicker/TimePicker/Datetime props: value, min, max, description, disabled
FileUpload props: value (file array), accept, multiple, button_style
Multi-value Inputs
| Widget | Model Name | Description |
|---|---|---|
| TagsInput | TagsInputModel | Multi-value tag input |
| ColorsInput | ColorsInputModel | Multi-value color picker |
| IntsInput | IntsInputModel | Multi-value integer input |
| FloatsInput | FloatsInputModel | Multi-value float input |
Common props: value (array), description, allow_duplicates, placeholder
TagsInput/ColorsInput: allowed_tags
IntsInput/FloatsInput: min, max
Layout Containers
| Widget | Model Name | Description |
|---|---|---|
| VBox | VBoxModel | Vertical stack |
| HBox | HBoxModel | Horizontal row |
| Box | BoxModel | Generic container |
| GridBox | GridBoxModel | CSS Grid layout |
| Tab | TabModel | Tabbed interface |
| Accordion | AccordionModel | Collapsible panels |
| Stack | StackModel | Shows one child at a time |
Common props: children (array of IPY_MODEL_<id> references), box_style
Tab/Accordion/Stack props: _titles, selected_index
Gamepad Controller
| Widget | Model Name | Description |
|---|---|---|
| Controller | ControllerModel | Gamepad input via Web Gamepad API |
| ControllerButton | ControllerButtonModel | Individual button state |
| ControllerAxis | ControllerAxisModel | Individual axis value (-1 to 1) |
Controller props: index, connected, name, mapping, buttons, axes, timestamp
ControllerButton props: pressed (boolean), value (float 0-1)
ControllerAxis props: value (float -1 to 1)
Customizing Widgets
Custom widget props
All widget components (built-in and custom) receive WidgetComponentProps:
interface WidgetComponentProps {
modelId: string; // The comm_id of the widget
className?: string; // Optional CSS classes
}Override a widget globally
Register your own component to replace any built-in widget:
import { registerWidget } from "@/components/widgets/widget-registry"
import { useWidgetModelValue, useWidgetStoreRequired } from "@/components/widgets/widget-store-context"
function MyFancySlider({ modelId, className }) {
const { sendUpdate } = useWidgetStoreRequired()
const value = useWidgetModelValue(modelId, "value") ?? 0
return (
<div className={className}>
<input
type="range"
value={value}
onChange={(e) => sendUpdate(modelId, { value: Number(e.target.value) })}
/>
</div>
)
}
// Replace the default IntSlider everywhere
registerWidget("IntSliderModel", MyFancySlider)Style via CSS variables
All widgets use shadcn's CSS variable theming. Customize colors in your tailwind.config.js:
module.exports = {
theme: {
extend: {
colors: {
primary: "hsl(var(--primary))",
// ... your custom theme
}
}
}
}Fork and modify
Copy any widget file from the controls/ directory and modify it directly. The widgets are intentionally simple and self-contained.