@react-ui-org/react-ui 0.52.1 → 0.54.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +10 -7
- package/dist/react-ui.css +5 -3
- package/dist/react-ui.development.css +11302 -0
- package/dist/react-ui.development.js +1588 -0
- package/dist/react-ui.js +1 -1
- package/package.json +66 -77
- package/src/{lib/components → components}/Alert/Alert.jsx +1 -1
- package/src/{lib/components/Alert/README.mdx → components/Alert/README.md} +84 -100
- package/src/{lib/components → components}/Badge/Badge.jsx +1 -1
- package/src/{lib/components → components}/Badge/Badge.scss +1 -1
- package/src/components/Badge/README.md +103 -0
- package/src/{lib/components → components}/Button/Button.jsx +1 -1
- package/src/components/Button/README.md +580 -0
- package/src/{lib/components → components}/ButtonGroup/ButtonGroup.jsx +11 -9
- package/src/{lib/components/ButtonGroup/README.mdx → components/ButtonGroup/README.md} +128 -134
- package/src/{lib/components → components}/Card/Card.jsx +1 -1
- package/src/components/Card/README.md +314 -0
- package/src/{lib/components/CheckboxField/README.mdx → components/CheckboxField/README.md} +96 -108
- package/src/{lib/components/FileInputField/README.mdx → components/FileInputField/README.md} +83 -95
- package/src/{lib/components → components}/FormLayout/FormLayout.jsx +4 -4
- package/src/components/FormLayout/README.md +462 -0
- package/src/{lib/components → components}/Grid/Grid.jsx +2 -2
- package/src/components/Grid/README.md +281 -0
- package/src/{lib/components → components}/InputGroup/InputGroup.jsx +28 -19
- package/src/{lib/components → components}/InputGroup/InputGroup.scss +4 -5
- package/src/{lib/components/InputGroup/README.mdx → components/InputGroup/README.md} +162 -165
- package/src/{lib/components → components}/Modal/Modal.jsx +6 -6
- package/src/components/Modal/README.md +1090 -0
- package/src/components/Modal/_hooks/useModalScrollPrevention.js +37 -0
- package/src/{lib/components/Paper/README.mdx → components/Paper/README.md} +18 -30
- package/src/{lib/components/Popover/README.mdx → components/Popover/README.md} +102 -132
- package/src/{lib/components/Radio/README.mdx → components/Radio/README.md} +122 -134
- package/src/{lib/components → components}/Radio/Radio.jsx +11 -12
- package/src/{lib/components → components}/Radio/Radio.scss +0 -5
- package/src/components/ScrollView/README.md +503 -0
- package/src/{lib/components → components}/ScrollView/ScrollView.jsx +12 -3
- package/src/components/SelectField/README.md +681 -0
- package/src/components/Table/README.md +259 -0
- package/src/{lib/components → components}/Table/Table.jsx +4 -1
- package/src/{lib/components → components}/Table/_components/TableHeaderCell/TableHeaderCell.jsx +1 -1
- package/src/{lib/components/Tabs/README.mdx → components/Tabs/README.md} +117 -134
- package/src/{lib/components → components}/Tabs/TabsItem.jsx +3 -3
- package/src/components/Text/README.md +220 -0
- package/src/components/TextArea/README.md +359 -0
- package/src/{lib/components/TextField/README.mdx → components/TextField/README.md} +336 -342
- package/src/{lib/components/TextLink/README.mdx → components/TextLink/README.md} +19 -31
- package/src/{lib/components/Toggle/README.mdx → components/Toggle/README.md} +98 -110
- package/src/components/Toolbar/README.md +359 -0
- package/src/{lib/components → components}/Toolbar/_helpers/getAlignClassName.js +12 -4
- package/src/components/_helpers/getRootPriorityClassName.js +15 -0
- package/src/{lib/index.js → index.js} +6 -0
- package/src/{lib/provider → provider}/RUIProvider.jsx +17 -11
- package/src/{lib/styles → styles}/tools/_caret.scss +1 -1
- package/src/{lib/styles → styles}/tools/form-fields/_box-field-elements.scss +1 -1
- package/src/{lib/styles → styles}/tools/form-fields/_inline-field-elements.scss +2 -2
- package/src/{lib/theme.scss → theme.scss} +4 -3
- package/CONTRIBUTING.md +0 -137
- package/dist/lib.development.js +0 -3179
- package/dist/lib.js +0 -1
- package/public/racom.svg +0 -11
- package/src/lib/components/Badge/README.mdx +0 -126
- package/src/lib/components/Button/README.mdx +0 -581
- package/src/lib/components/Card/README.mdx +0 -326
- package/src/lib/components/FormLayout/README.mdx +0 -501
- package/src/lib/components/Grid/README.mdx +0 -299
- package/src/lib/components/Modal/README.mdx +0 -1360
- package/src/lib/components/Modal/_hooks/useModalScrollPrevention.js +0 -35
- package/src/lib/components/ScrollView/README.mdx +0 -521
- package/src/lib/components/SelectField/README.mdx +0 -693
- package/src/lib/components/Table/README.mdx +0 -275
- package/src/lib/components/Text/README.mdx +0 -241
- package/src/lib/components/TextArea/README.mdx +0 -366
- package/src/lib/components/Toolbar/README.mdx +0 -386
- package/src/{lib/components → components}/Alert/Alert.scss +0 -0
- package/src/{lib/components → components}/Alert/_settings.scss +0 -0
- package/src/{lib/components → components}/Alert/_theme.scss +0 -0
- package/src/{lib/components → components}/Alert/_tools.scss +0 -0
- package/src/{lib/components → components}/Alert/index.js +0 -0
- package/src/{lib/components → components}/Badge/index.js +0 -0
- package/src/{lib/components → components}/Button/Button.scss +0 -0
- package/src/{lib/components → components}/Button/_base.scss +0 -0
- package/src/{lib/components → components}/Button/_priorities.scss +0 -0
- package/src/{lib/components → components}/Button/_settings.scss +0 -0
- package/src/{lib/components → components}/Button/_theme.scss +0 -0
- package/src/{lib/components → components}/Button/_tools.scss +0 -0
- package/src/{lib/components → components}/Button/helpers/getRootLabelVisibilityClassName.js +0 -0
- package/src/{lib/components/_helpers → components/Button/helpers}/getRootPriorityClassName.js +0 -0
- package/src/{lib/components → components}/Button/index.js +0 -0
- package/src/{lib/components → components}/ButtonGroup/ButtonGroup.scss +0 -0
- package/src/{lib/components → components}/ButtonGroup/ButtonGroupContext.js +0 -0
- package/src/{lib/components → components}/ButtonGroup/_theme.scss +0 -0
- package/src/{lib/components → components}/ButtonGroup/index.js +0 -0
- package/src/{lib/components → components}/Card/Card.scss +0 -0
- package/src/{lib/components → components}/Card/CardBody.jsx +0 -0
- package/src/{lib/components → components}/Card/CardFooter.jsx +0 -0
- package/src/{lib/components → components}/Card/_theme.scss +0 -0
- package/src/{lib/components → components}/Card/_tools.scss +0 -0
- package/src/{lib/components → components}/Card/index.js +0 -0
- package/src/{lib/components → components}/CheckboxField/CheckboxField.jsx +0 -0
- package/src/{lib/components → components}/CheckboxField/CheckboxField.scss +0 -0
- package/src/{lib/components → components}/CheckboxField/index.js +0 -0
- package/src/{lib/components → components}/FileInputField/FileInputField.jsx +0 -0
- package/src/{lib/components → components}/FileInputField/FileInputField.scss +0 -0
- package/src/{lib/components → components}/FileInputField/index.js +0 -0
- package/src/{lib/components → components}/FormLayout/FormLayout.scss +0 -0
- package/src/{lib/components → components}/FormLayout/FormLayoutContext.js +0 -0
- package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.jsx +4 -4
- package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.scss +0 -0
- package/src/{lib/components → components}/FormLayout/_theme.scss +0 -0
- package/src/{lib/components → components}/FormLayout/index.js +0 -0
- package/src/{lib/components → components}/Grid/Grid.scss +0 -0
- package/src/{lib/components → components}/Grid/GridSpan.jsx +0 -0
- package/src/{lib/components → components}/Grid/_helpers/generateResponsiveCustomProperties.js +0 -0
- package/src/{lib/components → components}/Grid/_settings.scss +0 -0
- package/src/{lib/components → components}/Grid/_tools.scss +0 -0
- package/src/{lib/components → components}/Grid/index.js +0 -0
- package/src/{lib/components → components}/InputGroup/InputGroupContext.js +0 -0
- package/src/{lib/components → components}/InputGroup/_theme.scss +0 -0
- package/src/{lib/components → components}/InputGroup/index.js +0 -0
- package/src/{lib/components → components}/Modal/Modal.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalBody.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalBody.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalCloseButton.jsx +1 -1
- package/src/{lib/components → components}/Modal/ModalCloseButton.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalContent.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalContent.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalFooter.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalFooter.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalHeader.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalHeader.scss +0 -0
- package/src/{lib/components → components}/Modal/ModalTitle.jsx +0 -0
- package/src/{lib/components → components}/Modal/ModalTitle.scss +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getJustifyClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getPositionClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getScrollingClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_helpers/getSizeClassName.js +0 -0
- package/src/{lib/components → components}/Modal/_hooks/useModalFocus.js +0 -0
- package/src/{lib/components → components}/Modal/_settings.scss +0 -0
- package/src/{lib/components → components}/Modal/_theme.scss +0 -0
- package/src/{lib/components → components}/Modal/index.js +0 -0
- package/src/{lib/components → components}/Paper/Paper.jsx +0 -0
- package/src/{lib/components → components}/Paper/Paper.scss +0 -0
- package/src/{lib/components → components}/Paper/_theme.scss +0 -0
- package/src/{lib/components → components}/Paper/index.js +0 -0
- package/src/{lib/components → components}/Popover/Popover.jsx +0 -0
- package/src/{lib/components → components}/Popover/Popover.scss +0 -0
- package/src/{lib/components → components}/Popover/PopoverWrapper.jsx +0 -0
- package/src/{lib/components → components}/Popover/PopoverWrapper.scss +0 -0
- package/src/{lib/components → components}/Popover/_helpers/getRootAlignmentClassName.js +0 -0
- package/src/{lib/components → components}/Popover/_helpers/getRootSideClassName.js +0 -0
- package/src/{lib/components → components}/Popover/_theme.scss +0 -0
- package/src/{lib/components → components}/Popover/index.js +0 -0
- package/src/{lib/components → components}/Radio/index.js +0 -0
- package/src/{lib/components → components}/ScrollView/ScrollView.scss +0 -0
- package/src/{lib/components → components}/ScrollView/_helpers/getElementsPositionDifference.js +0 -0
- package/src/{lib/components → components}/ScrollView/_hooks/useLoadResizeHook.js +0 -0
- package/src/{lib/components → components}/ScrollView/_hooks/useScrollPositionHook.js +0 -0
- package/src/{lib/components → components}/ScrollView/index.js +0 -0
- package/src/{lib/components → components}/SelectField/SelectField.jsx +0 -0
- package/src/{lib/components → components}/SelectField/SelectField.scss +0 -0
- package/src/{lib/components → components}/SelectField/_components/Option/Option.jsx +0 -0
- package/src/{lib/components → components}/SelectField/_components/Option/index.js +0 -0
- package/src/{lib/components → components}/SelectField/index.js +0 -0
- package/src/{lib/components → components}/Table/Table.scss +0 -0
- package/src/{lib/components → components}/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -0
- package/src/{lib/components → components}/Table/_components/TableBodyCell/index.js +0 -0
- package/src/{lib/components → components}/Table/_components/TableCell.scss +0 -0
- package/src/{lib/components → components}/Table/_components/TableHeaderCell/index.js +0 -0
- package/src/{lib/components → components}/Table/_settings.scss +0 -0
- package/src/{lib/components → components}/Table/index.js +0 -0
- package/src/{lib/components → components}/Tabs/Tabs.jsx +0 -0
- package/src/{lib/components → components}/Tabs/Tabs.scss +0 -0
- package/src/{lib/components → components}/Tabs/TabsItem.scss +0 -0
- package/src/{lib/components → components}/Tabs/_theme.scss +0 -0
- package/src/{lib/components → components}/Tabs/index.js +0 -0
- package/src/{lib/components → components}/Text/Text.jsx +0 -0
- package/src/{lib/components → components}/Text/Text.scss +0 -0
- package/src/{lib/components → components}/Text/_helpers/getRootClampClassName.js +0 -0
- package/src/{lib/components → components}/Text/_helpers/getRootHyphensClassName.js +0 -0
- package/src/{lib/components → components}/Text/_helpers/getRootWordWrappingClassName.js +0 -0
- package/src/{lib/components → components}/Text/index.js +0 -0
- package/src/{lib/components → components}/TextArea/TextArea.jsx +0 -0
- package/src/{lib/components → components}/TextArea/TextArea.scss +0 -0
- package/src/{lib/components → components}/TextArea/index.js +0 -0
- package/src/{lib/components → components}/TextField/TextField.jsx +0 -0
- package/src/{lib/components → components}/TextField/TextField.scss +0 -0
- package/src/{lib/components → components}/TextField/index.js +0 -0
- package/src/{lib/components → components}/TextLink/TextLink.jsx +1 -1
- /package/src/{lib/components → components}/TextLink/TextLink.scss +0 -0
- /package/src/{lib/components → components}/TextLink/_theme.scss +0 -0
- /package/src/{lib/components → components}/TextLink/index.js +0 -0
- /package/src/{lib/components → components}/Toggle/Toggle.jsx +0 -0
- /package/src/{lib/components → components}/Toggle/Toggle.scss +0 -0
- /package/src/{lib/components → components}/Toggle/index.js +0 -0
- /package/src/{lib/components → components}/Toolbar/Toolbar.jsx +0 -0
- /package/src/{lib/components → components}/Toolbar/Toolbar.scss +0 -0
- /package/src/{lib/components → components}/Toolbar/ToolbarGroup.jsx +0 -0
- /package/src/{lib/components → components}/Toolbar/ToolbarItem.jsx +0 -0
- /package/src/{lib/components → components}/Toolbar/_helpers/getJustifyClassName.js +0 -0
- /package/src/{lib/components → components}/Toolbar/_theme.scss +0 -0
- /package/src/{lib/components → components}/Toolbar/index.js +0 -0
- /package/src/{lib/components → components}/_helpers/getRootColorClassName.js +0 -0
- /package/src/{lib/components → components}/_helpers/getRootSizeClassName.js +0 -0
- /package/src/{lib/components → components}/_helpers/getRootValidationStateClassName.js +0 -0
- /package/src/{lib/components → components}/_helpers/isChildrenEmpty.js +0 -0
- /package/src/{lib/components → components}/_helpers/resolveContextOrProp.js +0 -0
- /package/src/{lib/components → components}/_helpers/transferProps.js +0 -0
- /package/src/{lib/foundation.scss → foundation.scss} +0 -0
- /package/src/{lib/helpers.scss → helpers.scss} +0 -0
- /package/src/{lib/provider → provider}/RUIContext.jsx +0 -0
- /package/src/{lib/provider → provider}/index.js +0 -0
- /package/src/{lib/provider → provider}/withGlobalProps.jsx +0 -0
- /package/src/{lib/styles → styles}/_utilities.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_code.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_links.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_lists.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_page.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_rulers.scss +0 -0
- /package/src/{lib/styles → styles}/elements/_small.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_box-sizing.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_focus.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_forms.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_reset.scss +0 -0
- /package/src/{lib/styles → styles}/generic/_shared.scss +0 -0
- /package/src/{lib/styles → styles}/helpers/_animation.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_animations.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_breakpoints.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_escaped-characters.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_form-fields.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_forms.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_utilities.scss +0 -0
- /package/src/{lib/styles → styles}/settings/_z-indexes.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_accessibility.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_borders.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_code.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_form-fields.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_links.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_lists.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_page.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_spacing.scss +0 -0
- /package/src/{lib/styles → styles}/theme/_typography.scss +0 -0
- /package/src/{lib/styles → styles}/theme-constants/_breakpoints.scss +0 -0
- /package/src/{lib/styles → styles}/theme-constants/_colors.scss +0 -0
- /package/src/{lib/styles → styles}/theme-constants/_svg.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_accessibility.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_breakpoint.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_colors.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_reset.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_scrollbar.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_spacing.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_string.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_svg.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_transition.scss +0 -0
- /package/src/{lib/styles → styles}/tools/_utilities.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_box-field-layout.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_box-field-sizes.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_foundation.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_inline-field-layout.scss +0 -0
- /package/src/{lib/styles → styles}/tools/form-fields/_variants.scss +0 -0
- /package/src/{lib/translations → translations}/en.js +0 -0
- /package/src/{lib/utils → utils}/classNames.js +0 -0
@@ -1,501 +0,0 @@
|
|
1
|
-
---
|
2
|
-
name: FormLayout
|
3
|
-
menu: 'Layouts'
|
4
|
-
route: /components/form-layout
|
5
|
-
---
|
6
|
-
|
7
|
-
# FormLayout
|
8
|
-
|
9
|
-
The FormLayout aligns form fields into an organized grid.
|
10
|
-
|
11
|
-
import {
|
12
|
-
Playground,
|
13
|
-
Props,
|
14
|
-
} from 'docz'
|
15
|
-
import { Placeholder } from '../../../docs/_components/Placeholder/Placeholder'
|
16
|
-
import {
|
17
|
-
Button,
|
18
|
-
ButtonGroup,
|
19
|
-
CheckboxField,
|
20
|
-
FileInputField,
|
21
|
-
Radio,
|
22
|
-
SelectField,
|
23
|
-
TextArea,
|
24
|
-
TextField,
|
25
|
-
Toggle,
|
26
|
-
Toolbar,
|
27
|
-
ToolbarItem,
|
28
|
-
FormLayout,
|
29
|
-
FormLayoutCustomField,
|
30
|
-
InputGroup,
|
31
|
-
} from '../..'
|
32
|
-
|
33
|
-
## Basic Usage
|
34
|
-
|
35
|
-
To implement the FormLayout component, you need to import it first:
|
36
|
-
|
37
|
-
```js
|
38
|
-
import { FormLayout } from '@react-ui-org/react-ui';
|
39
|
-
```
|
40
|
-
|
41
|
-
And use it:
|
42
|
-
|
43
|
-
<Playground>
|
44
|
-
<FormLayout>
|
45
|
-
<TextField label="A form element" />
|
46
|
-
</FormLayout>
|
47
|
-
</Playground>
|
48
|
-
|
49
|
-
See [API](#api) for all available options.
|
50
|
-
|
51
|
-
## General Guidelines
|
52
|
-
|
53
|
-
Since all form fields in React UI are styled as inline blocks, they **queue up
|
54
|
-
one after another in a row by default.** The FormLayout component is there to
|
55
|
-
make building **vertical and horizontal forms** easy. It uses the right tool for
|
56
|
-
the job: the [CSS grid layout][grid].
|
57
|
-
|
58
|
-
- Put **only form field components** from React UI inside the FormLayout and
|
59
|
-
make sure they are **direct descendants** of it (React [fragments] are
|
60
|
-
supported!). All React UI form components are ready for this use case and
|
61
|
-
don't need to be wrapped in any `div`s. Namely, the FormLayout supports the
|
62
|
-
following React UI components:
|
63
|
-
[CheckboxField](/components/checkbox-field),
|
64
|
-
[Radio](/components/radio), [SelectField](/components/select-field),
|
65
|
-
[TextArea](/components/text-area), [TextField](/components/text-field),
|
66
|
-
and [Toggle](/components/toggle).
|
67
|
-
|
68
|
-
- Use the [FormLayoutCustomField](#custom-fields) component when you need to
|
69
|
-
place any **custom content** inside the FormLayout. This layout helper ensures
|
70
|
-
your content is properly spaced and aligned with other FormLayout elements.
|
71
|
-
Do **not** try to put any custom HTML or React components directly into
|
72
|
-
FormLayout without wrapping it with the FormLayoutCustomField first.
|
73
|
-
|
74
|
-
👉 For usage in auto-width Modal, you may need to turn on the `autoWidth` option
|
75
|
-
for your FormLayout. This prevents FormLayout from unexpectedly growing in
|
76
|
-
browsers that [don't support][rui-232] [CSS subgrid][subgrid] in cases when
|
77
|
-
there are longer validation messages or help texts.
|
78
|
-
|
79
|
-
## Vertical Layout
|
80
|
-
|
81
|
-
Vertical FormLayout works similar to single-column [Grid](/components/grid)
|
82
|
-
layout while it also forces vertical layout mode on form fields. To use this
|
83
|
-
layout, simply wrap your form fields with the FormLayout component:
|
84
|
-
|
85
|
-
<Playground>
|
86
|
-
<FormLayout>
|
87
|
-
<TextField label="A form element" />
|
88
|
-
<TextField label="Another form element" />
|
89
|
-
<TextField label="Yet another one" />
|
90
|
-
</FormLayout>
|
91
|
-
</Playground>
|
92
|
-
|
93
|
-
## Horizontal Layout
|
94
|
-
|
95
|
-
Horizontal FormLayout is designed for horizontal form fields: it nicely **aligns
|
96
|
-
labels and inputs in an organized grid.** It is applied starting from the `md`
|
97
|
-
viewport size onward and it forces the horizontal layout on the fields.
|
98
|
-
|
99
|
-
<Playground>
|
100
|
-
<FormLayout fieldLayout="horizontal">
|
101
|
-
<TextField label="A form element" />
|
102
|
-
<TextField label="Another form element" />
|
103
|
-
<TextField label="Yet another one" />
|
104
|
-
</FormLayout>
|
105
|
-
</Playground>
|
106
|
-
|
107
|
-
### Label Width
|
108
|
-
|
109
|
-
In the horizontal layout mode, it's possible to fine-tune the way how the form
|
110
|
-
will be aligned through the `labelWidth` option to cover various design
|
111
|
-
requirements. It comes with **three globally shared options:** default width,
|
112
|
-
auto width, and limited width. For cases where an individual manual width works
|
113
|
-
better, there is the **local custom width mode** which enables setting a width
|
114
|
-
that is applied just for the current FormLayout.
|
115
|
-
|
116
|
-
👉 All global label width options can be easily [customized](/customize/theming/overview)
|
117
|
-
with CSS custom properties.
|
118
|
-
|
119
|
-
#### Label Width Options
|
120
|
-
|
121
|
-
- The `default` mode (global) sets the width of all labels to a **global default
|
122
|
-
value** which is 10 em.
|
123
|
-
|
124
|
-
- The `auto` mode (global) aligns the form **according to the longest label.**
|
125
|
-
|
126
|
-
- The `limited` mode (global) works as `auto` except it's intended for values
|
127
|
-
that **set a limit for the label width.** Its default value is
|
128
|
-
`fitcontent(50%)` which also aligns the form according to the longest label
|
129
|
-
like `auto`, but with the difference that the labels cannot be wider than
|
130
|
-
50 % of the FormLayout.
|
131
|
-
|
132
|
-
- The `custom` mode (local) allows you to enter any **custom label width for
|
133
|
-
individual FormLayouts.**
|
134
|
-
|
135
|
-
📐 Try resizing the playground to see how individual options work.
|
136
|
-
|
137
|
-
<Playground>
|
138
|
-
{() => {
|
139
|
-
const [labelWidth, setLabelWidth] = React.useState('default');
|
140
|
-
const [customLabelWidth, setCustomLabelWidth] = React.useState('20em');
|
141
|
-
return (
|
142
|
-
<div>
|
143
|
-
<Toolbar align="baseline">
|
144
|
-
<ToolbarItem>
|
145
|
-
<span id="label-width-options-label">Label width:</span>
|
146
|
-
</ToolbarItem>
|
147
|
-
<ToolbarItem>
|
148
|
-
<ButtonGroup
|
149
|
-
aria-labelledby="label-width-options-label"
|
150
|
-
priority="outline"
|
151
|
-
>
|
152
|
-
<Button
|
153
|
-
aria-pressed={labelWidth === 'default'}
|
154
|
-
color={labelWidth === 'default' ? 'selected' : 'secondary'}
|
155
|
-
label="default"
|
156
|
-
onClick={() => setLabelWidth('default')}
|
157
|
-
/>
|
158
|
-
<Button
|
159
|
-
aria-pressed={labelWidth === 'auto'}
|
160
|
-
color={labelWidth === 'auto' ? 'selected' : 'secondary'}
|
161
|
-
label="auto"
|
162
|
-
onClick={() => setLabelWidth('auto')}
|
163
|
-
/>
|
164
|
-
<Button
|
165
|
-
aria-pressed={labelWidth === 'limited'}
|
166
|
-
color={labelWidth === 'limited' ? 'selected' : 'secondary'}
|
167
|
-
label="limited"
|
168
|
-
onClick={() => setLabelWidth('limited')}
|
169
|
-
/>
|
170
|
-
<Button
|
171
|
-
aria-pressed={labelWidth === 'custom'}
|
172
|
-
color={labelWidth === 'custom' ? 'selected' : 'secondary'}
|
173
|
-
label="custom"
|
174
|
-
onClick={() => setLabelWidth('custom')}
|
175
|
-
/>
|
176
|
-
</ButtonGroup>
|
177
|
-
</ToolbarItem>
|
178
|
-
{labelWidth === 'custom' && (
|
179
|
-
<ToolbarItem>
|
180
|
-
<TextField
|
181
|
-
inputSize={5}
|
182
|
-
isLabelVisible={false}
|
183
|
-
label="Custom label width"
|
184
|
-
layout="horizontal"
|
185
|
-
onChange={(e) => setCustomLabelWidth(e.target.value)}
|
186
|
-
value={customLabelWidth}
|
187
|
-
/>
|
188
|
-
</ToolbarItem>
|
189
|
-
)}
|
190
|
-
</Toolbar>
|
191
|
-
<FormLayout
|
192
|
-
fieldLayout="horizontal"
|
193
|
-
labelWidth={labelWidth === 'custom' ? customLabelWidth : labelWidth}
|
194
|
-
>
|
195
|
-
<TextField label="A form element" />
|
196
|
-
<TextField
|
197
|
-
label={'Another form element with a very long label that is so '
|
198
|
-
+ 'long that in the auto mode, it should make the label column '
|
199
|
-
+ 'grow until the inputs reach the end of the line, but it will '
|
200
|
-
+ 'not exceed 50 % of the FormLayout width in the limited label '
|
201
|
-
+ 'width mode'}
|
202
|
-
/>
|
203
|
-
<TextField label="Yet another one" />
|
204
|
-
</FormLayout>
|
205
|
-
</div>
|
206
|
-
);
|
207
|
-
}}
|
208
|
-
</Playground>
|
209
|
-
|
210
|
-
### Limitations
|
211
|
-
|
212
|
-
#### Label Position
|
213
|
-
|
214
|
-
Label position of inline form fields (CheckboxField, Toggle) is ignored in
|
215
|
-
horizontal FormLayout.
|
216
|
-
|
217
|
-
#### Modals
|
218
|
-
|
219
|
-
Please note the `auto` and `limited` label width options may not function
|
220
|
-
correctly in combination with other auto layout mechanisms, e.g. the auto-width
|
221
|
-
[Modal](/components/modal). It's just too much of magic that does not quite
|
222
|
-
work together yet 🎩.
|
223
|
-
|
224
|
-
## Custom Fields
|
225
|
-
|
226
|
-
You can even place any content you need into the FormLayout — just wrap it with
|
227
|
-
the [FormLayoutCustomField](#formlayoutcustomfield) component. This layout
|
228
|
-
helper ensures your content is properly spaced and aligned with to other
|
229
|
-
FormLayout elements. FormLayoutCustomFields are designed to work solely inside
|
230
|
-
the FormLayout component.
|
231
|
-
|
232
|
-
<Playground>
|
233
|
-
<FormLayout fieldLayout="horizontal" labelWidth="auto">
|
234
|
-
<TextField label="A form element" />
|
235
|
-
<FormLayoutCustomField label="Optional custom field label">
|
236
|
-
<Placeholder bordered>Custom field content</Placeholder>
|
237
|
-
</FormLayoutCustomField>
|
238
|
-
<TextField label="Another form element" />
|
239
|
-
</FormLayout>
|
240
|
-
</Playground>
|
241
|
-
|
242
|
-
👉 While you can set FormLayoutCustomField as `disabled`, `valid` or `required`
|
243
|
-
and its styles may affect contained form fields through CSS cascade, don't
|
244
|
-
forget to mirror the aforementioned properties to the contained form fields too
|
245
|
-
as API options as such are **not** inherited.
|
246
|
-
|
247
|
-
### Label Alignment
|
248
|
-
|
249
|
-
If you are in a situation with one or more box form fields inside your
|
250
|
-
FormLayoutCustomField, you may want to have its label aligned with the fields
|
251
|
-
inside. Since it's [not quite possible to do this automatically][rui-265] due to
|
252
|
-
limited browser support, there is `innerFieldSize` option which accepts any of
|
253
|
-
existing box field sizes (small, medium, or large) and is intended right for
|
254
|
-
this task.
|
255
|
-
|
256
|
-
<Playground>
|
257
|
-
<FormLayout fieldLayout="horizontal" labelWidth="auto">
|
258
|
-
<TextField label="A form element" />
|
259
|
-
<FormLayoutCustomField
|
260
|
-
innerFieldSize="medium"
|
261
|
-
label="Custom field label aligned to inner text input"
|
262
|
-
>
|
263
|
-
<TextField
|
264
|
-
isLabelVisible={false}
|
265
|
-
label="A form element"
|
266
|
-
placeholder="Text field with invisible label"
|
267
|
-
/>
|
268
|
-
</FormLayoutCustomField>
|
269
|
-
<TextField label="Another form element" />
|
270
|
-
</FormLayout>
|
271
|
-
</Playground>
|
272
|
-
|
273
|
-
### Validation States
|
274
|
-
|
275
|
-
Custom fields support the same validation states as regular form fields to
|
276
|
-
provide labels with optional feedback style.
|
277
|
-
|
278
|
-
<Playground>
|
279
|
-
<FormLayout fieldLayout="horizontal" labelWidth="auto">
|
280
|
-
<TextField label="A form element" />
|
281
|
-
<FormLayoutCustomField
|
282
|
-
label="Custom field label in valid state"
|
283
|
-
validationState="valid"
|
284
|
-
>
|
285
|
-
<Placeholder bordered>Custom field content</Placeholder>
|
286
|
-
</FormLayoutCustomField>
|
287
|
-
<TextField label="Another form element" />
|
288
|
-
</FormLayout>
|
289
|
-
</Playground>
|
290
|
-
|
291
|
-
### Accessibility
|
292
|
-
|
293
|
-
If possible, use the `labelForId` option to provide ID of contained form field
|
294
|
-
so the field remains accessible via custom field label.
|
295
|
-
|
296
|
-
You can also specify size of contained form field so custom field label is
|
297
|
-
properly vertically aligned.
|
298
|
-
|
299
|
-
<Playground>
|
300
|
-
{() => {
|
301
|
-
const [isChecked, setIsChecked] = React.useState(false);
|
302
|
-
return (
|
303
|
-
<FormLayout fieldLayout="horizontal" labelWidth="auto">
|
304
|
-
<TextField label="A form element" />
|
305
|
-
<FormLayoutCustomField
|
306
|
-
fullWidth
|
307
|
-
label="Custom field label aligned with medium form field"
|
308
|
-
labelForId="my-text-field-custom-accessibility-2"
|
309
|
-
innerFieldSize="medium"
|
310
|
-
>
|
311
|
-
<Toolbar align="middle" dense>
|
312
|
-
<ToolbarItem>
|
313
|
-
<TextField
|
314
|
-
isLabelVisible={false}
|
315
|
-
label="A form element"
|
316
|
-
placeholder="Text field with invisible label"
|
317
|
-
/>
|
318
|
-
</ToolbarItem>
|
319
|
-
<ToolbarItem>
|
320
|
-
<CheckboxField
|
321
|
-
checked={isChecked}
|
322
|
-
label="Another form field"
|
323
|
-
onChange={() => setIsChecked(!isChecked)}
|
324
|
-
/>
|
325
|
-
</ToolbarItem>
|
326
|
-
</Toolbar>
|
327
|
-
</FormLayoutCustomField>
|
328
|
-
<TextField label="Another form element" />
|
329
|
-
</FormLayout>
|
330
|
-
)
|
331
|
-
}}
|
332
|
-
</Playground>
|
333
|
-
|
334
|
-
## Full Example
|
335
|
-
|
336
|
-
This is a demo of all components supported by FormLayout.
|
337
|
-
|
338
|
-
<Playground>
|
339
|
-
{() => {
|
340
|
-
const [fieldLayout, setFieldLayout] = React.useState('vertical');
|
341
|
-
const [fruit, setFruit] = React.useState('apple');
|
342
|
-
const [isDeliveryAddress, setIsDeliveryAddress] = React.useState(true);
|
343
|
-
const [receiveNewsletter, setReceiveNewsletter] = React.useState(true);
|
344
|
-
const options = [
|
345
|
-
{
|
346
|
-
label: 'Apple',
|
347
|
-
value: 'apple',
|
348
|
-
},
|
349
|
-
{
|
350
|
-
label: 'Banana',
|
351
|
-
value: 'banana',
|
352
|
-
},
|
353
|
-
{
|
354
|
-
label: 'Grapefruit',
|
355
|
-
value: 'grapefruit',
|
356
|
-
},
|
357
|
-
];
|
358
|
-
return (
|
359
|
-
<div>
|
360
|
-
<Toolbar>
|
361
|
-
<ToolbarItem>
|
362
|
-
<ButtonGroup priority="outline">
|
363
|
-
<Button
|
364
|
-
aria-pressed={fieldLayout === 'vertical'}
|
365
|
-
color={fieldLayout === 'vertical' ? 'selected' : 'secondary'}
|
366
|
-
label="Vertical layout"
|
367
|
-
onClick={() => setFieldLayout('vertical')}
|
368
|
-
/>
|
369
|
-
<Button
|
370
|
-
aria-pressed={fieldLayout === 'horizontal'}
|
371
|
-
color={fieldLayout === 'horizontal' ? 'selected' : 'secondary'}
|
372
|
-
label="Horizontal layout"
|
373
|
-
onClick={() => setFieldLayout('horizontal')}
|
374
|
-
/>
|
375
|
-
</ButtonGroup>
|
376
|
-
</ToolbarItem>
|
377
|
-
</Toolbar>
|
378
|
-
<FormLayout fieldLayout={fieldLayout} labelWidth="auto">
|
379
|
-
<>
|
380
|
-
<TextField
|
381
|
-
label="First Name"
|
382
|
-
/>
|
383
|
-
<TextField
|
384
|
-
label="Last Name"
|
385
|
-
/>
|
386
|
-
</>
|
387
|
-
<TextField
|
388
|
-
helpText="Optional"
|
389
|
-
label="Email address"
|
390
|
-
type="email"
|
391
|
-
/>
|
392
|
-
<>
|
393
|
-
<TextField
|
394
|
-
label="Address"
|
395
|
-
placeholder="Address line 1"
|
396
|
-
/>
|
397
|
-
<TextField
|
398
|
-
isLabelVisible={false}
|
399
|
-
label="Address 2"
|
400
|
-
placeholder="Address line 2"
|
401
|
-
/>
|
402
|
-
<TextField
|
403
|
-
inputSize={6}
|
404
|
-
label="ZIP"
|
405
|
-
validationState="invalid"
|
406
|
-
validationText="ZIP should be 5 to 6 digits long code."
|
407
|
-
/>
|
408
|
-
<FormLayoutCustomField label="Country">
|
409
|
-
<span>Czech Republic</span>
|
410
|
-
</FormLayoutCustomField>
|
411
|
-
<CheckboxField
|
412
|
-
checked={isDeliveryAddress}
|
413
|
-
helpText="Uncheck if you wish to deliver to a different address."
|
414
|
-
label="This is my delivery address"
|
415
|
-
onChange={() => setIsDeliveryAddress(!isDeliveryAddress)}
|
416
|
-
/>
|
417
|
-
</>
|
418
|
-
<SelectField
|
419
|
-
label="Your favourite fruit"
|
420
|
-
onChange={(e) => setFruit(e.target.value)}
|
421
|
-
options={options}
|
422
|
-
value={fruit}
|
423
|
-
/>
|
424
|
-
<TextArea
|
425
|
-
fullWidth
|
426
|
-
label="Message"
|
427
|
-
rows={3}
|
428
|
-
/>
|
429
|
-
<FileInputField
|
430
|
-
label="Attachment"
|
431
|
-
/>
|
432
|
-
<Toggle
|
433
|
-
checked={receiveNewsletter}
|
434
|
-
helpText="Only once per week!"
|
435
|
-
label="Receive weekly newsletter"
|
436
|
-
onChange={() => setReceiveNewsletter(!receiveNewsletter)}
|
437
|
-
required
|
438
|
-
/>
|
439
|
-
<Radio
|
440
|
-
label="And fruit again!"
|
441
|
-
onChange={(e) => setFruit(e.target.value)}
|
442
|
-
options={options}
|
443
|
-
value={fruit}
|
444
|
-
/>
|
445
|
-
<InputGroup label="Promo code">
|
446
|
-
<TextField label="Code" />
|
447
|
-
<Button label="Apply" color="secondary" priority="outline" />
|
448
|
-
</InputGroup>
|
449
|
-
</FormLayout>
|
450
|
-
</div>
|
451
|
-
)
|
452
|
-
}}
|
453
|
-
</Playground>
|
454
|
-
|
455
|
-
## Forwarding HTML Attributes
|
456
|
-
|
457
|
-
In addition to the options below in the [component's API](#api) section, you
|
458
|
-
can specify [React synthetic events] or **any HTML attribute you like.** All
|
459
|
-
attributes that don't interfere with the API are forwarded to the root `<div>`
|
460
|
-
HTML element. This enables making the component interactive and helps to improve
|
461
|
-
its accessibility.
|
462
|
-
|
463
|
-
👉 Refer to the MDN reference for the full list of supported attributes of the
|
464
|
-
[div] element.
|
465
|
-
|
466
|
-
## API
|
467
|
-
|
468
|
-
<Props table of={FormLayout} />
|
469
|
-
|
470
|
-
### FormLayoutCustomField API
|
471
|
-
|
472
|
-
A place for custom content inside FormLayout.
|
473
|
-
|
474
|
-
<Props table of={FormLayoutCustomField} />
|
475
|
-
|
476
|
-
## Theming
|
477
|
-
|
478
|
-
| Custom Property | Description |
|
479
|
-
|------------------------------------------------------|--------------------------------------------------------------|
|
480
|
-
| `--rui-FormLayout__row-gap` | Gap between individual rows |
|
481
|
-
| `--rui-FormLayout--horizontal__label__width` | Default label width |
|
482
|
-
| `--rui-FormLayout--horizontal__label__width--auto` | Label width in automatic layout |
|
483
|
-
| `--rui-FormLayout--horizontal__label__width--limited` | Label width in limited-width layout |
|
484
|
-
|
485
|
-
### FormLayoutCustomField Theming
|
486
|
-
|
487
|
-
FormLayoutCustomField can be styled using a small subset of
|
488
|
-
[other form fields theming options](/customize/theming/forms).
|
489
|
-
|
490
|
-
| Custom Property | Description |
|
491
|
-
|------------------------------------------------------|--------------------------------------------------------------|
|
492
|
-
| `--rui-FormField--custom--default__surrounding-text-color` | Custom field label color in default state |
|
493
|
-
| `--rui-FormField--custom--disabled__surrounding-text-color` | Custom field label color in disabled-like state |
|
494
|
-
|
495
|
-
[grid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout
|
496
|
-
[subgrid]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Subgrid
|
497
|
-
[fragments]: https://reactjs.org/docs/fragments.html
|
498
|
-
[rui-232]: https://github.com/react-ui-org/react-ui/issues/232
|
499
|
-
[rui-265]: https://github.com/react-ui-org/react-ui/issues/265
|
500
|
-
[React synthetic events]: https://reactjs.org/docs/events.html
|
501
|
-
[div]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/div#attributes
|