UNPKG

1.69 kBTypeScriptView Raw
1import { PolymorphicComponent } from '../utils/PolymorphicComponent';
2import { FormControlTypeMap } from './FormControl.types';
3/**
4 * Provides context such as filled/focused/error/required for form inputs.
5 * Relying on the context provides high flexibility and ensures that the state always stays
6 * consistent across the children of the `FormControl`.
7 * This context is used by the following components:
8 *
9 * * FormLabel
10 * * FormHelperText
11 * * Input
12 * * InputLabel
13 *
14 * You can find one composition example below and more going to [the demos](https://mui.com/material-ui/react-text-field/#components).
15 *
16 * ```jsx
17 * <FormControl>
18 * <InputLabel htmlFor="my-input">Email address</InputLabel>
19 * <Input id="my-input" aria-describedby="my-helper-text" />
20 * <FormHelperText id="my-helper-text">We'll never share your email.</FormHelperText>
21 * </FormControl>
22 * ```
23 *
24 * ⚠️ Only one `Input` can be used within a FormControl because it create visual inconsistencies.
25 * For instance, only one input can be focused at the same time, the state shouldn't be shared.
26 *
27 * Demos:
28 *
29 * - [Form Control](https://mui.com/base/react-form-control/)
30 * - [Input](https://mui.com/joy-ui/react-input/)
31 * - [Checkbox](https://mui.com/material-ui/react-checkbox/)
32 * - [Radio Group](https://mui.com/material-ui/react-radio-button/)
33 * - [Switch](https://mui.com/material-ui/react-switch/)
34 * - [Text Field](https://mui.com/material-ui/react-text-field/)
35 *
36 * API:
37 *
38 * - [FormControl API](https://mui.com/base/react-form-control/components-api/#form-control)
39 */
40declare const FormControl: PolymorphicComponent<FormControlTypeMap<{}, "div">>;
41export default FormControl;