<Form>
is a container which displays a set of related user input fields in a structured way. It can contain one or more of the following form components:
<TextField>
<MultilineTextField>
<Checkbox>
<Radio>
<RadioGroup>
<Switch>
<Select>
<Dropdown>
The component supports different type of layouts which can be specified through the layoutType
prop.
Usage
import { Form } from 'nr1'
Examples
Default layout
<Form> <TextField placeholder="AAA Production" label="Name" /> <Select label="Select account"> <SelectItem>Option 1</SelectItem> <SelectItem>Option 2</SelectItem> </Select> <TextField defaultValue="help-production-db" label="Help channel" invalid="Please enter a valid slack channel" /> <MultilineTextField label="Description" info="Info tooltip" placeholder="Placeholder text" /> <Button type={Button.TYPE.PRIMARY} sizeType={Button.SIZE_TYPE.SMALL} spacingType={[ HeadingText.SPACING_TYPE.EXTRA_LARGE, HeadingText.SPACING_TYPE.NONE, ]} > Create dashboard </Button></Form>
Split layout
<Form layoutType={Form.LAYOUT_TYPE.SPLIT}> <TextField placeholder="AAA Production" label="Name" /> <Select label="Select account"> <SelectItem>Option 1</SelectItem> <SelectItem>Option 2</SelectItem> </Select> <TextField defaultValue="help-production-db" label="Help channel" invalid="Please enter a valid slack channel" /> <MultilineTextField label="Description" info="Info tooltip" placeholder="Placeholder text" /> <Button type={Button.TYPE.PRIMARY} sizeType={Button.SIZE_TYPE.SMALL} spacingType={[ HeadingText.SPACING_TYPE.EXTRA_LARGE, HeadingText.SPACING_TYPE.NONE, ]} > Create dashboard </Button></Form>
Split layout with size type
<Form layoutType={Form.LAYOUT_TYPE.SPLIT} splitSizeType={Form.SPLIT_SIZE_TYPE.LARGE}> <TextField placeholder="AAA Production" label="Name" /> <Select label="Select account"> <SelectItem>Option 1</SelectItem> <SelectItem>Option 2</SelectItem> </Select> <TextField defaultValue="help-production-db" label="Help channel" invalid="Please enter a valid slack channel" /> <MultilineTextField label="Description" info="Info tooltip" placeholder="Placeholder text" /> <Button type={Button.TYPE.PRIMARY} sizeType={Button.SIZE_TYPE.SMALL} spacingType={[ HeadingText.SPACING_TYPE.EXTRA_LARGE, HeadingText.SPACING_TYPE.NONE, ]} > Create dashboard </Button></Form>
Form with required fields
<Form> <TextField required placeholder="AAA Production" label="Name" /> <TextField defaultValue="help-production-db" label="Help channel" /> <MultilineTextField label="Description" info="Info tooltip" placeholder="Placeholder text" /> <Button type={Button.TYPE.PRIMARY} sizeType={Button.SIZE_TYPE.SMALL} spacingType={[ HeadingText.SPACING_TYPE.EXTRA_LARGE, HeadingText.SPACING_TYPE.NONE, ]} > Create dashboard </Button></Form>
Props
node | Form fields to display. |
string | Appends class names to the component.Should be used only for positioning and spacing purposes. |
enum | Layout of the form:
|
enum[] | Spacing property. Spacing is defined as a tuple of zero to four values, which follow the same conventions as CSS properties like <Array of |
enum | Specifies the size of the columns when using the split layout.
|
object | Inline style for custom styling.Should be used only for positioning and spacing purposes. |
string | Adds a |