packages/grafana-ui/src/components/Forms/Field.mdx
import { Meta, ArgTypes } from '@storybook/blocks'; import { Field } from './Field'; import { Input } from '../Input/Input'; import { ExampleFrame } from '../../utils/storybook/ExampleFrame';
<Meta title="MDX|Field" component={Field} />Field is the basic component for rendering form elements together with labels and description.
The Field component is suitable for various scenarios where you need to incorporate form inputs into your application. Some common use cases include:
Note that the Field component will pass the invalid, disabled and loading props, unless they are undefined, to the child component, which will override those props if they are set on the child component.
description prop without also providing a label.invalid prop without also providing an error message.Use the invalid prop to indicate that the input is invalid. This will add a red border to the input and display the error message provided in the error prop. For this to work, both the invalid and error props must be set.
Use the loading prop to indicate that the input is loading. This will add a spinner to the input.