gform-react
Back to Examples

Event Registration

A live, editable gform-react example combining text inputs, a native select, and a date picker - all typed, validated, and gated on state.isInvalid.

A typed registration form that mixes the three most common controls: text inputs, a native <select>, and a date picker (type="date"). Each renders through the element render prop, so gform wires name/value/onChange and the aria-* attributes for you - you only style the markup.

A few things worth noting in the code below:

  • The <select> spreads {...props} directly - native since gform-react@2.10.0, no cast needed.
  • The date picker is just type="date"; pair it with a min constraint and a withRangeUnderflowMessage validator to reject past dates.
  • The checkbox stores a boolean value - gform passes checked (not value) in props, so a required checkbox must be ticked before state.isInvalid clears.
  • A field-level validator (topic) shows a per-key override layered on the '*' default.
Loading playground…
Mixing control types

Every control - text, <select>, <textarea>, type="date", checkboxes - goes through the same element render prop and the same validators map. There's no per-type API to learn: spread {...props}, read input.error/input.errorText, and gate submit on state.isInvalid.