-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Form component #409
Add Form component #409
Conversation
This reverts commit 04e877a.
c19a71d simplifies the component structure:
This component is a convenience, that simply enables the user to import the RAC Form component without needing to add an additional dependency. With that, I think this is ready for review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great addition! 🚀 Just one small change to the MDX file to make the code sample more readable.
When testing this component, I find the HTML validation is super easy to use. Features like passing type="email"
to an input field or type="reset"
to a button just work.
Example:
<Form>
<TextField label="Name" isRequired />
<TextField type="email" label="Email" isRequired />
<Select
label="Employment status"
items={[
{ id: "employee", label: "Employee" },
{ id: "contractor", label: "Contractor" },
]}
isRequired
/>
<Button type="submit" variant="primary">
Submit
</Button>
<Button type="reset" variant="secondary">
Reset
</Button>
</Form>
After interacting with each field:
|
||
### CSS for this example form | ||
|
||
<Source |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 78cf1c9!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cherry-picked from #401 so that we can test with new components. Scope of this PR is the same:
This PR adds a new Form component, based on RAC Form. An example instance and documentation page in Storybook is also included.
The Form component is intended to be used as a wrapper around other components, to provide additional support for data validation and submission and form styling. It renders an HTML
<form>
element.By default, the Form component renders without any styling of its own. The
className
prop can be used to style the form as a whole.Some boilerplate CSS is included (see Form.css). This is currently only used to style the example form in Storybook.