Custom forms
Ask the questions your team needs alongside the message — a plan, a rating, a checkbox — and get answers Studio has already checked.
PanelUI components are native-only for now
The form, its answers and the checks Studio runs work on the web through the SDK. The PanelUI controls the App version draws them with — Radio Group, Rating, Checkbox, Input and Textarea — are React Native components and don't run in a browser yet. Fields on the web renders each type with plain form controls.
A report is a message plus whatever the device knows. When your team needs more — which plan someone is on, how easy a task was — add fields to the project's form in Studio (Project → Settings → Feedback form). Custom forms are part of Pro and Max.
Each field has a label, a key the app answers under, a type and whether it's required:
| Type | The app sends |
|---|---|
text, textarea | A string, up to 2,000 characters. text is kept to one line. |
choice | One of the field's options, exactly. |
checkbox | true or false. |
rating | A whole number from 1 to 5. |
Render the form
The app asks for the form, so a new field shows up without shipping an update:
import { useFeedbackForm } from 'panelui-studio/react';
export function ExtraQuestions({ answers, onChange }) {
const { fields } = useFeedbackForm();
return fields.map((field) => (
<FormField key={field.key} field={field} value={answers[field.key]} onChange={onChange} />
));
}Usage with PanelUI has the whole form drawn with PanelUI's controls.
Fields on the web has every field type drawn with plain form controls.
Without React, await studio.feedback.form() returns the same list. It's empty
on Free and when the project has no fields, so rendering it is always safe.
Send the answers
await studio.feedback.submit({
message,
fields: { plan: 'Pro', ease_of_use: 4, contact_me: true },
});Studio checks every answer against the form before the report is saved:
- A wrong type — a rating of 9, a choice that isn't an option — fails with
bad_request, and the message names the field. - Keys that aren't on the form are dropped and reported as a
fields_ignoredwarning, so an app built against an older form never loses a report. - Required fields are enforced once the app sends
fieldsat all — includingfields: {}, when the user skipped every question. A version of your app that predates the form, and sends none, still gets through.
Answers show in the inbox under Form and export one column per field.
Fields on the web
The same field types, as plain form controls. Swap in your own components where your site has them:
'use client';
import type { FormField } from 'panelui-studio';
import { useFeedbackForm } from 'panelui-studio/react';
export type Answers = Record<string, string | number | boolean>;
export function FormFields({
answers,
onChange,
}: {
answers: Answers;
onChange: (key: string, value: string | number | boolean) => void;
}) {
const { fields } = useFeedbackForm();
return fields.map((field) => (
<FieldInput key={field.key} field={field} value={answers[field.key]} onChange={(v) => onChange(field.key, v)} />
));
}
function FieldInput({
field,
value,
onChange,
}: {
field: FormField;
value: string | number | boolean | undefined;
onChange: (value: string | number | boolean) => void;
}) {
const id = `field-${field.key}`;
switch (field.type) {
case 'choice':
return (
<fieldset>
<legend>{field.label}</legend>
{field.options.map((option) => (
<label key={option}>
<input
type="radio"
name={id}
required={field.required}
checked={value === option}
onChange={() => onChange(option)}
/>
{option}
</label>
))}
</fieldset>
);
case 'rating':
return (
<label htmlFor={id}>
{field.label}
<input
id={id}
type="range"
min={1}
max={5}
value={typeof value === 'number' ? value : 3}
onChange={(event) => onChange(Number(event.target.value))}
/>
</label>
);
case 'checkbox':
return (
<label htmlFor={id}>
<input id={id} type="checkbox" checked={value === true} onChange={(event) => onChange(event.target.checked)} />
{field.label}
</label>
);
default: {
const Control = field.type === 'textarea' ? 'textarea' : 'input';
return (
<label htmlFor={id}>
{field.label}
<Control
id={id}
required={field.required}
maxLength={2000}
value={typeof value === 'string' ? value : ''}
onChange={(event) => onChange(event.target.value)}
/>
</label>
);
}
}
}Render <FormFields> inside your feedback form — the one on the Feedback
page works — keep the answers in
state, and send them as fields:
const [answers, setAnswers] = useState<Answers>({});
<FormFields
answers={answers}
onChange={(key, value) => setAnswers((current) => ({ ...current, [key]: value }))}
/>
await studio.feedback.submit({ message, fields: answers });Usage with PanelUI
The form is plain data, so any UI can render it. If your app uses PanelUI, each
field type has a control: choice is a
Radio Group, rating a
Rating, checkbox a
Checkbox, and the text types an
Input or Textarea:
import { View } from 'react-native';
import { Checkbox, Input, RadioGroup, Rating, Text, Textarea } from 'panelui-native';
import type { FormField } from 'panelui-studio';
import { useFeedbackForm } from 'panelui-studio/react';
export type Answers = Record<string, string | number | boolean>;
export function FormFields({
answers,
onChange,
}: {
answers: Answers;
onChange: (key: string, value: string | number | boolean) => void;
}) {
const { fields } = useFeedbackForm();
if (fields.length === 0) return null;
return (
<View className="gap-4">
{fields.map((field) => (
<FormFieldInput
key={field.key}
field={field}
value={answers[field.key]}
onChange={(value) => onChange(field.key, value)}
/>
))}
</View>
);
}
function FormFieldInput({
field,
value,
onChange,
}: {
field: FormField;
value: string | number | boolean | undefined;
onChange: (value: string | number | boolean) => void;
}) {
switch (field.type) {
case 'choice':
return (
<View className="gap-2">
<Text size="sm" weight="medium">
{field.label}
{field.required ? ' *' : ''}
</Text>
<RadioGroup
value={typeof value === 'string' ? value : ''}
onValueChange={onChange}
orientation="horizontal"
>
{field.options.map((option) => (
<RadioGroup.Item key={option} value={option} label={option} />
))}
</RadioGroup>
</View>
);
case 'rating':
return (
<Rating
label={field.label}
value={typeof value === 'number' ? value : 0}
onValueChange={onChange}
/>
);
case 'checkbox':
return <Checkbox label={field.label} checked={value === true} onCheckedChange={onChange} />;
case 'textarea':
return (
<Textarea
label={field.label}
isRequired={field.required}
value={typeof value === 'string' ? value : ''}
onChangeText={onChange}
/>
);
default:
return (
<Input label={field.label} value={typeof value === 'string' ? value : ''} onChangeText={onChange} />
);
}
}Put <FormFields> inside the panel of the
Feedback dialog, keep the answers in
state, and send them as fields:
const [answers, setAnswers] = useState<Answers>({});
<FormFields
answers={answers}
onChange={(key, value) => setAnswers((current) => ({ ...current, [key]: value }))}
/>
await studio.feedback.submit({ message, fields: answers });useFeedbackForm() has to reach a StudioProvider from inside the dialog, so
the provider goes above PanelUIProvider — see
Usage with PanelUI in the Quickstart.
