S
Documentation

Question Types

Every question in a survey has a type that determines how it's rendered and what kind of data it collects. The library ships with 17 built-in types and supports custom types via the extensible type system.

Common Question Properties

All question types share these base properties. Each type may support additional type-specific options documented on its own page.

Common Propertiestypescript
{
  id: string;              // Unique identifier
  type: QuestionType;      // One of the built-in types or a custom string
  label: string;           // Display label
  description?: string;    // Optional helper text
  placeholder?: string;    // Input placeholder text
  required?: boolean;      // Whether the field is required
  defaultValue?: any;      // Default answer value
  validation?: [];         // Array of validation rules
  visibleIf?: string;      // Conditional visibility expression
  meta?: {};               // Arbitrary metadata for custom types
}

Custom Question Types

Beyond the 17 built-in types, you can register any string as a question type and provide a custom React component to render it. The type system uses string & {} to allow arbitrary types while preserving autocomplete for built-in ones.

Custom Type Registrationtsx
// Register a custom component for your type
<SurveyRenderer
  schema={schema}
  components={{
    "file-upload": MyFileUploadComponent,
    "color-picker": MyColorPickerComponent,
  }}
/>