Skip to content

Field

Use Field to wrap a form input with a label, helper text, and validation messages. It passes size, disabled, and validation state down to the input it wraps, such as an Input, Incrementer, or Picker.

The SDK Field wrapping an input with a label.
import { Field } from '/@dropins/tools/components.js';
PropTypeReq?Description
labelstringNoLabel text shown above the input.
hintstringNoHelper text shown below the input.
errorstringNoError message shown below the input. Takes priority over success and hint.
successstringNoSuccess message shown below the input.
size'medium' | 'large'NoField size, passed down to the wrapped input. Defaults to medium.
disabledbooleanNoWhether the field is disabled. Defaults to false.
childrenVNodeNoThe form input to wrap, such as an Input or Incrementer.

Field also accepts standard HTML attributes (for example, className), except size.

Wrap an input with a label and helper text:

import { Field, Input, provider } from '/@dropins/tools/components.js';
import { h } from '/@dropins/tools/preact.js';
await provider.render(Field, {
label: 'Email',
hint: 'We never share your email.',
children: h(Input, { name: 'email', placeholder: 'you@example.com' }),
})(document.querySelector('.field'));
  • Input — wrap it in a Field, as shown in the example above.
  • Design tokens — the spacing and typography fields use.