--- title: "Form Field" slug: form-field category: component type: documentation version: 20.0.0 tokens: 990 source: https://ovh.github.io/design-system/v20.0.0/llms/react-components-form-field--documentation.txt --- # Form Field _A **Form Field** component is used to wrap several form components with logic, visual hints and additional styling_ ## Overview Form Guidelines] } figmaLink="https://www.figma.com/design/9jDDTcR4a9jPRFcdjawAlf/ODS---UI-Kit?node-id=172-11996" githubUrl="https://github.com/ovh/design-system/tree/master/packages/ods-react/src/components/form-field" name="Form Field"> A **Form Field** is based on a single form element or group components as a whole that are decorated with additional text to handle specific types of information, like a Password field for example. | | | |---|---| | Name | undefined | | Also known as | Form Control | ## Usage A **Form Field** is used to wrap a field that can be customized with some additional information about this field. Additional information (label, placeholder, helper message) provides hint and help to users, so that they can easily understand what is required from them in a form. Users will also type or enter information in the expected format and avoid mistakes. ### Dos & Don'ts **Do** - Use Form Field to wrap form inputs with a clear structure, including a label, optional helper text, or extra information - Group related fields using multiple Form Fields to improve clarity and scannability - Include helper messages to guide users on expected input formats or constraints (e.g., password requirements) - Use error message to provide feedback after user interaction **Don't** - Don't place interactive elements like links or buttons inside the label - Don't rely on an asterisk alone to indicate required fields. Prefer explicit helper text or label - Overuse content related Form Fields with top aligned label in one group since it requires quite vertical space: split into smaller groups - Don't use Form Field when there's no input or interaction expected. It is meant for form inputs, not static content ### Best Practices in Context 1. **Form Field** 2. **Label** - optional 3. **Form element** 4. **Helper message** - optional 5. **Error message** - optional 6. **Hint text** - optional ## Placement A **Form Field** can be used everywhere in a page where there is a form and users may need help to fill in this form. ## Behavior A **Form Field** can react to validation states, such as error, often by visually updating elements like the border or text indicators. Helper text and error messages can be displayed freely around the field component, depending on the design or functional needs. ## Navigation The **Form Field** component itself is not focusable and does not receive keyboard focus. Only the interactive inner component it wraps, such as an Input, Password, Select, or other form element, can receive focus. Focus behavior and keyboard navigation are determined by the specific form element used within the **Form Field**. ## Accessibility The **Form Field** component handles by itself the accessibility requirements by using its internal components. ```tsx Login: Username or email address ``` Screen readers will announce the label, the field, its content and the helper text. ### Field id You don't need to set any id: the **Form Field** gives one to the field it wraps, then links the label, the helper text and the error message to it. When you need a specific id (for an anchor, an end-to-end test or an external reference), set it either on the **Form Field** or directly on the field. An id set on the field takes precedence, and the label follows it: ```tsx Email: {/* The label targets "email" */} ``` **Radio Group** and **Range** have no single element for the label to target: the label names the radio group, or each thumb of the range, instead.