diff --git a/packages/grafana-ui/src/components/Forms/Form.mdx b/packages/grafana-ui/src/components/Forms/Form.mdx
index 417eb7c4105..cff858a9d4f 100644
--- a/packages/grafana-ui/src/components/Forms/Form.mdx
+++ b/packages/grafana-ui/src/components/Forms/Form.mdx
@@ -1,5 +1,5 @@
-import { Meta, Props } from "@storybook/addon-docs/blocks";
-import { Form } from "./Form";
+import { Meta, Props } from '@storybook/addon-docs/blocks';
+import { Form } from './Form';
@@ -9,7 +9,7 @@ Form component provides a way to build simple forms at Grafana. It is built on t
## Usage
-```jsx
+```tsx
import { Forms } from '@grafana/ui';
interface UserDTO {
@@ -46,7 +46,7 @@ const defaultUser: Partial = {
`register` allows registering form elements (inputs, selects, radios, etc) in the form. In order to do that you need to invoke the function itself and spread the props into the input. For example:
```jsx
-
+
```
The first argument for `register` is the field name. It also accepts an object, which describes validation rules for a given input:
@@ -264,17 +264,23 @@ validateAsync = (newValue: string) => {
```
### Upgrading to v8
+
Version 8 of Grafana-UI is using version 7 of `react-hook-form` (previously version 5 was used), which introduced a few breaking changes to the `Form` API. The detailed list of changes can be found in the library's migration guides:
+
- [Migration guide v5 to v6](https://react-hook-form.com/migrate-v5-to-v6/)
- [Migration guide v6 to v7](https://react-hook-form.com/migrate-v6-to-v7/)
In a nutshell, the two most important changes are:
+
- register method is no longer passed as a `ref`, but instead its result is spread onto the input component:
+
```jsx
-
+
```
-- `InputControl`'s `as` prop has been replaced with `render`, which has `field` and `fieldState` objects as arguments. `onChange`, `onBlur`, `value`, `name`, and `ref` are parts of `field`.
+
+- `InputControl`'s `as` prop has been replaced with `render`, which has `field` and `fieldState` objects as arguments. `onChange`, `onBlur`, `value`, `name`, and `ref` are parts of `field`.
+
```jsx
- } />
+ }
@@ -282,7 +288,6 @@ In a nutshell, the two most important changes are:
+ } />
```
-
### Props
diff --git a/packages/grafana-ui/src/components/Forms/InlineField.mdx b/packages/grafana-ui/src/components/Forms/InlineField.mdx
index 1ab000ddf7d..a6cadf14e98 100644
--- a/packages/grafana-ui/src/components/Forms/InlineField.mdx
+++ b/packages/grafana-ui/src/components/Forms/InlineField.mdx
@@ -1,10 +1,13 @@
-import { Props } from "@storybook/addon-docs/blocks";
-import { InlineField } from "./InlineField";
+import { Props } from '@storybook/addon-docs/blocks';
+import { InlineField } from './InlineField';
# InlineField
A basic component for rendering form elements, like `Input`, `Select`, `Checkbox`, etc, inline together with `InlineLabel`. If the child element has `id` specified, the label's `htmlFor` attribute, pointing to the id, will be added.
-The width of the `InlineLabel` can be modified via `labelWidth` prop. If `tooltip` prop is provided, an info icon with supplied tooltip content will be rendered inside the label.
+
+The width of the `InlineLabel` can be modified via `labelWidth` prop, which is a multiple of 8px. For example, an `InlineField` with `labelWidth={20}` will have a label 160px wide.
+
+If `tooltip` prop is provided, an info icon with supplied tooltip content will be rendered inside the label.
# Usage
diff --git a/packages/grafana-ui/src/components/Forms/InlineField.tsx b/packages/grafana-ui/src/components/Forms/InlineField.tsx
index fa30a05659e..094270ec4d6 100644
--- a/packages/grafana-ui/src/components/Forms/InlineField.tsx
+++ b/packages/grafana-ui/src/components/Forms/InlineField.tsx
@@ -10,7 +10,7 @@ import { getChildId } from '../../utils/children';
export interface Props extends Omit {
/** Content for the label's tooltip */
tooltip?: PopoverContent;
- /** Custom width for the label */
+ /** Custom width for the label as a multiple of 8px */
labelWidth?: number | 'auto';
/** Make the field's child to fill the width of the row. Equivalent to setting `flex-grow:1` on the field */
grow?: boolean;