Skip to main content
torch.jstorch.jstorch.js
Getting StartedPlaygroundContact
Login
torch.jstorch.jstorch.js
Documentation
IntroductionType SafetyTensor IndexingEinsumEinopsAutogradTraining a ModelProfiling & MemoryPyTorch MigrationBest PracticesRuntimesPerformance
IntroductionTraining DashboardsVisualizing TensorsGPU AccelerationInteractive InputsThemingStorybook
torch.js· 2026
LegalTerms of UsePrivacy Policy
  1. docs
  2. React UI
  3. Interactive Inputs

Interactive Inputs

To build truly interactive AI apps, you need ways to provide data to your models. react-ui includes specialized input components that bridge standard web inputs with tensor data formats.

Showcase of ImageInput, TextInput, and Param sliders

Image Input

The ImageInput component handles file uploads, URLs, and direct camera access, automatically converting the result to a format suitable for torch.js.

import { ImageInput } from '@torchjsorg/react-ui';

function MyModel() {
  const handleImage = async (image: HTMLImageElement) => {
    // Process image into a tensor...
  };

  return (
    <ImageInput 
      onChange={handleImage}
      width={224}
      height={224}
      modes={['upload', 'camera']}
    />
  );
}

Text and Tokens

For Natural Language Processing (NLP), the TextInput component provides real-time tokenization previews.

import { TextInput } from '@torchjsorg/react-ui';

<TextInput
  placeholder="Enter prompt here..."
  onTokenize={(tokens) => console.log(tokens)}
  showTokenCount={true}
/>

Controlling Hyperparameters

Use the Param group of components to adjust model behavior in real-time. These are ideal for exploring generative models or tuning training parameters.

ComponentIdeal For
ParamSliderContinuous values (Learning Rate, Temperature)
ParamSelectDiscrete choices (Optimizer, Activation type)
ParamCheckboxBoolean flags (Use Bias, Dropout enabled)
<ParamSlider
  label="Creativity (Temperature)"
  value={0.7}
  min={0}
  max={2}
  step={0.1}
/>

Next Steps

  • Visualizing Tensors - Show the results of your model's inference.
  • Training Dashboards - Using inputs to control your training loop.
Previous
GPU Acceleration
Next
Theming