Forms library for react-native

Overview

build status dependency status npm downloads

Notice

tcomb-form-native is looking for maintainers. If you're interested in helping, a great way to get started would just be to start weighing-in on GitHub issues, reviewing and testing some PRs.

Contents

Setup

npm install tcomb-form-native

Supported react-native versions

Version React Native Support Android Support iOS Support
0.5 - 0.6.1 0.25.0 - 0.35.0 7.1 10.0.2
0.4 0.20.0 - 0.24.0 7.1 10.0.2
0.3 0.1.0 - 0.13.0 7.1 10.0.2
Complies with react-native-version-support-table

Domain Driven Forms

The tcomb library provides a concise but expressive way to define domain models in JavaScript.

The tcomb-validation library builds on tcomb, providing validation functions for tcomb domain models.

This library builds on those two and the awesome react-native.

Benefits

With tcomb-form-native you simply call <Form type={Model} /> to generate a form based on that domain model. What does this get you?

  1. Write a lot less code
  2. Usability and accessibility for free (automatic labels, inline validation, etc)
  3. No need to update forms when domain model changes

JSON Schema support

JSON Schemas are also supported via the (tiny) tcomb-json-schema library.

Note. Please use tcomb-json-schema ^0.2.5.

Pluggable look and feel

The look and feel is customizable via react-native stylesheets and templates (see documentation).

Screencast

http://react.rocks/example/tcomb-form-native

Example App

https://github.com/bartonhammond/snowflake React-Native, Tcomb, Redux, Parse.com, Jest - 88% coverage

Example

// index.ios.js

'use strict';

var React = require('react-native');
var t = require('tcomb-form-native');
var { AppRegistry, StyleSheet, Text, View, TouchableHighlight } = React;

var Form = t.form.Form;

// here we are: define your domain model
var Person = t.struct({
  name: t.String,              // a required string
  surname: t.maybe(t.String),  // an optional string
  age: t.Number,               // a required number
  rememberMe: t.Boolean        // a boolean
});

var options = {}; // optional rendering options (see documentation)

var AwesomeProject = React.createClass({

  onPress: function () {
    // call getValue() to get the values of the form
    var value = this.refs.form.getValue();
    if (value) { // if validation fails, value will be null
      console.log(value); // value here is an instance of Person
    }
  },

  render: function() {
    return (
      <View style={styles.container}>
        {/* display */}
        <Form
          ref="form"
          type={Person}
          options={options}
        />
        <TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
          <Text style={styles.buttonText}>Save</Text>
        </TouchableHighlight>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    justifyContent: 'center',
    marginTop: 50,
    padding: 20,
    backgroundColor: '#ffffff',
  },
  buttonText: {
    fontSize: 18,
    color: 'white',
    alignSelf: 'center'
  },
  button: {
    height: 36,
    backgroundColor: '#48BBEC',
    borderColor: '#48BBEC',
    borderWidth: 1,
    borderRadius: 8,
    marginBottom: 10,
    alignSelf: 'stretch',
    justifyContent: 'center'
  }
});

AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);

Output:

(Labels are automatically generated)

Result

Ouput after a validation error:

Result after a validation error

API

getValue()

Returns null if the validation failed, an instance of your model otherwise.

Note. Calling getValue will cause the validation of all the fields of the form, including some side effects like highlighting the errors.

validate()

Returns a ValidationResult (see tcomb-validation for a reference documentation).

Adding a default value and listen to changes

The Form component behaves like a controlled component:

var Person = t.struct({
  name: t.String,
  surname: t.maybe(t.String)
});

var AwesomeProject = React.createClass({

  getInitialState() {
    return {
      value: {
        name: 'Giulio',
        surname: 'Canti'
      }
    };
  },

  onChange(value) {
    this.setState({value});
  },

  onPress: function () {
    var value = this.refs.form.getValue();
    if (value) {
      console.log(value);
    }
  },

  render: function() {
    return (
      <View style={styles.container}>
        <Form
          ref="form"
          type={Person}
          value={this.state.value}
          onChange={this.onChange}
        />
        <TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
          <Text style={styles.buttonText}>Save</Text>
        </TouchableHighlight>
      </View>
    );
  }
});

The onChange handler has the following signature:

(raw: any, path: Array<string | number>) => void

where

  • raw contains the current raw value of the form (can be an invalid value for your model)
  • path is the path to the field triggering the change

Warning. tcomb-form-native uses shouldComponentUpdate aggressively. In order to ensure that tcomb-form-native detect any change to type, options or value props you have to change references:

Disable a field based on another field's value

var Type = t.struct({
  disable: t.Boolean, // if true, name field will be disabled
  name: t.String
});

// see the "Rendering options" section in this guide
var options = {
  fields: {
    name: {}
  }
};

var AwesomeProject = React.createClass({

  getInitialState() {
    return {
      options: options,
      value: null
    };
  },

  onChange(value) {
    // tcomb immutability helpers
    // https://github.com/gcanti/tcomb/blob/master/docs/API.md#updating-immutable-instances
    var options = t.update(this.state.options, {
      fields: {
        name: {
          editable: {'$set': !value.disable}
        }
      }
    });
    this.setState({options: options, value: value});
  },

  onPress: function () {
    var value = this.refs.form.getValue();
    if (value) {
      console.log(value);
    }
  },

  render: function() {
    return (
      <View style={styles.container}>
        <Form
          ref="form"
          type={Type}
          options={this.state.options}
          value={this.state.value}
          onChange={this.onChange}
        />
        <TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
          <Text style={styles.buttonText}>Save</Text>
        </TouchableHighlight>
      </View>
    );
  }

});

How to get access to a field

You can get access to a field with the getComponent(path) API:

var Person = t.struct({
  name: t.String,
  surname: t.maybe(t.String),
  age: t.Number,
  rememberMe: t.Boolean
});

var AwesomeProject = React.createClass({

  componentDidMount() {
    // give focus to the name textbox
    this.refs.form.getComponent('name').refs.input.focus();
  },

  onPress: function () {
    var value = this.refs.form.getValue();
    if (value) {
      console.log(value);
    }
  },

  render: function() {
    return (
      <View style={styles.container}>
        <Form
          ref="form"
          type={Person}
        />
        <TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
          <Text style={styles.buttonText}>Save</Text>
        </TouchableHighlight>
      </View>
    );
  }
});

How to clear form after submit

var Person = t.struct({
  name: t.String,
  surname: t.maybe(t.String),
  age: t.Number,
  rememberMe: t.Boolean
});

var AwesomeProject = React.createClass({

  getInitialState() {
    return { value: null };
  },

  onChange(value) {
    this.setState({ value });
  },

  clearForm() {
    // clear content from all textbox
    this.setState({ value: null });
  },

  onPress: function () {
    var value = this.refs.form.getValue();
    if (value) {
      console.log(value);
      // clear all fields after submit
      this.clearForm();
    }
  },

  render: function() {
    return (
      <View style={styles.container}>
        <Form
          ref="form"
          type={Person}
          value={this.state.value}
          onChange={this.onChange.bind(this)}
        />
        <TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
          <Text style={styles.buttonText}>Save</Text>
        </TouchableHighlight>
      </View>
    );
  }
});

Dynamic forms example: how to change a form based on selection

Say I have an iOS Picker, depending on which option is selected in this picker I want the next component to either be a checkbox or a textbox:

const Country = t.enums({
  'IT': 'Italy',
  'US': 'United States'
}, 'Country');

var AwesomeProject = React.createClass({

  // returns the suitable type based on the form value
  getType(value) {
    if (value.country === 'IT') {
      return t.struct({
        country: Country,
        rememberMe: t.Boolean
      });
    } else if (value.country === 'US') {
      return t.struct({
        country: Country,
        name: t.String
      });
    } else {
      return t.struct({
        country: Country
      });
    }
  },

  getInitialState() {
    const value = {};
    return { value, type: this.getType(value) };
  },

  onChange(value) {
    // recalculate the type only if strictly necessary
    const type = value.country !== this.state.value.country ?
      this.getType(value) :
      this.state.type;
    this.setState({ value, type });
  },

  onPress() {
    var value = this.refs.form.getValue();
    if (value) {
      console.log(value);
    }
  },

  render() {

    return (
      <View style={styles.container}>
        <t.form.Form
          ref="form"
          type={this.state.type}
          value={this.state.value}
          onChange={this.onChange}
        />
        <TouchableHighlight style={styles.button} onPress={this.onPress} underlayColor='#99d9f4'>
          <Text style={styles.buttonText}>Save</Text>
        </TouchableHighlight>
      </View>
    );
  }
});

Types

Required field

By default fields are required:

var Person = t.struct({
  name: t.String,    // a required string
  surname: t.String  // a required string
});

Optional field

In order to create an optional field, wrap the field type with the t.maybe combinator:

var Person = t.struct({
  name: t.String,
  surname: t.String,
  email: t.maybe(t.String) // an optional string
});

The postfix " (optional)" is automatically added to optional fields.

You can customise the postfix value or setting a postfix for required fields:

t.form.Form.i18n = {
  optional: '',
  required: ' (required)' // inverting the behaviour: adding a postfix to the required fields
};

Numbers

In order to create a numeric field, use the t.Number type:

var Person = t.struct({
  name: t.String,
  surname: t.String,
  email: t.maybe(t.String),
  age: t.Number // a numeric field
});

tcomb-form-native will convert automatically numbers to / from strings.

Booleans

In order to create a boolean field, use the t.Boolean type:

var Person = t.struct({
  name: t.String,
  surname: t.String,
  email: t.maybe(t.String),
  age: t.Number,
  rememberMe: t.Boolean // a boolean field
});

Booleans are displayed as SwitchIOSs.

Dates

In order to create a date field, use the t.Date type:

var Person = t.struct({
  name: t.String,
  surname: t.String,
  email: t.maybe(t.String),
  age: t.Number,
  birthDate: t.Date // a date field
});

Dates are displayed as DatePickerIOSs under iOS and DatePickerAndroid or TimePickerAndroid under Android, depending on the mode selected (date or time).

Under Android, use the fields option to configure which mode to display the Picker:

// see the "Rendering options" section in this guide
var options = {
  fields: {
    birthDate: {
      mode: 'date' // display the Date field as a DatePickerAndroid
    }
  }
};

iOS date config option

The bundled template will render an iOS UIDatePicker component, but collapsed into a touchable component in order to improve usability. A config object can be passed to customize it with the following parameters:

Key Value
animation The animation to collapse the date picker. Defaults to Animated.timing.
animationConfig The animation configuration object. Defaults to {duration: 200} for the default animation.
format A (date) => String(date) kind of function to provide a custom date format parsing to display the value. Optional, defaults to (date) => String(date).
defaultValueText An string to customize the default value of the null date value text.

For the collapsible customization, look at the dateTouchable and dateValue keys in the stylesheet file.

Android date config option

When using a t.Date type in Android, it can be configured through a config option that take the following parameters:

Key Value
background Determines the type of background drawable that's going to be used to display feedback. Optional, defaults to TouchableNativeFeedback.SelectableBackground.
format A (date) => String(date) kind of function to provide a custom date format parsing to display the value. Optional, defaults to (date) => String(date).
dialogMode Determines the type of datepicker mode for Android (default, spinner or calendar).
defaultValueText An string to customize the default value of the null date value text.

Enums

In order to create an enum field, use the t.enums combinator:

var Gender = t.enums({
  M: 'Male',
  F: 'Female'
});

var Person = t.struct({
  name: t.String,
  surname: t.String,
  email: t.maybe(t.String),
  age: t.Number,
  rememberMe: t.Boolean,
  gender: Gender // enum
});

Enums are displayed as Pickers.

iOS select config option

The bundled template will render an iOS UIPickerView component, but collapsed into a touchable component in order to improve usability. A config object can be passed to customize it with the following parameters:

Key Value
animation The animation to collapse the date picker. Defaults to Animated.timing.
animationConfig The animation configuration object. Defaults to {duration: 200} for the default animation.

For the collapsible customization, look at the pickerContainer, pickerTouchable and pickerValue keys in the stylesheet file.

Refinements

A predicate is a function with the following signature:

(x: any) => boolean

You can refine a type with the t.refinement(type, predicate) combinator:

// a type representing positive numbers
var Positive = t.refinement(t.Number, function (n) {
  return n >= 0;
});

var Person = t.struct({
  name: t.String,
  surname: t.String,
  email: t.maybe(t.String),
  age: Positive, // refinement
  rememberMe: t.Boolean,
  gender: Gender
});

Subtypes allow you to express any custom validation with a simple predicate.

Rendering options

In order to customize the look and feel, use an options prop:

<Form type={Model} options={options} />

Form component

Labels and placeholders

By default labels are automatically generated. You can turn off this behaviour or override the default labels on field basis.

var options = {
  label: 'My struct label' // <= form legend, displayed before the fields
};

var options = {
  fields: {
    name: {
      label: 'My name label' // <= label for the name field
    }
  }
};

In order to automatically generate default placeholders, use the option auto: 'placeholders':

var options = {
  auto: 'placeholders'
};

<Form type={Person} options={options} />

Placeholders

Set auto: 'none' if you don't want neither labels nor placeholders.

var options = {
  auto: 'none'
};

Fields order

You can sort the fields with the order option:

var options = {
  order: ['name', 'surname', 'rememberMe', 'gender', 'age', 'email']
};

Default values

You can set the default values passing a value prop to the Form component:

var value = {
  name: 'Giulio',
  surname: 'Canti',
  age: 41,
  gender: 'M'
};

<Form type={Model} value={value} />

Fields configuration

You can configure each field with the fields option:

var options = {
  fields: {
    name: {
      // name field configuration here..
    },
    surname: {
      // surname field configuration here..
    }
  }
};

Textbox component

Implementation: TextInput

Tech note. Values containing only white spaces are converted to null.

Placeholder

You can set the placeholder with the placeholder option:

var options = {
  fields: {
    name: {
      placeholder: 'Your placeholder here'
    }
  }
};

Label

You can set the label with the label option:

var options = {
  fields: {
    name: {
      label: 'Insert your name'
    }
  }
};

Help message

You can set a help message with the help option:

var options = {
  fields: {
    name: {
      help: 'Your help message here'
    }
  }
};

Help

Error messages

You can add a custom error message with the error option:

var options = {
  fields: {
    email: {
      // you can use strings or JSX
      error: 'Insert a valid email'
    }
  }
};

Help

tcomb-form-native will display the error message when the field validation fails.

error can also be a function with the following signature:

(value, path, context) => ?(string | ReactElement)

where

  • value is an object containing the current form value.
  • path is the path of the value being validated
  • context is the value of the context prop. Also it contains a reference to the component options.

The value returned by the function will be used as error message.

If you want to show the error message onload, add the hasError option:

var options = {
  hasError: true,
  error: <i>A custom error message</i>
};

Another way is to add a:

getValidationErrorMessage(value, path, context)

static function to a type, where:

  • value is the (parsed) current value of the component.
  • path is the path of the value being validated
  • context is the value of the context prop. Also it contains a reference to the component options.
var Age = t.refinement(t.Number, function (n) { return n >= 18; });

// if you define a getValidationErrorMessage function, it will be called on validation errors
Age.getValidationErrorMessage = function (value, path, context) {
  return 'bad age, locale: ' + context.locale;
};

var Schema = t.struct({
  age: Age
});

...

<t.form.Form
  ref="form"
  type={Schema}
  context={{locale: 'it-IT'}}
/>

You can even define getValidationErrorMessage on the supertype in order to be DRY:

t.Number.getValidationErrorMessage = function (value, path, context) {
  return 'bad number';
};

Age.getValidationErrorMessage = function (value, path, context) {
  return 'bad age, locale: ' + context.locale;
};

Other standard options

The following standard options are available (see http://facebook.github.io/react-native/docs/textinput.html):

  • allowFontScaling
  • autoCapitalize
  • autoCorrect
  • autoFocus
  • bufferDelay
  • clearButtonMode
  • editable
  • enablesReturnKeyAutomatically
  • keyboardType
  • maxLength
  • multiline
  • numberOfLines
  • onBlur
  • onEndEditing
  • onFocus
  • onSubmitEditing
  • onContentSizeChange
  • password
  • placeholderTextColor
  • returnKeyType
  • selectTextOnFocus
  • secureTextEntry
  • selectionState
  • textAlign
  • textAlignVertical
  • textContentType
  • underlineColorAndroid

underlineColorAndroid is not supported now on tcomb-form-native due to random crashes on Android, especially on ScrollView. See more on: https://github.com/facebook/react-native/issues/17530#issuecomment-416367184

Checkbox component

Implementation: SwitchIOS

The following options are similar to the Textbox component's ones:

  • label
  • help
  • error

Other standard options

The following standard options are available (see http://facebook.github.io/react-native/docs/switchios.html):

  • disabled
  • onTintColor
  • thumbTintColor
  • tintColor

Select component

Implementation: PickerIOS

The following options are similar to the Textbox component's ones:

  • label
  • help
  • error

nullOption option

You can customize the null option with the nullOption option:

var options = {
  fields: {
    gender: {
      nullOption: {value: '', text: 'Choose your gender'}
    }
  }
};

You can remove the null option setting the nullOption option to false.

Warning: when you set nullOption = false you must also set the Form's value prop for the select field.

Tech note. A value equal to nullOption.value (default '') is converted to null.

Options order

You can sort the options with the order option:

var options = {
  fields: {
    gender: {
      order: 'asc' // or 'desc'
    }
  }
};

Options isCollapsed

You can determinate if Select is collapsed:

var options = {
  fields: {
    gender: {
      isCollapsed: false // default: true
    }
  }
};

If option not set, default is true

Options onCollapseChange

You can set a callback, triggered, when collapse change:

var options = {
  fields: {
    gender: {
      onCollapseChange: () => { console.log('collapse changed'); }
    }
  }
};

DatePicker component

Implementation: DatePickerIOS

Example

var Person = t.struct({
  name: t.String,
  birthDate: t.Date
});

The following options are similar to the Textbox component's ones:

  • label
  • help
  • error

Other standard options

The following standard options are available (see http://facebook.github.io/react-native/docs/datepickerios.html):

  • maximumDate,
  • minimumDate,
  • minuteInterval,
  • mode,
  • timeZoneOffsetInMinutes

Hidden Component

For any component, you can set the field with the hidden option:

var options = {
  fields: {
    name: {
      hidden: true
    }
  }
};

This will completely skip the rendering of the component, while the default value will be available for validation purposes.

Unions

Code Example

const AccountType = t.enums.of([
  'type 1',
  'type 2',
  'other'
], 'AccountType')

const KnownAccount = t.struct({
  type: AccountType
}, 'KnownAccount')

// UnknownAccount extends KnownAccount so it owns also the type field
const UnknownAccount = KnownAccount.extend({
  label: t.String,
}, 'UnknownAccount')

// the union
const Account = t.union([KnownAccount, UnknownAccount], 'Account')

// the final form type
const Type = t.list(Account)

const options = {
  item: [ // one options object for each concrete type of the union
    {
      label: 'KnownAccount'
    },
    {
      label: 'UnknownAccount'
    }
  ]
}

Generally tcomb's unions require a dispatch implementation in order to select the suitable type constructor for a given value and this would be the key in this use case:

// if account type is 'other' return the UnknownAccount type
Account.dispatch = value => value && value.type === 'other' ? UnknownAccount : KnownAccount

Lists

You can handle a list with the t.list combinator:

const Person = t.struct({
  name: t.String,
  tags: t.list(t.String) // a list of strings
});

Items configuration

To configure all the items in a list, set the item option:

const Person = t.struct({
  name: t.String,
  tags: t.list(t.String) // a list of strings
});

const options = {
  fields: { // <= Person options
    tags: {
      item: { // <= options applied to each item in the list
        label: 'My tag'
      }
    }
  }
});

Nested structures

You can nest lists and structs at an arbitrary level:

const Person = t.struct({
  name: t.String,
  surname: t.String
});

const Persons = t.list(Person);

If you want to provide options for your nested structures they must be nested following the type structure. Here is an example:

const Person = t.struct({
  name: t.Struct,
  position: t.Struct({
    latitude: t.Number,
    longitude: t.Number
  });
});

const options = {
  fields: { // <= Person options
    name: {
        label: 'name label'
    }
    position: {
        fields: {
            // Note that latitude is not directly nested in position,
            // but in the fields property
            latitude: {
                label: 'My position label'
            }
        }
    }
  }
});

When dealing with t.list, make sure to declare the fields property inside the item property, as such:

const Documents = t.struct({
  type: t.Number,
  value: t.String
})

const Person = t.struct({
  name: t.Struct,
  documents: t.list(Documents)
});

const options = {
  fields: {
    name: { /*...*/ },
    documents: {
      item: {
        fields: {
          type: {
            // Documents t.struct 'type' options
          },
          value: {
            // Documents t.struct 'value' options
          }
        }
      }
    }
  }
}

Internationalization

You can override the default language (english) with the i18n option:

const options = {
  i18n: {
    optional: ' (optional)',
    required: '',
    add: 'Add',   // add button
    remove: '✘',  // remove button
    up: '↑',      // move up button
    down: '↓'     // move down button
  }
};

Buttons configuration

You can prevent operations on lists with the following options:

  • disableAdd: (default false) prevents adding new items
  • disableRemove: (default false) prevents removing existing items
  • disableOrder: (default false) prevents sorting existing items
const options = {
  disableOrder: true
};

List with Dynamic Items (Different structs based on selected value)

Lists of different types are not supported. This is because a tcomb's list, by definition, contains only values of the same type. You can define a union though:

const AccountType = t.enums.of([
  'type 1',
  'type 2',
  'other'
], 'AccountType')

const KnownAccount = t.struct({
  type: AccountType
}, 'KnownAccount')

// UnknownAccount extends KnownAccount so it owns also the type field
const UnknownAccount = KnownAccount.extend({
  label: t.String,
}, 'UnknownAccount')

// the union
const Account = t.union([KnownAccount, UnknownAccount], 'Account')

// the final form type
const Type = t.list(Account)

Generally tcomb's unions require a dispatch implementation in order to select the suitable type constructor for a given value and this would be the key in this use case:

// if account type is 'other' return the UnknownAccount type
Account.dispatch = value => value && value.type === 'other' ? UnknownAccount : KnownAccount

Customizations

Stylesheets

See also Stylesheet guide.

tcomb-form-native comes with a default style. You can customize the look and feel by setting another stylesheet:

var t = require('tcomb-form-native/lib');
var i18n = require('tcomb-form-native/lib/i18n/en');
var templates = require('tcomb-form-native/lib/templates/bootstrap');

// define a stylesheet (see lib/stylesheets/bootstrap for an example)
var stylesheet = {...};

// override globally the default stylesheet
t.form.Form.stylesheet = stylesheet;
// set defaults
t.form.Form.templates = templates;
t.form.Form.i18n = i18n;

You can also override the stylesheet locally for selected fields:

var Person = t.struct({
  name: t.String
});

var options = {
  fields: {
    name: {
      stylesheet: myCustomStylesheet
    }
  }
};

Or per form:

var Person = t.struct({
  name: t.String
});

var options = {
  stylesheet: myCustomStylesheet
};

For a complete example see the default stylesheet https://github.com/gcanti/tcomb-form-native/blob/master/lib/stylesheets/bootstrap.js.

Templates

tcomb-form-native comes with a default layout, i.e. a bunch of templates, one for each component. When changing the stylesheet is not enough, you can customize the layout by setting custom templates:

var t = require('tcomb-form-native/lib');
var i18n = require('tcomb-form-native/lib/i18n/en');
var stylesheet = require('tcomb-form-native/lib/stylesheets/bootstrap');

// define the templates (see lib/templates/bootstrap for an example)
var templates = {...};

// override globally the default layout
t.form.Form.templates = templates;
// set defaults
t.form.Form.stylesheet = stylesheet;
t.form.Form.i18n = i18n;

You can also override the template locally:

var Person = t.struct({
  name: t.String
});

function myCustomTemplate(locals) {

  var containerStyle = {...};
  var labelStyle = {...};
  var textboxStyle = {...};

  return (
    <View style={containerStyle}>
      <Text style={labelStyle}>{locals.label}</Text>
      <TextInput style={textboxStyle} />
    </View>
  );
}

var options = {
  fields: {
    name: {
      template: myCustomTemplate
    }
  }
};

A template is a function with the following signature:

(locals: Object) => ReactElement

where locals is an object contaning the "recipe" for rendering the input and it's built for you by tcomb-form-native. Let's see an example: the locals object passed in the checkbox template:

type Message = string | ReactElement

{
  stylesheet: Object, // the styles to be applied
  hasError: boolean,  // true if there is a validation error
  error: ?Message,    // the optional error message to be displayed
  label: Message,     // the label to be displayed
  help: ?Message,     // the optional help message to be displayed
  value: boolean,     // the current value of the checkbox
  onChange: Function, // the event handler to be called when the value changes
  config: Object,     // an optional object to pass configuration options to the new template

  ...other input options here...

}

For a complete example see the default template https://github.com/gcanti/tcomb-form-native/blob/master/lib/templates/bootstrap.

i18n

tcomb-form-native comes with a default internationalization (English). You can change it by setting another i18n object:

var t = require('tcomb-form-native/lib');
var templates = require('tcomb-form-native/lib/templates/bootstrap');

// define an object containing your translations (see tcomb-form-native/lib/i18n/en for an example)
var i18n = {...};

// override globally the default i18n
t.form.Form.i18n = i18n;
// set defaults
t.form.Form.templates = templates;
t.form.Form.stylesheet = stylesheet;

Transformers

Say you want a search textbox which accepts a list of keywords separated by spaces:

var Search = t.struct({
  search: t.list(t.String)
});

tcomb-form by default will render the search field as a list. In order to render a textbox you have to override the default behaviour with the factory option:

var options = {
  fields: {
    search: {
      factory: t.form.Textbox
    }
  }
};

There is a problem though: a textbox handle only strings so we need a way to transform a list in a string and a string in a list: a Transformer deals with serialization / deserialization of data and has the following interface:

var Transformer = t.struct({
  format: t.Function, // from value to string, it must be idempotent
  parse: t.Function   // from string to value
});

A basic transformer implementation for the search textbox:

var listTransformer = {
  format: function (value) {
    return Array.isArray(value) ? value.join(' ') : value;
  },
  parse: function (str) {
    return str ? str.split(' ') : [];
  }
};

Now you can handle lists using the transformer option:

// example of initial value
var value = {
  search: ['climbing', 'yosemite']
};

var options = {
  fields: {
    search: {
      factory: t.form.Textbox, // tell tcomb-react-native to use the same component for textboxes
      transformer: listTransformer,
      help: 'Keywords are separated by spaces'
    }
  }
};

Custom factories

You can pack together style, template (and transformers) in a custom component and then you can use it with the factory option:

var Component = t.form.Component;

// extend the base Component
class MyComponent extends Component {

  // this is the only required method to implement
  getTemplate() {
    // define here your custom template
    return function (locals) {

      //return ... jsx ...

    };
  }

  // you can optionally override the default getLocals method
  // it will provide the locals param to your template
  getLocals() {

    // in locals you'll find the default locals:
    // - path
    // - error
    // - hasError
    // - label
    // - onChange
    // - stylesheet
    var locals = super.getLocals();

    // add here your custom locals

    return locals;
  }


}

// as example of transformer: this is the default transformer for textboxes
MyComponent.transformer = {
  format: value => Nil.is(value) ? null : value,
  parse: value => (t.String.is(value) && value.trim() === '') || Nil.is(value) ? null : value
};

var Person = t.struct({
  name: t.String
});

var options = {
  fields: {
    name: {
      factory: MyComponent
    }
  }
};

Tests

npm test

Note: If you are using Jest, you will encounter an error which can be fixed w/ a small change to the package.json.

The error will look similiar to the following:

Error: Cannot find module './datepicker' from 'index.js' at
Resolver.resolveModule

A completely working example jest setup is shown below w/ the http://facebook.github.io/jest/docs/api.html#modulefileextensions-array-string fix added:

  "jest": {
    "setupEnvScriptFile": "./node_modules/react-native/jestSupport/env.js",
    "haste": {
      "defaultPlatform": "ios",
      "platforms": [
        "ios",
        "android"
      ],
      "providesModuleNodeModules": [
        "react-native"
      ]
    },
    "testPathIgnorePatterns": [
      "/node_modules/"
    ],
    "testFileExtensions": [
      "es6",
      "js"
    ],
    "moduleFileExtensions": [
      "js",
      "json",
      "es6",
      "ios.js"    <<<<<<<<<<<< this needs to be defined!
    ],
    "unmockedModulePathPatterns": [
      "react",
      "react-addons-test-utils",
      "react-native-router-flux",
      "promise",
      "source-map",
      "key-mirror",
      "immutable",
      "fetch",
      "redux",
      "redux-thunk",
      "fbjs"
    ],
    "collectCoverage": false,
    "verbose": true
    },

License

MIT

Comments
  • React Native Hot Reload breaks tcomb-form-native

    React Native Hot Reload breaks tcomb-form-native

    Version

    • tcomb-form-native: 0.4.0
    • react-native: 0.22.0-rc4

    Expected behaviour

    React Native 0.22 introduces Hot Reload and after a code change the hot reload behaviour should not break the plugin.

    Actual behaviour

    After a code change the plugin throws an error.

    Steps to reproduce

    1. New react native project
    2. Add a tcomb-form-native form
    3. Enabled Hot Reload in the app
    4. Make a change while the app is running

    Stack trace and console log

    The error that is thrown: [tcomb][tcomb-form-native] missing stylesheet config

    Additional information

    • The error is thrown in the Form.render method by the assert
    • The stylesheet variable is indeed undefined after a code change
    • The other asserts fail as well (templates and i18n)
    • Hot Reload works by wrapping components with a shell that can reloads its component, so somehow the assignments in the index.js file are ignored
    opened by justim 44
  • Remove unnecessary bottom border Android from default style

    Remove unnecessary bottom border Android from default style

    Version

    Tell us which versions you are using:

    • tcomb-form-native v0.6.1
    • react-native v0.34.0

    Every TextInput has unnecessary bottom border after RN34

    https://github.com/facebook/react-native/issues/10108

    input

    we should set underlineColorAndroid='transparent' as the default

    opened by sibelius 24
  • Jest tests are broken: Error: Cannot find module './datepicker' from 'index.js'

    Jest tests are broken: Error: Cannot find module './datepicker' from 'index.js'

    Version

    Tell us which versions you are using:

    • tcomb-form-native v0.4.0
    • react-native v0.22.2

    Expected behaviour

    Tests should pass as they used to!

    Actual behaviour

    Error: Cannot find module './datepicker' from 'index.js'

    Steps to reproduce

    1. git clone [email protected]:bartonhammond/snowflake.git
    2. npm3 install
    3. npm3 test
      ✓ it if disabled and not checked, it should display square-o and text
    
     FAIL  src/components/__tests__/LoginForm-test.js
    Runtime Error
    Error: Cannot find module './datepicker' from 'index.js'
        at Loader._resolveNodeModule (/Users/barton/projects/MFV/snowflake/node_modules/jest-cli/src/HasteModuleLoader/HasteModuleLoader.js:431:11)
        at Object.<anonymous> (/Users/barton/projects/MFV/snowflake/node_modules/tcomb-form-native/lib/templates/bootstrap/index.js:5:12)
        at Object.<anonymous> (/Users/barton/projects/MFV/snowflake/node_modules/tcomb-form-native/index.js:3:15)
    1 test suite failed, 74 tests passed (74 total in 11 test suites, run time 7.245s)
    
    Type: Docs 
    opened by bartonhammond 23
  • Build fails in RN 0.21 with Error

    Build fails in RN 0.21 with Error "Failed to build DependencyGraph: Naming collision detected "

    Naming collision detected: /Users/NAME/React-Native/PROJECT/node_modules/react-native/Libraries/StyleSheet/ColorPropType.js collides with /Users/NAME/React-Native/PROJECT/node_modules/tcomb-form-native/node_modules/react-native/Libraries/StyleSheet/ColorPropType.js

    Status: Completed 
    opened by iZaL 19
  • add support for lists, ref #80

    add support for lists, ref #80

    This adds support for lists.

    Builds on my previous PR https://github.com/gcanti/tcomb-form-native/pull/172

    It's a direct porting of the same tcomb-form feature, this means you can handle lists of strings, lists of structs, lists of lists, lists of unions of lists of structs... etc etc etc :)

    The engine (the List component in components.js) should be ok, but I need some help with the default template: I put up a bare and ugly one, just for having something to show.

    I'm a web developer :) when it comes to mobile development and RN it's better having someone more experienced than me to jump in and change the code.

    opened by gcanti 18
  • closes #132 Solves HMR issue by assigning props to the Form class

    closes #132 Solves HMR issue by assigning props to the Form class

    ...as suggested in the issue.

    Tests doesn't pass because of https://github.com/gcanti/tcomb-form-native/issues/134. Can be tested by changing from require('./datepicker') to require('./datepicker.ios.js').

    opened by alvaromb 18
  • Looses input values when the keyboard is closed (Android)

    Looses input values when the keyboard is closed (Android)

    Version

    Tell us which versions you are using:

    • tcomb-form-native v0.6.11
    • react-native v0.54.2

    Expected behaviour

    I expected that the values in the input form will be retained

    Actual behaviour

    It looses the input values when the keyboard is closed

    Steps to reproduce

    1. Test on android and close the keyboard before submitting the form

    Stack trace and console log

    No error is seen

    Hint: it would help a lot if you enable the debugger ("Pause on exceptions" in the "Source" panel of Chrome dev tools) and spot the place where the error is thrown

    opened by joshuachinemezu 15
  • Close iOS Select when selection is made

    Close iOS Select when selection is made

    @alvaromb mentioned he'd take a pull request for this in #265 Currently, when presenting an enum in the form the default template provides a Picker on iOS. This picker stays open after the user selects an option instead of automatically closing.

    This pull request closes the picker 500ms after the user stops interacting with the Picker. It detects pans on the View surrounding the Picker to ensure it doesn't close if the user is still panning the Picker after a selection is made, be it they are scrolling lower in the list or simply hovering over options.

    opened by zolrath 15
  • Feature: Wrap TextInput in a View for More Customizable Styling

    Feature: Wrap TextInput in a View for More Customizable Styling

    This makes material design styling of textboxes achievable through stylesheets.

    Without this, you must implement a template to render a textbox with an underline.*

    This will allow customization of the border.

    The reason this is necessary is because in React Native the TextInput component does not respect these granular border style declarations, they currently are recommending wrapping the TextInput in a View.

    Related Issue: #37

    * assuming you want the error to be under the underline

    opened by kenleezle 14
  • Update components for React Native 0.25

    Update components for React Native 0.25

    Removes deprecation warning when using React Native 0.25.

    From the release notes:

    Requiring React API from react-native is now deprecated - 2eafcd4 0b534d1

    opened by jebschiefer 14
  • Set `accessibilityLabel` attributes on form controls

    Set `accessibilityLabel` attributes on form controls

    Version

    Tell us which versions you are using:

    • tcomb-form-native v0.4.0
    • react-native v0.22.2

    Expected behaviour

    Tell us what should happen

    As a blind developer, I should be able to hear my screen reader read the text labels associated with fields.

    Actual behaviour

    Tell us what happens instead

    Field labels aren't read, as seems to be indicated by the README should happen.

    Steps to reproduce

    1. Launch TalkBack (or presumably VoiceOver.)
    2. Use a form.
    3. Touch a text field.

    This can likely be solved by setting the accessibleLabel attribute on form controls to the text of their associated labels. Should be easy to do this programatically since you're generating the label already.

    https://facebook.github.io/react-native/docs/accessibility.html

    For bonus points, set up a live region for form validation errors on Android so they are read out automatically. :)

    Thanks, love working with this library.

    Type: Enhancement 
    opened by ndarilek 14
  • feat(picker): import picker from community lib

    feat(picker): import picker from community lib

    Picker component does not exist on react-native lts version > 0.66. It must be imported from react-native-picker/picker library. For now on, this picker community lib must be installed in the project.

    opened by feliciovcm 8
  • react native t comb form ERROR Warning: Component

    react native t comb form ERROR Warning: Component "Textbox" contains the string ref "input". React.createRef()

    Version

    Tell us which versions you are using:

    • tcomb-form-native ^0.6.20
    • react-native v0.64.0

    Expected behaviour

    Here my SO question: https://stackoverflow.com/questions/67244411/react-native-t-comb-form-error-string-ref-input-react-createref

    I can edit this issue / question if it is not well explained. This is my first time submitting an issue :)

    opened by hoerlanton 2
  • how to add  BUTTON IN BETWEEN the form fields

    how to add BUTTON IN BETWEEN the form fields

    Version

    Tell us which versions you are using:

    • tcomb-form-native v0.?.?
    • react-native v0.?.?

    Expected behaviour

    Tell us what should happen

    Actual behaviour

    Tell us what happens instead

    Steps to reproduce

    Stack trace and console log

    Hint: it would help a lot if you enable the debugger ("Pause on exceptions" in the "Source" panel of Chrome dev tools) and spot the place where the error is thrown

    opened by prateekpareek 0
  • custom stylesheets does not apply to optional field title

    custom stylesheets does not apply to optional field title

    Version

    Tell us which versions you are using:

    • tcomb-form-native v0.6.20
    • react-native v0.63.4

    Expected behaviour

    I changed the color of controlLabel normal. it applies to all field titles except optional field

    Actual behaviour

    Steps to reproduce

    My custom stylesheet:

    const Form = t.form.Form;
      const formStyles = {
        ...Form.stylesheet,
        formGroup: {
          normal: {
            marginBottom: 10
          },
        },
        controlLabel: {
          normal: {
            color: 'purple',
            fontSize: 18,
            marginBottom: 7,
            fontWeight: '500'
          },
          optional: {
            color: 'purple',
            fontSize: 18,
            marginBottom: 7,
            fontWeight: '500'
          },
          // the style applied when a validation error occours
          error: {
            color: 'red',
            fontSize: 18,
            marginBottom: 7,
            fontWeight: '300'
          }
        }
      }
    ![Simulator Screen Shot - iPhone 11 - 2020-12-29 at 22 31 34](https://user-images.githubusercontent.com/19432914/103330100-a2c50b80-4a25-11eb-8e3b-12ebf78ecd3a.png)
    
    
    
    opened by lekeCoder 0
  • iOS 14: Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`

    iOS 14: Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`

    Version

    Tell us which versions you are using:

    • tcomb-form-native v0.6.20
    • react-native v0.62.2

    Expected behaviour

    Clicking an enum picker should show a picker component for the user to choose.

    Actual behaviour

    Clicking a enum picker gives the message:

    Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`
    

    This in iOS 14, and the picker doesn't show. I works for Android 28.

    Steps to reproduce

    Create a form with a field based on a t.enum, try to click in the resulting field.

    Stack trace and console log

    Animated: `useNativeDriver` was not specified. This is a required option and must be explicitly set to `true` or `false`
    * [native code]:null in __expoConsoleLog
    - node_modules/react-native/Libraries/LogBox/LogBox.js:36:4 in console.warn
    - node_modules/expo/build/environment/muteWarnings.fx.js:18:4 in warn
    - node_modules/react-native/Libraries/Animated/src/NativeAnimatedHelper.js:281:4 in shouldUseNativeDriver
    - node_modules/react-native/Libraries/Animated/src/animations/TimingAnimation.js:73:49 in constructor
    - node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:210:26 in start
    - node_modules/react-native/Libraries/Animated/src/AnimatedImplementation.js:217:13 in start
    * http://REDACTED:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:475994:34 in _animatePicker
    * [native code]:null in _animatePicker
    * http://REDACTED:19001/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&minify=false&hot=false:476004:30 in <unknown>
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:7669:2 in callCallback
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:7710:18 in commitUpdateEffects
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:7698:21 in commitUpdateQueue
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:18213:25 in commitLifeCycles
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21528:22 in commitLayoutEffects
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:286:4 in invokeGuardedCallbackImpl
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:497:2 in invokeGuardedCallback
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21267:29 in commitRootImpl
    * [native code]:null in commitRootImpl
    - node_modules/scheduler/cjs/scheduler.development.js:818:23 in unstable_runWithPriority
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:21109:17 in commitRoot
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20514:12 in finishSyncRender
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20493:24 in performSyncWorkOnRoot
    * [native code]:null in performSyncWorkOnRoot
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5703:31 in runWithPriority$argument_1
    - node_modules/scheduler/cjs/scheduler.development.js:818:23 in unstable_runWithPriority
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5698:21 in flushSyncCallbackQueueImpl
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:5686:28 in flushSyncCallbackQueue
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:20575:28 in batchedUpdates$1
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:2731:29 in batchedUpdates
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:2834:16 in _receiveRootNodeIDEvent
    - node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-dev.js:2911:27 in receiveTouches
    - node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:425:19 in __callFunction
    - node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:6 in __guard$argument_0
    - node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:373:10 in __guard
    - node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:111:4 in callFunctionReturnFlushedQueue
    * [native code]:null in callFunctionReturnFlushedQueue
    
    opened by xnaveira 0
Releases(v0.6.19)
  • v0.6.19(Sep 28, 2018)

  • v0.6.18(Sep 27, 2018)

    • Bug fix
      • Fix placeholder labels #531 (@tonycoco)
      • Some spelling fixes #534 (@RocketStormNet)
    • Props
      • Adds textContentType Local #528 (@tonycoco)
    Source code(tar.gz)
    Source code(zip)
  • v0.6.17(Sep 21, 2018)

    • Bug fix
      • Fix Material Design textboxView marginBottom #452 (@piranna)
      • Handle label option with i18n #475 (@elsifaka)
      • Reverted part of #483 due to arising bugs when locals change. Migrated from controlled-uncontrolled antipattern #527 (@alvaromb)
    • Props
      • Update datepicker.android.js #503 (@chenzhenjia)
      • Added testid to switch and textbox #525 (@kevinhury)
    Source code(tar.gz)
    Source code(zip)
  • v0.6.16(Aug 31, 2018)

    • Bug fix
      • Remove underlineColorAndroid #520 (@Moreno97)
    • Props
      • Added allowFontScaling as an option for TextBox #513 (@thomaschen)
    • Docs
      • Add docs about mode option in Date type's example #519 (@tibuurcio)
    Source code(tar.gz)
    Source code(zip)
  • v0.6.15(Jul 12, 2018)

  • v0.6.14(Jun 29, 2018)

  • v0.6.13(May 25, 2018)

  • v0.6.12(May 18, 2018)

    • New Feature
      • Added the ability to not have a default value in DatePickers: https://github.com/gcanti/tcomb-form-native/pull/484 (@alvaromb)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.11(Oct 18, 2017)

  • 0.6.10(Sep 22, 2017)

    • New Feature
      • add pureValidate method on Form (@papuaaaaaaa)
      • add option to change dialog mode for DatePickerAndroid (@javiercr)
      • add onPress handler for DatePicker (@koenpunt)
    • Bug fix
      • remove checkbox label when auto === 'none' (@OzoTek)
    • Polish
      • fix broken link in README (@Hitabis)
      • add version support table, closes #248 (@alvaromb)
      • updated React to 15.6.1 and added PropTypes Dependency (@garylesueur)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.9(Jun 9, 2017)

  • 0.6.8(May 3, 2017)

    • New Feature
      • allow disabling datepicker by passing disabled prop to touchableopacity we can disable the datepicker (@koenpunt)
    • Bug fix
      • Add proper border color to select.ios when there is an error, fix #342 (@javiercr)
    Source code(tar.gz)
    Source code(zip)
  • 0.6.7(Mar 8, 2017)

  • v0.6.6(Feb 28, 2017)

  • v0.6.5(Feb 20, 2017)

  • v0.6.4(Jan 12, 2017)

  • v0.6.3(Dec 20, 2016)

  • v0.6.2(Dec 20, 2016)

  • v0.6.1(Aug 17, 2016)

  • v0.6.0(Jul 26, 2016)

  • v0.5.3(Jul 11, 2016)

  • v0.5.2(Jul 10, 2016)

    • New Feature
      • add support for unions, fix #118 (@gcanti)
      • add support for lists, fix #80 (@gcanti)
      • Number keypad should show for numeric fields, fix #171 (@gcanti)
    • Bug Fix
      • allow to set a default value in Android date picker template, fix #187
    Source code(tar.gz)
    Source code(zip)
  • v0.5.1(May 27, 2016)

  • v0.5.0(May 23, 2016)

    • Breaking Change
      • upgrade to tcomb-validation ^3.0.0 (@gcanti)
      • React API must be now required from react package (@jebschiefer)
    • New Feature
      • Updated support for TextInput props for RN>=0.25 (@alvaromb)
    Source code(tar.gz)
    Source code(zip)
  • v0.4.4(May 10, 2016)

  • v0.4.3(May 10, 2016)

  • v0.4.2(Apr 13, 2016)

  • v0.4.1(Apr 12, 2016)

  • v0.4.0(Feb 28, 2016)

    • Breaking Change
      • required react-native version >= 0.20.0
    • New Feature
      • add support for Switch (Android), fix #60 (thanks @alvaromb)
      • Support for Android date and time pickers, fix #67 (thanks @alvaromb)
      • add support for webpack, fix #23
    • Documentation
      • How to clear form after submit (thanks @shashi-dokania)
      • Dynamic forms example: how to change a form based on selection
      • Stylesheet guide (docs/STYLESHEET.md)
    • Polish
      • add travis CI
      • add ISSUE_TEMPLATE.md (new GitHub feature)
    Source code(tar.gz)
    Source code(zip)
  • v0.3.3(Dec 9, 2015)

Owner
Giulio Canti
mathematician and rock climber
Giulio Canti
📋 React Hooks for forms validation (Web + React Native)

Version 7 | Version 6 English | 日本語 Features Built with performance, UX and DX in mind Embraces native form validation Out of the box integration with

React Hook Form 32.6k Jan 8, 2023
Easy react-native forms using bootstrap-like syntax with redux-form+immutablejs integration. Styled using styled-components

react-native-clean-form Easy react-native forms using bootstrap-like syntax with redux-form+immutablejs integration. Styled using styled-components Bi

Esben Petersen 475 Oct 30, 2022
Generate forms with native look and feel in a breeze

React Native Form Generator Generate forms with native look and feel in a breeze Components Picker DatePicker TimePicker Input Link Separator Switch F

Michael Cereda 375 Dec 7, 2022
Build forms in React, without the tears 😭

Build forms in React, without the tears. Visit https://formik.org to get started with Formik. Organizations and projects using Formik List of organiza

Formium 31.7k Dec 31, 2022
Angular like reactive forms in React.

React Reactive Forms It's a library inspired by the Angular's Reactive Forms, which allows to create a tree of form control objects in the component c

Kuldeep Saxena 290 Nov 26, 2022
React component for convert the valle screens-api data structure to web component based forms.

valleForm React component for convert the valle screens-api data structure to web component based forms. Write <valleForm tabs = { [...] } but

Valle Sistemas de Gestão 7 Dec 16, 2021
Handle your forms in a smart way

react-native-form-builder Note: If you're looking for a better form management library with more advanced features, Please check out React Reactive Fo

Kuldeep Saxena 117 Jul 24, 2022
Simple form validation library for React Native.

Foect Simple form validation library for React Native. Installing Npm npm i --save foect Yarn yarn add foect Quick Start import { TextInput, Text, V

null 38 Nov 11, 2022
A simple validation library for react native

react-native-form-validator A simple validation library for react native Installation Run: $ npm i react-native-validation --save Validators: matchReg

Şerafettin Aytekin 14 Mar 25, 2021
A Formik inspired form library that uses MobX under the hood

Formix A Formik inspired form library that uses MobX under the hood and update only the changed fields. Installation Using npm: npm install @euk-labs/

Shoulders 6 Dec 29, 2021
📝 Form component for React Native.

Gifted Form Form component for React Native. Example var { GiftedForm, GiftedFormManager } = require('react-native-gifted-form'); var FormComponent =

Farid Safi 1.4k Dec 19, 2022
A simple react-native component to wrap your form fields and get their values with just one single method.

react-native-form A simple react-native component to wrap your form fields and get their values without attaching listeners everywhere. Installation n

Juliano Duarte 145 Nov 11, 2022
FM Form is a module for React Native to fast generate pages with a form.

react-native-fm-form FM Form is a module for React Native to fast generate pages with a form. It works like Backbone forms. Using this module you can

Yi Wang 13 Dec 9, 2021
Project using React Router, Styled Components, useEffect, useState and context

Before run do the steps bellow install npm or yarn To run this application you can just use npm or if you want, yarn is another option. Download NPM I

Guilherme Mello 0 Dec 29, 2021
React library for rendering forms.

Data Driven Forms is a React library used for rendering and managing forms with a lot of provided features based on React Final Form. ❓ Why to use Dat

Data driven forms 235 Jan 3, 2023
A React library for building forms from any schema.

A set of React libraries for building forms from every schema.

Vazco 1.7k Jan 4, 2023
react-hook-form is an awsome library which provide a neat solution for building forms.

react-hook-form is an awsome library which provide a neat solution for building forms. However, there are many rules for the API which may be missed by the developer. This plugin aims to check those rules automatically thourgh ESLint. Thus brings better DX for react-hook-form.

Chuan-Tse Kao 37 Nov 22, 2022
Formst is a model-driven library for quickly building high-performance forms in React.

Formst is a model-driven library for quickly building high-performance forms in React. Unlike most form libraries that are UI-First, Formst is Data-First.

null 92 Jun 8, 2022
A bare minimal React form library for quick & simple forms.

React library using React Hooks to build forms & let you switch in & out Bootstrap 4 styling. React Bare Forms aka RBF aims to be the easiest to use f

Joe Gasewicz 17 Nov 22, 2022
A React library for rendering out forms based on the Form.io platform

React Formio A React library for rendering out forms based on the Form.io platform. Example Application To see an example application of how to implem

Form.io 225 Jan 6, 2023