Castle UI provides visual components to help you build forms in an extensible way.
Usage
Import
import {
FormControl,
FormLabel,
FormHint,
FormError,
Input,
} from '@passfort/castle'
Basic Field
<FormControl isRequired>
<FormLabel>Name</FormLabel>
<Input />
<FormHint>Your legal name</FormHint>
</FormControl>
live example
Invalid
<FormControl isInvalid isRequired>
<FormLabel>Name</FormLabel>
<Input value={1} />
<FormError>Name cannot be a number.</FormError>
</FormControl>
live example
Input Group
Useful for connecting two inputs together. Use the flex
property to adjust the sizes of different inputs.
import { InputGroup } from '@passfort/castle'
<InputGroup>
<Input flex={3} value={1} />
<HTMLSelect flex={2}>
<option value="option1">Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</HTMLSelect>
</InputGroup>
live example
Form Controls
Wrapper component to list FormControls
import { FormControl, FormControls } from '@passfort/castle'
<FormControls>
<FormControl isRequired>
<FormLabel>Name</FormLabel>
<Input />
<FormHint>Your legal name</FormHint>
</FormControl>
<InputGroup>
<FormControl flex={2} isRequired>
<FormLabel>National ID</FormLabel>
<Input />
</FormControl>
<FormControl isRequired>
<FormLabel>Country</FormLabel>
<Input />
</FormControl>
</InputGroup>
</FormControls>
live example
Required Label
<FormControl requiredLabel="erforderlich" isRequired>
<FormLabel>Name</FormLabel>
<Input />
<FormHint>Your legal name</FormHint>
</FormControl>
live example