@react-ui-org/react-ui 0.52.1 → 0.54.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/README.md +10 -7
  2. package/dist/react-ui.css +5 -3
  3. package/dist/react-ui.development.css +11302 -0
  4. package/dist/react-ui.development.js +1588 -0
  5. package/dist/react-ui.js +1 -1
  6. package/package.json +66 -77
  7. package/src/{lib/components → components}/Alert/Alert.jsx +1 -1
  8. package/src/{lib/components/Alert/README.mdx → components/Alert/README.md} +84 -100
  9. package/src/{lib/components → components}/Badge/Badge.jsx +1 -1
  10. package/src/{lib/components → components}/Badge/Badge.scss +1 -1
  11. package/src/components/Badge/README.md +103 -0
  12. package/src/{lib/components → components}/Button/Button.jsx +1 -1
  13. package/src/components/Button/README.md +580 -0
  14. package/src/{lib/components → components}/ButtonGroup/ButtonGroup.jsx +11 -9
  15. package/src/{lib/components/ButtonGroup/README.mdx → components/ButtonGroup/README.md} +128 -134
  16. package/src/{lib/components → components}/Card/Card.jsx +1 -1
  17. package/src/components/Card/README.md +314 -0
  18. package/src/{lib/components/CheckboxField/README.mdx → components/CheckboxField/README.md} +96 -108
  19. package/src/{lib/components/FileInputField/README.mdx → components/FileInputField/README.md} +83 -95
  20. package/src/{lib/components → components}/FormLayout/FormLayout.jsx +4 -4
  21. package/src/components/FormLayout/README.md +462 -0
  22. package/src/{lib/components → components}/Grid/Grid.jsx +2 -2
  23. package/src/components/Grid/README.md +281 -0
  24. package/src/{lib/components → components}/InputGroup/InputGroup.jsx +28 -19
  25. package/src/{lib/components → components}/InputGroup/InputGroup.scss +4 -5
  26. package/src/{lib/components/InputGroup/README.mdx → components/InputGroup/README.md} +162 -165
  27. package/src/{lib/components → components}/Modal/Modal.jsx +6 -6
  28. package/src/components/Modal/README.md +1090 -0
  29. package/src/components/Modal/_hooks/useModalScrollPrevention.js +37 -0
  30. package/src/{lib/components/Paper/README.mdx → components/Paper/README.md} +18 -30
  31. package/src/{lib/components/Popover/README.mdx → components/Popover/README.md} +102 -132
  32. package/src/{lib/components/Radio/README.mdx → components/Radio/README.md} +122 -134
  33. package/src/{lib/components → components}/Radio/Radio.jsx +11 -12
  34. package/src/{lib/components → components}/Radio/Radio.scss +0 -5
  35. package/src/components/ScrollView/README.md +503 -0
  36. package/src/{lib/components → components}/ScrollView/ScrollView.jsx +12 -3
  37. package/src/components/SelectField/README.md +681 -0
  38. package/src/components/Table/README.md +259 -0
  39. package/src/{lib/components → components}/Table/Table.jsx +4 -1
  40. package/src/{lib/components → components}/Table/_components/TableHeaderCell/TableHeaderCell.jsx +1 -1
  41. package/src/{lib/components/Tabs/README.mdx → components/Tabs/README.md} +117 -134
  42. package/src/{lib/components → components}/Tabs/TabsItem.jsx +3 -3
  43. package/src/components/Text/README.md +220 -0
  44. package/src/components/TextArea/README.md +359 -0
  45. package/src/{lib/components/TextField/README.mdx → components/TextField/README.md} +336 -342
  46. package/src/{lib/components/TextLink/README.mdx → components/TextLink/README.md} +19 -31
  47. package/src/{lib/components/Toggle/README.mdx → components/Toggle/README.md} +98 -110
  48. package/src/components/Toolbar/README.md +359 -0
  49. package/src/{lib/components → components}/Toolbar/_helpers/getAlignClassName.js +12 -4
  50. package/src/components/_helpers/getRootPriorityClassName.js +15 -0
  51. package/src/{lib/index.js → index.js} +6 -0
  52. package/src/{lib/provider → provider}/RUIProvider.jsx +17 -11
  53. package/src/{lib/styles → styles}/tools/_caret.scss +1 -1
  54. package/src/{lib/styles → styles}/tools/form-fields/_box-field-elements.scss +1 -1
  55. package/src/{lib/styles → styles}/tools/form-fields/_inline-field-elements.scss +2 -2
  56. package/src/{lib/theme.scss → theme.scss} +4 -3
  57. package/CONTRIBUTING.md +0 -137
  58. package/dist/lib.development.js +0 -3179
  59. package/dist/lib.js +0 -1
  60. package/public/racom.svg +0 -11
  61. package/src/lib/components/Badge/README.mdx +0 -126
  62. package/src/lib/components/Button/README.mdx +0 -581
  63. package/src/lib/components/Card/README.mdx +0 -326
  64. package/src/lib/components/FormLayout/README.mdx +0 -501
  65. package/src/lib/components/Grid/README.mdx +0 -299
  66. package/src/lib/components/Modal/README.mdx +0 -1360
  67. package/src/lib/components/Modal/_hooks/useModalScrollPrevention.js +0 -35
  68. package/src/lib/components/ScrollView/README.mdx +0 -521
  69. package/src/lib/components/SelectField/README.mdx +0 -693
  70. package/src/lib/components/Table/README.mdx +0 -275
  71. package/src/lib/components/Text/README.mdx +0 -241
  72. package/src/lib/components/TextArea/README.mdx +0 -366
  73. package/src/lib/components/Toolbar/README.mdx +0 -386
  74. package/src/{lib/components → components}/Alert/Alert.scss +0 -0
  75. package/src/{lib/components → components}/Alert/_settings.scss +0 -0
  76. package/src/{lib/components → components}/Alert/_theme.scss +0 -0
  77. package/src/{lib/components → components}/Alert/_tools.scss +0 -0
  78. package/src/{lib/components → components}/Alert/index.js +0 -0
  79. package/src/{lib/components → components}/Badge/index.js +0 -0
  80. package/src/{lib/components → components}/Button/Button.scss +0 -0
  81. package/src/{lib/components → components}/Button/_base.scss +0 -0
  82. package/src/{lib/components → components}/Button/_priorities.scss +0 -0
  83. package/src/{lib/components → components}/Button/_settings.scss +0 -0
  84. package/src/{lib/components → components}/Button/_theme.scss +0 -0
  85. package/src/{lib/components → components}/Button/_tools.scss +0 -0
  86. package/src/{lib/components → components}/Button/helpers/getRootLabelVisibilityClassName.js +0 -0
  87. package/src/{lib/components/_helpers → components/Button/helpers}/getRootPriorityClassName.js +0 -0
  88. package/src/{lib/components → components}/Button/index.js +0 -0
  89. package/src/{lib/components → components}/ButtonGroup/ButtonGroup.scss +0 -0
  90. package/src/{lib/components → components}/ButtonGroup/ButtonGroupContext.js +0 -0
  91. package/src/{lib/components → components}/ButtonGroup/_theme.scss +0 -0
  92. package/src/{lib/components → components}/ButtonGroup/index.js +0 -0
  93. package/src/{lib/components → components}/Card/Card.scss +0 -0
  94. package/src/{lib/components → components}/Card/CardBody.jsx +0 -0
  95. package/src/{lib/components → components}/Card/CardFooter.jsx +0 -0
  96. package/src/{lib/components → components}/Card/_theme.scss +0 -0
  97. package/src/{lib/components → components}/Card/_tools.scss +0 -0
  98. package/src/{lib/components → components}/Card/index.js +0 -0
  99. package/src/{lib/components → components}/CheckboxField/CheckboxField.jsx +0 -0
  100. package/src/{lib/components → components}/CheckboxField/CheckboxField.scss +0 -0
  101. package/src/{lib/components → components}/CheckboxField/index.js +0 -0
  102. package/src/{lib/components → components}/FileInputField/FileInputField.jsx +0 -0
  103. package/src/{lib/components → components}/FileInputField/FileInputField.scss +0 -0
  104. package/src/{lib/components → components}/FileInputField/index.js +0 -0
  105. package/src/{lib/components → components}/FormLayout/FormLayout.scss +0 -0
  106. package/src/{lib/components → components}/FormLayout/FormLayoutContext.js +0 -0
  107. package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.jsx +4 -4
  108. package/src/{lib/components → components}/FormLayout/FormLayoutCustomField.scss +0 -0
  109. package/src/{lib/components → components}/FormLayout/_theme.scss +0 -0
  110. package/src/{lib/components → components}/FormLayout/index.js +0 -0
  111. package/src/{lib/components → components}/Grid/Grid.scss +0 -0
  112. package/src/{lib/components → components}/Grid/GridSpan.jsx +0 -0
  113. package/src/{lib/components → components}/Grid/_helpers/generateResponsiveCustomProperties.js +0 -0
  114. package/src/{lib/components → components}/Grid/_settings.scss +0 -0
  115. package/src/{lib/components → components}/Grid/_tools.scss +0 -0
  116. package/src/{lib/components → components}/Grid/index.js +0 -0
  117. package/src/{lib/components → components}/InputGroup/InputGroupContext.js +0 -0
  118. package/src/{lib/components → components}/InputGroup/_theme.scss +0 -0
  119. package/src/{lib/components → components}/InputGroup/index.js +0 -0
  120. package/src/{lib/components → components}/Modal/Modal.scss +0 -0
  121. package/src/{lib/components → components}/Modal/ModalBody.jsx +0 -0
  122. package/src/{lib/components → components}/Modal/ModalBody.scss +0 -0
  123. package/src/{lib/components → components}/Modal/ModalCloseButton.jsx +1 -1
  124. package/src/{lib/components → components}/Modal/ModalCloseButton.scss +0 -0
  125. package/src/{lib/components → components}/Modal/ModalContent.jsx +0 -0
  126. package/src/{lib/components → components}/Modal/ModalContent.scss +0 -0
  127. package/src/{lib/components → components}/Modal/ModalFooter.jsx +0 -0
  128. package/src/{lib/components → components}/Modal/ModalFooter.scss +0 -0
  129. package/src/{lib/components → components}/Modal/ModalHeader.jsx +0 -0
  130. package/src/{lib/components → components}/Modal/ModalHeader.scss +0 -0
  131. package/src/{lib/components → components}/Modal/ModalTitle.jsx +0 -0
  132. package/src/{lib/components → components}/Modal/ModalTitle.scss +0 -0
  133. package/src/{lib/components → components}/Modal/_helpers/getJustifyClassName.js +0 -0
  134. package/src/{lib/components → components}/Modal/_helpers/getPositionClassName.js +0 -0
  135. package/src/{lib/components → components}/Modal/_helpers/getScrollingClassName.js +0 -0
  136. package/src/{lib/components → components}/Modal/_helpers/getSizeClassName.js +0 -0
  137. package/src/{lib/components → components}/Modal/_hooks/useModalFocus.js +0 -0
  138. package/src/{lib/components → components}/Modal/_settings.scss +0 -0
  139. package/src/{lib/components → components}/Modal/_theme.scss +0 -0
  140. package/src/{lib/components → components}/Modal/index.js +0 -0
  141. package/src/{lib/components → components}/Paper/Paper.jsx +0 -0
  142. package/src/{lib/components → components}/Paper/Paper.scss +0 -0
  143. package/src/{lib/components → components}/Paper/_theme.scss +0 -0
  144. package/src/{lib/components → components}/Paper/index.js +0 -0
  145. package/src/{lib/components → components}/Popover/Popover.jsx +0 -0
  146. package/src/{lib/components → components}/Popover/Popover.scss +0 -0
  147. package/src/{lib/components → components}/Popover/PopoverWrapper.jsx +0 -0
  148. package/src/{lib/components → components}/Popover/PopoverWrapper.scss +0 -0
  149. package/src/{lib/components → components}/Popover/_helpers/getRootAlignmentClassName.js +0 -0
  150. package/src/{lib/components → components}/Popover/_helpers/getRootSideClassName.js +0 -0
  151. package/src/{lib/components → components}/Popover/_theme.scss +0 -0
  152. package/src/{lib/components → components}/Popover/index.js +0 -0
  153. package/src/{lib/components → components}/Radio/index.js +0 -0
  154. package/src/{lib/components → components}/ScrollView/ScrollView.scss +0 -0
  155. package/src/{lib/components → components}/ScrollView/_helpers/getElementsPositionDifference.js +0 -0
  156. package/src/{lib/components → components}/ScrollView/_hooks/useLoadResizeHook.js +0 -0
  157. package/src/{lib/components → components}/ScrollView/_hooks/useScrollPositionHook.js +0 -0
  158. package/src/{lib/components → components}/ScrollView/index.js +0 -0
  159. package/src/{lib/components → components}/SelectField/SelectField.jsx +0 -0
  160. package/src/{lib/components → components}/SelectField/SelectField.scss +0 -0
  161. package/src/{lib/components → components}/SelectField/_components/Option/Option.jsx +0 -0
  162. package/src/{lib/components → components}/SelectField/_components/Option/index.js +0 -0
  163. package/src/{lib/components → components}/SelectField/index.js +0 -0
  164. package/src/{lib/components → components}/Table/Table.scss +0 -0
  165. package/src/{lib/components → components}/Table/_components/TableBodyCell/TableBodyCell.jsx +0 -0
  166. package/src/{lib/components → components}/Table/_components/TableBodyCell/index.js +0 -0
  167. package/src/{lib/components → components}/Table/_components/TableCell.scss +0 -0
  168. package/src/{lib/components → components}/Table/_components/TableHeaderCell/index.js +0 -0
  169. package/src/{lib/components → components}/Table/_settings.scss +0 -0
  170. package/src/{lib/components → components}/Table/index.js +0 -0
  171. package/src/{lib/components → components}/Tabs/Tabs.jsx +0 -0
  172. package/src/{lib/components → components}/Tabs/Tabs.scss +0 -0
  173. package/src/{lib/components → components}/Tabs/TabsItem.scss +0 -0
  174. package/src/{lib/components → components}/Tabs/_theme.scss +0 -0
  175. package/src/{lib/components → components}/Tabs/index.js +0 -0
  176. package/src/{lib/components → components}/Text/Text.jsx +0 -0
  177. package/src/{lib/components → components}/Text/Text.scss +0 -0
  178. package/src/{lib/components → components}/Text/_helpers/getRootClampClassName.js +0 -0
  179. package/src/{lib/components → components}/Text/_helpers/getRootHyphensClassName.js +0 -0
  180. package/src/{lib/components → components}/Text/_helpers/getRootWordWrappingClassName.js +0 -0
  181. package/src/{lib/components → components}/Text/index.js +0 -0
  182. package/src/{lib/components → components}/TextArea/TextArea.jsx +0 -0
  183. package/src/{lib/components → components}/TextArea/TextArea.scss +0 -0
  184. package/src/{lib/components → components}/TextArea/index.js +0 -0
  185. package/src/{lib/components → components}/TextField/TextField.jsx +0 -0
  186. package/src/{lib/components → components}/TextField/TextField.scss +0 -0
  187. package/src/{lib/components → components}/TextField/index.js +0 -0
  188. package/src/{lib/components → components}/TextLink/TextLink.jsx +1 -1
  189. /package/src/{lib/components → components}/TextLink/TextLink.scss +0 -0
  190. /package/src/{lib/components → components}/TextLink/_theme.scss +0 -0
  191. /package/src/{lib/components → components}/TextLink/index.js +0 -0
  192. /package/src/{lib/components → components}/Toggle/Toggle.jsx +0 -0
  193. /package/src/{lib/components → components}/Toggle/Toggle.scss +0 -0
  194. /package/src/{lib/components → components}/Toggle/index.js +0 -0
  195. /package/src/{lib/components → components}/Toolbar/Toolbar.jsx +0 -0
  196. /package/src/{lib/components → components}/Toolbar/Toolbar.scss +0 -0
  197. /package/src/{lib/components → components}/Toolbar/ToolbarGroup.jsx +0 -0
  198. /package/src/{lib/components → components}/Toolbar/ToolbarItem.jsx +0 -0
  199. /package/src/{lib/components → components}/Toolbar/_helpers/getJustifyClassName.js +0 -0
  200. /package/src/{lib/components → components}/Toolbar/_theme.scss +0 -0
  201. /package/src/{lib/components → components}/Toolbar/index.js +0 -0
  202. /package/src/{lib/components → components}/_helpers/getRootColorClassName.js +0 -0
  203. /package/src/{lib/components → components}/_helpers/getRootSizeClassName.js +0 -0
  204. /package/src/{lib/components → components}/_helpers/getRootValidationStateClassName.js +0 -0
  205. /package/src/{lib/components → components}/_helpers/isChildrenEmpty.js +0 -0
  206. /package/src/{lib/components → components}/_helpers/resolveContextOrProp.js +0 -0
  207. /package/src/{lib/components → components}/_helpers/transferProps.js +0 -0
  208. /package/src/{lib/foundation.scss → foundation.scss} +0 -0
  209. /package/src/{lib/helpers.scss → helpers.scss} +0 -0
  210. /package/src/{lib/provider → provider}/RUIContext.jsx +0 -0
  211. /package/src/{lib/provider → provider}/index.js +0 -0
  212. /package/src/{lib/provider → provider}/withGlobalProps.jsx +0 -0
  213. /package/src/{lib/styles → styles}/_utilities.scss +0 -0
  214. /package/src/{lib/styles → styles}/elements/_code.scss +0 -0
  215. /package/src/{lib/styles → styles}/elements/_links.scss +0 -0
  216. /package/src/{lib/styles → styles}/elements/_lists.scss +0 -0
  217. /package/src/{lib/styles → styles}/elements/_page.scss +0 -0
  218. /package/src/{lib/styles → styles}/elements/_rulers.scss +0 -0
  219. /package/src/{lib/styles → styles}/elements/_small.scss +0 -0
  220. /package/src/{lib/styles → styles}/generic/_box-sizing.scss +0 -0
  221. /package/src/{lib/styles → styles}/generic/_focus.scss +0 -0
  222. /package/src/{lib/styles → styles}/generic/_forms.scss +0 -0
  223. /package/src/{lib/styles → styles}/generic/_reset.scss +0 -0
  224. /package/src/{lib/styles → styles}/generic/_shared.scss +0 -0
  225. /package/src/{lib/styles → styles}/helpers/_animation.scss +0 -0
  226. /package/src/{lib/styles → styles}/settings/_animations.scss +0 -0
  227. /package/src/{lib/styles → styles}/settings/_breakpoints.scss +0 -0
  228. /package/src/{lib/styles → styles}/settings/_escaped-characters.scss +0 -0
  229. /package/src/{lib/styles → styles}/settings/_form-fields.scss +0 -0
  230. /package/src/{lib/styles → styles}/settings/_forms.scss +0 -0
  231. /package/src/{lib/styles → styles}/settings/_utilities.scss +0 -0
  232. /package/src/{lib/styles → styles}/settings/_z-indexes.scss +0 -0
  233. /package/src/{lib/styles → styles}/theme/_accessibility.scss +0 -0
  234. /package/src/{lib/styles → styles}/theme/_borders.scss +0 -0
  235. /package/src/{lib/styles → styles}/theme/_code.scss +0 -0
  236. /package/src/{lib/styles → styles}/theme/_form-fields.scss +0 -0
  237. /package/src/{lib/styles → styles}/theme/_links.scss +0 -0
  238. /package/src/{lib/styles → styles}/theme/_lists.scss +0 -0
  239. /package/src/{lib/styles → styles}/theme/_page.scss +0 -0
  240. /package/src/{lib/styles → styles}/theme/_spacing.scss +0 -0
  241. /package/src/{lib/styles → styles}/theme/_typography.scss +0 -0
  242. /package/src/{lib/styles → styles}/theme-constants/_breakpoints.scss +0 -0
  243. /package/src/{lib/styles → styles}/theme-constants/_colors.scss +0 -0
  244. /package/src/{lib/styles → styles}/theme-constants/_svg.scss +0 -0
  245. /package/src/{lib/styles → styles}/tools/_accessibility.scss +0 -0
  246. /package/src/{lib/styles → styles}/tools/_breakpoint.scss +0 -0
  247. /package/src/{lib/styles → styles}/tools/_colors.scss +0 -0
  248. /package/src/{lib/styles → styles}/tools/_reset.scss +0 -0
  249. /package/src/{lib/styles → styles}/tools/_scrollbar.scss +0 -0
  250. /package/src/{lib/styles → styles}/tools/_spacing.scss +0 -0
  251. /package/src/{lib/styles → styles}/tools/_string.scss +0 -0
  252. /package/src/{lib/styles → styles}/tools/_svg.scss +0 -0
  253. /package/src/{lib/styles → styles}/tools/_transition.scss +0 -0
  254. /package/src/{lib/styles → styles}/tools/_utilities.scss +0 -0
  255. /package/src/{lib/styles → styles}/tools/form-fields/_box-field-layout.scss +0 -0
  256. /package/src/{lib/styles → styles}/tools/form-fields/_box-field-sizes.scss +0 -0
  257. /package/src/{lib/styles → styles}/tools/form-fields/_foundation.scss +0 -0
  258. /package/src/{lib/styles → styles}/tools/form-fields/_inline-field-layout.scss +0 -0
  259. /package/src/{lib/styles → styles}/tools/form-fields/_variants.scss +0 -0
  260. /package/src/{lib/translations → translations}/en.js +0 -0
  261. /package/src/{lib/utils → utils}/classNames.js +0 -0
@@ -1,693 +0,0 @@
1
- ---
2
- name: SelectField
3
- menu: 'Inputs'
4
- route: /components/select-field
5
- ---
6
-
7
- # SelectField
8
-
9
- SelectField allows users to select one option from a set.
10
-
11
- import {
12
- Playground,
13
- Props,
14
- } from 'docz'
15
- import { SelectField } from '../..'
16
-
17
- ## Basic Usage
18
-
19
- To implement the SelectField component, you need to import it first:
20
-
21
- ```js
22
- import { SelectField } from '@react-ui-org/react-ui';
23
- ```
24
-
25
- And use it:
26
-
27
- <Playground>
28
- {() => {
29
- const [fruit, setFruit] = React.useState('apple');
30
- return (
31
- <SelectField
32
- label="Your favourite fruit"
33
- onChange={(e) => setFruit(e.target.value)}
34
- options={[
35
- {
36
- label: 'Apple',
37
- value: 'apple',
38
- },
39
- {
40
- label: 'Banana',
41
- value: 'banana',
42
- },
43
- {
44
- label: 'Grapefruit',
45
- value: 'grapefruit',
46
- },
47
- ]}
48
- value={fruit}
49
- />
50
- );
51
- }}
52
- </Playground>
53
-
54
- See [API](#api) for all available options.
55
-
56
- ## General Guidelines
57
-
58
- - Use SelectField for **many options**. For sets of just a few options
59
- (say 3 at maximum) consider using the [Radio](/components/radio) component.
60
- This will help keep your UI clean and uncluttered and prevent your users from
61
- being overwhelmed by too many options.
62
-
63
- - **Don't use for boolean** (true/false) selection or to toggle things on and
64
- off. [CheckboxField](/components/checkbox-field) and
65
- [Toggle](/components/toggle) are more suitable for such cases.
66
-
67
- - Use **short and descriptive labels**, ideally nouns rather than seemingly
68
- polite phrases like _Please select your favourite fruit_. Short labels will
69
- help your users accomplish their task faster.
70
-
71
- - Only make the SelectField's label invisible when there is **another visual
72
- clue** to guide users through filling the input. Using the first option as
73
- label is not recommended either — it disappears once user makes their choice.
74
-
75
- - When a short label is not enough, use **help texts to guide users** before
76
- they enter anything.
77
-
78
- - Use **clear, calm error messages** when there's a problem with what they
79
- entered.
80
-
81
- - In case of a large amount of options, consider **grouping related items
82
- together** by nesting them.
83
-
84
- 👉 We use the **native `select`** HTML element to improve user experience on
85
- mobile devices by using the native select of the platform.
86
-
87
- ## Design Variants
88
-
89
- To satisfy the design requirements of your project, all input fields in React UI
90
- come in two design variants to choose from: outline and filled. Both can be
91
- further [customized](#theming) with CSS custom properties.
92
-
93
- <Playground>
94
- {() => {
95
- const [fruit, setFruit] = React.useState('apple');
96
- const options = [
97
- {
98
- label: 'Apple',
99
- value: 'apple',
100
- },
101
- {
102
- label: 'Banana',
103
- value: 'banana',
104
- },
105
- {
106
- label: 'Grapefruit',
107
- value: 'grapefruit',
108
- },
109
- ];
110
- return (
111
- <>
112
- <SelectField
113
- label="Your favourite fruit"
114
- onChange={(e) => setFruit(e.target.value)}
115
- options={options}
116
- value={fruit}
117
- />
118
- <SelectField
119
- label="Your favourite fruit"
120
- onChange={(e) => setFruit(e.target.value)}
121
- options={options}
122
- variant="filled"
123
- value={fruit}
124
- />
125
- </>
126
- );
127
- }}
128
- </Playground>
129
-
130
- ## Sizes
131
-
132
- Aside from the default (medium) size, two additional sizes are available: small
133
- and large.
134
-
135
- <Playground>
136
- {() => {
137
- const [fruit, setFruit] = React.useState('apple');
138
- const options = [
139
- {
140
- label: 'Apple',
141
- value: 'apple',
142
- },
143
- {
144
- label: 'Banana',
145
- value: 'banana',
146
- },
147
- {
148
- label: 'Grapefruit',
149
- value: 'grapefruit',
150
- },
151
- ];
152
- return (
153
- <>
154
- <SelectField
155
- label="Your favourite fruit"
156
- onChange={(e) => setFruit(e.target.value)}
157
- options={options}
158
- size="small"
159
- value={fruit}
160
- />
161
- <SelectField
162
- label="Your favourite fruit"
163
- onChange={(e) => setFruit(e.target.value)}
164
- options={options}
165
- value={fruit}
166
- />
167
- <SelectField
168
- label="Your favourite fruit"
169
- onChange={(e) => setFruit(e.target.value)}
170
- options={options}
171
- size="large"
172
- value={fruit}
173
- />
174
- <SelectField
175
- label="Your favourite fruit"
176
- onChange={(e) => setFruit(e.target.value)}
177
- options={options}
178
- size="small"
179
- value={fruit}
180
- variant="filled"
181
- />
182
- <SelectField
183
- label="Your favourite fruit"
184
- onChange={(e) => setFruit(e.target.value)}
185
- options={options}
186
- value={fruit}
187
- variant="filled"
188
- />
189
- <SelectField
190
- label="Your favourite fruit"
191
- onChange={(e) => setFruit(e.target.value)}
192
- options={options}
193
- size="large"
194
- value={fruit}
195
- variant="filled"
196
- />
197
- </>
198
- );
199
- }}
200
- </Playground>
201
-
202
- Full-width fields span the full width of a parent:
203
-
204
- <Playground>
205
- {() => {
206
- const [fruit, setFruit] = React.useState('apple');
207
- const options = [
208
- {
209
- label: 'Apple',
210
- value: 'apple',
211
- },
212
- {
213
- label: 'Banana',
214
- value: 'banana',
215
- },
216
- {
217
- label: 'Grapefruit',
218
- value: 'grapefruit',
219
- },
220
- ];
221
- return (
222
- <>
223
- <SelectField
224
- fullWidth
225
- label="Your favourite fruit"
226
- onChange={(e) => setFruit(e.target.value)}
227
- options={options}
228
- value={fruit}
229
- />
230
- <SelectField
231
- fullWidth
232
- label="Your favourite fruit"
233
- onChange={(e) => setFruit(e.target.value)}
234
- options={options}
235
- value={fruit}
236
- variant="filled"
237
- />
238
- </>
239
- );
240
- }}
241
- </Playground>
242
-
243
- ## Grouping Related Options
244
-
245
- For a large amount of options you can group related items together by nesting
246
- them (implements the `optgroup` HTML element).
247
-
248
- <Playground>
249
- {() => {
250
- const [crop, setCrop] = React.useState('apple');
251
- const options = [
252
- {
253
- label: 'Fruits',
254
- options: [
255
- {
256
- label: 'Apple',
257
- value: 'apple',
258
- },
259
- {
260
- label: 'Banana',
261
- value: 'banana',
262
- },
263
- {
264
- label: 'Grapefruit',
265
- value: 'grapefruit',
266
- },
267
- ],
268
- },
269
- {
270
- label: 'Vegetables',
271
- options: [
272
- {
273
- label: 'Beetroot',
274
- value: 'beetroot',
275
- },
276
- {
277
- label: 'Carrot',
278
- value: 'carrot',
279
- },
280
- {
281
- label: 'Tomato',
282
- value: 'tomato',
283
- },
284
- ],
285
- },
286
- ];
287
- return (
288
- <>
289
- <SelectField
290
- label="Your favourite crop"
291
- onChange={(e) => setCrop(e.target.value)}
292
- options={options}
293
- value={crop}
294
- />
295
- <SelectField
296
- label="Your favourite crop"
297
- onChange={(e) => setCrop(e.target.value)}
298
- options={options}
299
- value={crop}
300
- variant="filled"
301
- />
302
- </>
303
- );
304
- }}
305
- </Playground>
306
-
307
- ## Invisible Label
308
-
309
- While it may be acceptable for login screens with just a few fields or for other
310
- simple forms, it's dangerous to hide labels from users in most cases. Keep in
311
- mind you should **provide another visual clue** so users know what to fill into
312
- the input.
313
-
314
- <Playground>
315
- {() => {
316
- const [fruit, setFruit] = React.useState('apple');
317
- const options = [
318
- {
319
- label: 'Apple',
320
- value: 'apple',
321
- },
322
- {
323
- label: 'Banana',
324
- value: 'banana',
325
- },
326
- {
327
- label: 'Grapefruit',
328
- value: 'grapefruit',
329
- },
330
- ];
331
- return (
332
- <>
333
- <SelectField
334
- isLabelVisible={false}
335
- label="Your favourite fruit"
336
- onChange={(e) => setFruit(e.target.value)}
337
- options={options}
338
- value={fruit}
339
- />
340
- <SelectField
341
- isLabelVisible={false}
342
- label="Your favourite fruit"
343
- onChange={(e) => setFruit(e.target.value)}
344
- options={options}
345
- value={fruit}
346
- variant="filled"
347
- />
348
- </>
349
- );
350
- }}
351
- </Playground>
352
-
353
- ## Horizontal Layout
354
-
355
- The default vertical layout is very easy to use and work with. However, there
356
- are situations where horizontal layout suits better — and that's why React UI
357
- supports this kind of layout as well.
358
-
359
- <Playground>
360
- {() => {
361
- const [fruit, setFruit] = React.useState('apple');
362
- const options = [
363
- {
364
- label: 'Apple',
365
- value: 'apple',
366
- },
367
- {
368
- label: 'Banana',
369
- value: 'banana',
370
- },
371
- {
372
- label: 'Grapefruit',
373
- value: 'grapefruit',
374
- },
375
- ];
376
- return (
377
- <>
378
- <SelectField
379
- label="Your favourite fruit"
380
- layout="horizontal"
381
- onChange={(e) => setFruit(e.target.value)}
382
- options={options}
383
- value={fruit}
384
- />
385
- <SelectField
386
- label="Your favourite fruit"
387
- layout="horizontal"
388
- onChange={(e) => setFruit(e.target.value)}
389
- options={options}
390
- value={fruit}
391
- variant="filled"
392
- />
393
- <SelectField
394
- fullWidth
395
- label="Your favourite fruit"
396
- layout="horizontal"
397
- onChange={(e) => setFruit(e.target.value)}
398
- options={options}
399
- value={fruit}
400
- />
401
- <SelectField
402
- fullWidth
403
- label="Your favourite fruit"
404
- layout="horizontal"
405
- onChange={(e) => setFruit(e.target.value)}
406
- options={options}
407
- value={fruit}
408
- variant="filled"
409
- />
410
- <SelectField
411
- fullWidth
412
- isLabelVisible={false}
413
- label="Your favourite fruit"
414
- layout="horizontal"
415
- onChange={(e) => setFruit(e.target.value)}
416
- options={options}
417
- value={fruit}
418
- />
419
- <SelectField
420
- fullWidth
421
- isLabelVisible={false}
422
- label="Your favourite fruit"
423
- layout="horizontal"
424
- onChange={(e) => setFruit(e.target.value)}
425
- options={options}
426
- value={fruit}
427
- variant="filled"
428
- />
429
- </>
430
- );
431
- }}
432
- </Playground>
433
-
434
- ## Help Text
435
-
436
- You may provide an additional help text to clarify how the input should be
437
- filled.
438
-
439
- <Playground>
440
- {() => {
441
- const [fruit, setFruit] = React.useState('apple');
442
- const options = [
443
- {
444
- label: 'Apple',
445
- value: 'apple',
446
- },
447
- {
448
- label: 'Banana',
449
- value: 'banana',
450
- },
451
- {
452
- label: 'Grapefruit',
453
- value: 'grapefruit',
454
- },
455
- ];
456
- return (
457
- <>
458
- <SelectField
459
- helpText="Choose one or more kinds of fruit to feel happy."
460
- label="Your favourite fruit"
461
- onChange={(e) => setFruit(e.target.value)}
462
- options={options}
463
- value={fruit}
464
- />
465
- <SelectField
466
- helpText="Choose one or more kinds of fruit to feel happy."
467
- label="Your favourite fruit"
468
- onChange={(e) => setFruit(e.target.value)}
469
- options={options}
470
- value={fruit}
471
- variant="filled"
472
- />
473
- <SelectField
474
- helpText="Choose one or more kinds of fruit to feel happy."
475
- label="Your favourite fruit"
476
- layout="horizontal"
477
- onChange={(e) => setFruit(e.target.value)}
478
- options={options}
479
- value={fruit}
480
- />
481
- <SelectField
482
- helpText="Choose one or more kinds of fruit to feel happy."
483
- label="Your favourite fruit"
484
- layout="horizontal"
485
- onChange={(e) => setFruit(e.target.value)}
486
- options={options}
487
- value={fruit}
488
- variant="filled"
489
- />
490
- <SelectField
491
- fullWidth
492
- helpText="Choose one or more kinds of fruit to feel happy."
493
- label="Your favourite fruit"
494
- layout="horizontal"
495
- onChange={(e) => setFruit(e.target.value)}
496
- options={options}
497
- value={fruit}
498
- />
499
- <SelectField
500
- fullWidth
501
- helpText="Choose one or more kinds of fruit to feel happy."
502
- label="Your favourite fruit"
503
- layout="horizontal"
504
- onChange={(e) => setFruit(e.target.value)}
505
- options={options}
506
- value={fruit}
507
- variant="filled"
508
- />
509
- </>
510
- );
511
- }}
512
- </Playground>
513
-
514
- ## States
515
-
516
- ### Validation States
517
-
518
- Validation states visually present the result of validation of the input. You
519
- should always **provide a validation message for states other than valid** so
520
- users know what happened and what action they should take or what options they
521
- have.
522
-
523
- <Playground>
524
- {() => {
525
- const [fruit, setFruit] = React.useState('apple');
526
- const options = [
527
- {
528
- label: 'Apple',
529
- value: 'apple',
530
- },
531
- {
532
- label: 'Banana',
533
- value: 'banana',
534
- },
535
- {
536
- label: 'Grapefruit',
537
- value: 'grapefruit',
538
- },
539
- ];
540
- return (
541
- <>
542
- <SelectField
543
- label="Your favourite fruit"
544
- onChange={(e) => setFruit(e.target.value)}
545
- options={options}
546
- required
547
- validationState="valid"
548
- validationText="Great, they're in stock!"
549
- value={fruit}
550
- />
551
- <SelectField
552
- label="Your favourite fruit"
553
- onChange={(e) => setFruit(e.target.value)}
554
- options={options}
555
- required
556
- validationState="warning"
557
- validationText="Oh, really?"
558
- value={fruit}
559
- />
560
- <SelectField
561
- label="Your favourite fruit"
562
- onChange={(e) => setFruit(e.target.value)}
563
- options={options}
564
- required
565
- validationState="invalid"
566
- validationText="You must select at least one kind of fruit."
567
- value={fruit}
568
- />
569
- <SelectField
570
- label="Your favourite fruit"
571
- onChange={(e) => setFruit(e.target.value)}
572
- options={options}
573
- required
574
- validationState="valid"
575
- validationText="Great, they're in stock!"
576
- value={fruit}
577
- variant="filled"
578
- />
579
- <SelectField
580
- label="Your favourite fruit"
581
- onChange={(e) => setFruit(e.target.value)}
582
- options={options}
583
- required
584
- validationState="warning"
585
- validationText="Oh, really?"
586
- value={fruit}
587
- variant="filled"
588
- />
589
- <SelectField
590
- label="Your favourite fruit"
591
- onChange={(e) => setFruit(e.target.value)}
592
- options={options}
593
- required
594
- value={fruit}
595
- validationState="invalid"
596
- validationText="You must select at least one kind of fruit."
597
- variant="filled"
598
- />
599
- </>
600
- );
601
- }}
602
- </Playground>
603
-
604
- ### Disabled State
605
-
606
- It's possible to disable just some options or the whole input.
607
-
608
- <Playground>
609
- {() => {
610
- const [fruit, setFruit] = React.useState('apple');
611
- const options = [
612
- {
613
- label: 'Apple',
614
- value: 'apple',
615
- },
616
- {
617
- disabled: true,
618
- label: 'Banana',
619
- value: 'banana',
620
- },
621
- {
622
- label: 'Grapefruit',
623
- value: 'grapefruit',
624
- },
625
- ];
626
- return (
627
- <>
628
- <SelectField
629
- label="Your favourite fruit"
630
- onChange={(e) => setFruit(e.target.value)}
631
- options={options}
632
- value={fruit}
633
- />
634
- <SelectField
635
- label="Your favourite fruit"
636
- onChange={(e) => setFruit(e.target.value)}
637
- options={options}
638
- value={fruit}
639
- variant="filled"
640
- />
641
- <SelectField
642
- disabled
643
- label="Your favourite fruit"
644
- onChange={(e) => setFruit(e.target.value)}
645
- options={options}
646
- value="apple"
647
- />
648
- <SelectField
649
- disabled
650
- label="Your favourite fruit"
651
- onChange={(e) => setFruit(e.target.value)}
652
- options={options}
653
- value="apple"
654
- variant="filled"
655
- />
656
- </>
657
- );
658
- }}
659
- </Playground>
660
-
661
- ## Forwarding HTML Attributes
662
-
663
- In addition to the options below in the [component's API](#api) section, you
664
- can specify [React synthetic events] or you can **add whatever HTML attribute
665
- you like.** All attributes that don't interfere with the API are forwarded to
666
- the native HTML `<select>`. This enables making the component interactive and helps
667
- to improve its accessibility.
668
-
669
- 👉 Refer to the MDN reference for the full list of supported attributes of the
670
- [select] element.
671
-
672
- ## Forwarding ref
673
-
674
- If you provide [ref], it is forwarded to the native HTML `<select>` element.
675
-
676
- ## API
677
-
678
- <Props table of={SelectField} />
679
-
680
- ## Theming
681
-
682
- Head to [Forms Theming](/customize/theming/forms) to see shared form theming
683
- options. On top of that, the following options are available for SelectField.
684
-
685
- | Custom Property | Description |
686
- |------------------------------------------------------|--------------------------------------------------------------|
687
- | `--rui-FormField--box--select__caret__border-style` | SelectField arrow border style (e.g. `solid`) |
688
- | `--rui-FormField--box--select__caret__background` | SelectField arrow background (including `url()` or gradient) |
689
- | `--rui-FormField--box--select__option--disabled__color` | Text color of disabled SelectField options |
690
-
691
- [React synthetic events]: https://reactjs.org/docs/events.html
692
- [select]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/select#attributes
693
- [ref]: https://reactjs.org/docs/refs-and-the-dom.html