yarn add @react-spectre/form
npm install @react-spectre/form --save
There are 7 components exported for form: FormGroup
, Input
, TextArea
, Select
, Radio
, CheckBox
and Switch
.
import { FormGroup, Input, TextArea, Select, Radio, CheckBox, Switch } from '@react-spectre/form'
A form group is a wrapper for form controls.
<FormGroup label="Name">
<Input />
</FormGroup>
<Input /> // Default type="text"
<Input type="email" />
<TextArea />
<TextArea rows="3" />
<Select>
<option>Choose an option</option>
<option>Slack</option>
<option>Skype</option>
<option>Hipcat</option>
</Select>
<Select multiple>
<option>Choose an option</option>
<option>Slack</option>
<option>Skype</option>
<option>Hipcat</option>
</Select>
<FormGroup label="Genre">
<Radio label="Male" name="genre" defaultChecked>
<Radio label="Female" name="genre">
</FormGroup>
<FormGroup>
<CheckBox label="Remember me">
<CheckBox label="Remember me" defaultChecked>
</FormGroup>
<FormGroup>
<Switch label="Send me emails with news and tips">
<Switch label="Send me emails with news and tips" defaultChecked>
</FormGroup>