nteract elements

Built-in Controls

Gallery of shadcn-backed widget components

Loading widgets...

Installation

Install the widget controls along with the widget view infrastructure:

npx shadcn@latest add @nteract/widget-controls

New 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

WidgetModel NameDescription
IntSliderIntSliderModelInteger value with draggable handle
FloatSliderFloatSliderModelFloating point value with handle
FloatLogSliderFloatLogSliderModelLogarithmic scale slider
IntRangeSliderIntRangeSliderModelInteger range with two handles
FloatRangeSliderFloatRangeSliderModelFloat range with two handles
SelectionSliderSelectionSliderModelDiscrete option slider
SelectionRangeSliderSelectionRangeSliderModelDiscrete 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

WidgetModel NameDescription
IntProgressIntProgressModelInteger progress bar
FloatProgressFloatProgressModelFloat progress bar (0-1)

Common props: value, min, max, description, bar_style ("success", "info", "warning", "danger")

Text Input

WidgetModel NameDescription
TextTextModelSingle-line text input
TextareaTextareaModelMulti-line text input
PasswordPasswordModelMasked text input

Common props: value, description, placeholder, disabled, continuous_update

Numeric Input

WidgetModel NameDescription
IntTextIntTextModelInteger text input
FloatTextFloatTextModelFloat text input
BoundedIntTextBoundedIntTextModelBounded integer text input
BoundedFloatTextBoundedFloatTextModelBounded float text input

Common props: value, min, max, step, description, disabled, continuous_update

Display

WidgetModel NameDescription
LabelLabelModelPlain text display
HTMLHTMLModelRendered HTML content
HTMLMathHTMLMathModelHTML with LaTeX math rendering
ImageImageModelImage display from kernel
AudioAudioModelAudio player with controls
VideoVideoModelVideo 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

WidgetModel NameDescription
CheckboxCheckboxModelCheckbox with label
ToggleButtonToggleButtonModelToggle button

Common props: value, description, disabled

Selection

WidgetModel NameDescription
DropdownDropdownModelSingle-select dropdown
SelectSelectModelSingle-select listbox
ComboboxComboboxModelText input with autocomplete
RadioButtonsRadioButtonsModelRadio button group
ToggleButtonsToggleButtonsModelButton group for selection
SelectMultipleSelectMultipleModelMulti-select listbox

Common props: index, _options_labels, description, disabled, rows Combobox props: value, options, placeholder, ensure_option, continuous_update

Other

WidgetModel NameDescription
ButtonButtonModelClickable button
ColorPickerColorPickerModelColor selection input
ValidValidModelValidation indicator (checkmark/X)
PlayPlayModelAnimation control with play/pause
DatePickerDatePickerModelDate input field
DatetimeDatetimeModelDatetime input with timezone
NaiveDatetimeNaiveDatetimeModelDatetime input without timezone
TimePickerTimeModelTime input field
FileUploadFileUploadModelFile 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

WidgetModel NameDescription
TagsInputTagsInputModelMulti-value tag input
ColorsInputColorsInputModelMulti-value color picker
IntsInputIntsInputModelMulti-value integer input
FloatsInputFloatsInputModelMulti-value float input

Common props: value (array), description, allow_duplicates, placeholder TagsInput/ColorsInput: allowed_tags IntsInput/FloatsInput: min, max

Layout Containers

WidgetModel NameDescription
VBoxVBoxModelVertical stack
HBoxHBoxModelHorizontal row
BoxBoxModelGeneric container
GridBoxGridBoxModelCSS Grid layout
TabTabModelTabbed interface
AccordionAccordionModelCollapsible panels
StackStackModelShows 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

WidgetModel NameDescription
ControllerControllerModelGamepad input via Web Gamepad API
ControllerButtonControllerButtonModelIndividual button state
ControllerAxisControllerAxisModelIndividual 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.

On this page