Following on from the discussion in #35, this issue is to clarify our intent for this.
We would like to expose a FormGroup component so that it can be used by library consumers, so that all the boiler plate and logic for error styles, hint text etc can be encapsulated and easily reused. This will help us in Forms so that we can focus on our custom components and not repeat all the boiler plate.
There is some complexity here as the existing FormGroup component was not designed to be exposed and it accepts a function instead of child components in the usual way.
The goal is to have syntax like this:
import React from "react";
import { FormGroup, Input } from "nhsuk-react-components";
const ExampleUsage = () => (
<FormGroup>
<Input hint="Test Hint" label="Test Label" />
<a href="/somewhere-else">Don't have a number?</a>
</FormGroup>
);
Emit something like this:
<div class="nhsuk-form-group">
<label class="nhsuk-label">Test Label</label>
<span class="nhsuk-hint">Test Hint</span>
<input />
<a href="/somewhere-else">Don't have a number?</a>
</div>
The new / exposed FormGroup should support at least the following props (and associated functionality):
hint
label
error
Questions
- Should we also support
disableErrorLine?
- What else is included with
labelProps, hintProps, errorProps and formGroupProps, and should we support them?
Fyi. Forms team, we're tracking this in Jira as WBFCD-399.
@Tomdango anything else to add?
@ramyas16 ping
Following on from the discussion in #35, this issue is to clarify our intent for this.
We would like to expose a
FormGroupcomponent so that it can be used by library consumers, so that all the boiler plate and logic for error styles, hint text etc can be encapsulated and easily reused. This will help us in Forms so that we can focus on our custom components and not repeat all the boiler plate.There is some complexity here as the existing
FormGroupcomponent was not designed to be exposed and it accepts a function instead of child components in the usual way.The goal is to have syntax like this:
Emit something like this:
The new / exposed
FormGroupshould support at least the following props (and associated functionality):hintlabelerrorQuestions
disableErrorLine?labelProps,hintProps,errorPropsandformGroupProps, and should we support them?Fyi. Forms team, we're tracking this in Jira as WBFCD-399.
@Tomdango anything else to add?
@ramyas16 ping