@splunk/react-ui 5.7.1 → 5.9.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 (152) hide show
  1. package/Accordion.js +6 -6
  2. package/Anchor.js +2 -1
  3. package/Box.js +83 -34
  4. package/CHANGELOG.md +51 -0
  5. package/Calendar.js +134 -134
  6. package/Clickable.js +131 -94
  7. package/CollapsiblePanel.js +175 -137
  8. package/ComboBox.js +32 -27
  9. package/ControlGroup.js +92 -91
  10. package/DefinitionList.js +9 -9
  11. package/Drawer.d.ts +2 -0
  12. package/Drawer.js +679 -0
  13. package/Dropdown.js +27 -18
  14. package/DualListbox.js +1 -1
  15. package/File.js +35 -35
  16. package/JSONTree.js +73 -72
  17. package/Link.js +2 -2
  18. package/MIGRATION.md +10 -0
  19. package/Menu.js +403 -261
  20. package/Modal.js +263 -252
  21. package/Monogram.js +2 -2
  22. package/Multiselect.js +551 -385
  23. package/Number.js +2 -1
  24. package/Paginator.js +14 -12
  25. package/Popover.js +4 -1
  26. package/README.md +11 -0
  27. package/RadioBar.js +1 -1
  28. package/Search.js +111 -95
  29. package/Select.js +42 -40
  30. package/SelectBase.js +819 -715
  31. package/SidePanel.js +346 -167
  32. package/SlidingPanels.js +11 -11
  33. package/StepBar.js +7 -7
  34. package/Switch.js +5 -5
  35. package/Table.js +116 -119
  36. package/Text.js +48 -48
  37. package/TextArea.js +7 -7
  38. package/TransitionOpen.js +188 -169
  39. package/docs-llm/Accordion.md +267 -0
  40. package/docs-llm/Anchor Menu.md +115 -0
  41. package/docs-llm/Anchor.md +54 -0
  42. package/docs-llm/AnimationToggle.md +254 -0
  43. package/docs-llm/Avatar.md +292 -0
  44. package/docs-llm/Badge.md +212 -0
  45. package/docs-llm/Breadcrumbs.md +306 -0
  46. package/docs-llm/Button Group.md +53 -0
  47. package/docs-llm/Button.md +361 -0
  48. package/docs-llm/Card Layout.md +286 -0
  49. package/docs-llm/Card.md +619 -0
  50. package/docs-llm/Checkbox.md +218 -0
  51. package/docs-llm/Chip.md +291 -0
  52. package/docs-llm/Clickable.md +160 -0
  53. package/docs-llm/Code.md +292 -0
  54. package/docs-llm/Collapsible Panel.md +744 -0
  55. package/docs-llm/Color.md +253 -0
  56. package/docs-llm/Column Layout.md +391 -0
  57. package/docs-llm/Combo Box.md +540 -0
  58. package/docs-llm/Control Group.md +594 -0
  59. package/docs-llm/Date.md +270 -0
  60. package/docs-llm/Definition List.md +278 -0
  61. package/docs-llm/Divider.md +216 -0
  62. package/docs-llm/Drawer.md +414 -0
  63. package/docs-llm/Dropdown.md +472 -0
  64. package/docs-llm/Dual Listbox.md +325 -0
  65. package/docs-llm/File.md +653 -0
  66. package/docs-llm/Form Rows.md +374 -0
  67. package/docs-llm/Heading.md +179 -0
  68. package/docs-llm/Image.md +109 -0
  69. package/docs-llm/JSON Tree.md +260 -0
  70. package/docs-llm/Layer.md +74 -0
  71. package/docs-llm/Layout.md +50 -0
  72. package/docs-llm/Link.md +318 -0
  73. package/docs-llm/List.md +189 -0
  74. package/docs-llm/Markdown.md +179 -0
  75. package/docs-llm/Menu.md +735 -0
  76. package/docs-llm/Message Bar.md +236 -0
  77. package/docs-llm/Message.md +248 -0
  78. package/docs-llm/Modal.md +443 -0
  79. package/docs-llm/Monogram.md +159 -0
  80. package/docs-llm/Multiselect.md +939 -0
  81. package/docs-llm/Notifications.md +46 -0
  82. package/docs-llm/Number.md +298 -0
  83. package/docs-llm/Paginator.md +395 -0
  84. package/docs-llm/Paragraph.md +148 -0
  85. package/docs-llm/Phone Number.md +254 -0
  86. package/docs-llm/Popover.md +166 -0
  87. package/docs-llm/Progress.md +141 -0
  88. package/docs-llm/Radio Bar.md +303 -0
  89. package/docs-llm/Radio List.md +350 -0
  90. package/docs-llm/Resize.md +362 -0
  91. package/docs-llm/Screen Reader Content.md +73 -0
  92. package/docs-llm/Scroll Container Context.md +155 -0
  93. package/docs-llm/Scroll.md +152 -0
  94. package/docs-llm/Search.md +381 -0
  95. package/docs-llm/Select.md +985 -0
  96. package/docs-llm/Side Panel.md +777 -0
  97. package/docs-llm/Slider.md +339 -0
  98. package/docs-llm/Sliding Panels.md +340 -0
  99. package/docs-llm/Split Button.md +295 -0
  100. package/docs-llm/Static Content.md +90 -0
  101. package/docs-llm/Step Bar.md +292 -0
  102. package/docs-llm/Switch.md +268 -0
  103. package/docs-llm/Tab Bar.md +439 -0
  104. package/docs-llm/Tab Layout.md +398 -0
  105. package/docs-llm/Table.md +2642 -0
  106. package/docs-llm/Text Area.md +253 -0
  107. package/docs-llm/Text.md +339 -0
  108. package/docs-llm/Tooltip.md +325 -0
  109. package/docs-llm/Transition Open.md +406 -0
  110. package/docs-llm/Tree.md +591 -0
  111. package/docs-llm/Typography.md +125 -0
  112. package/docs-llm/Wait Spinner.md +121 -0
  113. package/docs-llm/llms.txt +101 -0
  114. package/package.json +6 -5
  115. package/types/src/Box/Box.d.ts +2 -10
  116. package/types/src/Drawer/Body.d.ts +17 -0
  117. package/types/src/Drawer/Drawer.d.ts +114 -0
  118. package/types/src/Drawer/DrawerContext.d.ts +11 -0
  119. package/types/src/Drawer/Footer.d.ts +25 -0
  120. package/types/src/Drawer/Header.d.ts +41 -0
  121. package/types/src/Drawer/docs/examples/Basic.d.ts +6 -0
  122. package/types/src/Drawer/docs/examples/ContainerPosition.d.ts +7 -0
  123. package/types/src/Drawer/docs/examples/InitialFocus.d.ts +9 -0
  124. package/types/src/Drawer/docs/examples/InlinePosition.d.ts +7 -0
  125. package/types/src/Drawer/docs/examples/PagePosition.d.ts +7 -0
  126. package/types/src/Drawer/index.d.ts +2 -0
  127. package/types/src/JSONTree/JSONTree.d.ts +12 -5
  128. package/types/src/JSONTree/renderTreeItems.d.ts +2 -1
  129. package/types/src/Menu/Item.d.ts +2 -1
  130. package/types/src/Menu/docs/examples/SelectableCheckbox.d.ts +7 -0
  131. package/types/src/Modal/Modal.d.ts +1 -2
  132. package/types/src/Multiselect/Compact.d.ts +8 -3
  133. package/types/src/Multiselect/Multiselect.d.ts +8 -3
  134. package/types/src/Multiselect/Normal.d.ts +8 -3
  135. package/types/src/Multiselect/Option.d.ts +6 -3
  136. package/types/src/Multiselect/docs/examples/Disabled.d.ts +1 -0
  137. package/types/src/Select/Option.d.ts +6 -3
  138. package/types/src/Select/Select.d.ts +8 -5
  139. package/types/src/Select/docs/examples/Dimmed.d.ts +7 -0
  140. package/types/src/SelectBase/OptionBase.d.ts +6 -3
  141. package/types/src/SelectBase/SelectBase.d.ts +8 -3
  142. package/types/src/SidePanel/SidePanel.d.ts +43 -2
  143. package/types/src/SidePanel/docs/examples/DockLayout.d.ts +17 -0
  144. package/types/src/SidePanel/docs/examples/InitialFocus.d.ts +9 -0
  145. package/types/src/TransitionOpen/TransitionOpen.d.ts +29 -4
  146. package/types/src/useKeyPress/index.d.ts +9 -2
  147. package/types/src/useOnClickOutside/index.d.ts +2 -0
  148. package/types/src/useOnClickOutside/useOnClickOutside.d.ts +4 -0
  149. package/useKeyPress.js +23 -18
  150. package/useOnClickOutside.d.ts +2 -0
  151. package/useOnClickOutside.js +79 -0
  152. package/types/src/RadioList/docs/examples/Row.d.ts +0 -6
@@ -0,0 +1,439 @@
1
+ # Tab Bar
2
+
3
+ ## Overview
4
+
5
+
6
+ > Image: Illustration of a Tab Bar component.
7
+
8
+
9
+ ## When to use this component
10
+ - To group related content into different categories.
11
+ - Space is limited and you want to present multiple options to users.
12
+ - To organize forms, dashboards or other content to keep users focused on their primary tasks.
13
+
14
+ ## When to use another component
15
+ - Consider using a Collapsible Panel if the content is non-essential or supplemental.
16
+ - Users need to navigate to a specific page in a single view; consider a Paginator.
17
+ - Content requires immediate attention; try using a Modal.
18
+ - Use a Switch - Toggle when choices are opposing options (on/off, yes/no).
19
+
20
+ ```mermaid
21
+ graph TD
22
+ accDescr: Decision tree that guides on when to use the TabBar component or something else
23
+ A(Do you need to organize multiple sections within the same view?) -- Yes --- B(Is each section of content mutually exclusive?)
24
+ B -- No --- C(List)
25
+ B -- Yes --- D(Do you need to preserve vertical space?)
26
+ D -- Yes --- E(Collapsible Panel)
27
+ D -- No --- F(Tab Bar)
28
+ A -- No --- G(Card)
29
+ ```
30
+
31
+ ### Check out
32
+ - [Collapsible Panel][1]
33
+ - [Paginator][2]
34
+ - [Modal][3]
35
+ - [Switch][4]
36
+ - [Card][5]
37
+ - [List][6]
38
+
39
+ ## Behaviors
40
+
41
+ ### Always display a selection
42
+ By default, select the first Tab when showcasing a Tab Bar to indicate its content.
43
+
44
+ > Image: Example showing the importance of always having a selected Tab in a Tab Bar. The first example with the heart eyes emoji displays a selected Tab and the second example with a grimacing emoji displays no selected Tabs.
45
+
46
+
47
+
48
+ ## Usage
49
+
50
+ ### Pair icons with labels
51
+ Only using icons isn’t an effective way to communicate Tab content.
52
+
53
+ > Image: Example showing how to correctly use icons within the Tab Bar component. The first example with the heart eyes emoji displays three Tabs, each with an icon that corresponds to their respective labels:
54
+
55
+
56
+ #### Make icons consistent
57
+ Maintain visual balance when using icons. All Tab Bar labels should include them.
58
+
59
+ > Image: Example showing how to maintain a visual balance while using the Tab Bar component. The first example with the heart eyes emoji displays consistent use of icons in all Tabs, where as the second example with a grimacing emoji displays inconsistent icon usage in the Tabs.
60
+
61
+
62
+ ### No less than two Tab items
63
+
64
+ > Image: Example showing the minimum number of tabs required (at least 2). The first example with the heart eyes emoji displays 2 Tabs in the Tab Bar, whereas the second example with a grimacing emoji displays only 1 Tab in the Tab Bar.
65
+
66
+
67
+ ### No more than seven Tab items
68
+ Limit the Tab Bar component to no more than seven tab items, following Miller’s Law, which suggests that people can effectively manage around 7 (+/- 2) chunks of information at once. This principle helps to reduce cognitive load, allowing users to navigate and comprehend the available options more easily.
69
+
70
+ > Image: Example showing the maximum number of tabs required - at most 7 (based on Miller
71
+
72
+
73
+ ### Content organization
74
+ Content within a Tab should be directly related to the selected Tab title.
75
+
76
+ > Image: Example showing how content within a Tab should be directly related to the selected Title. The first example with the heart eyes emoji displays a correlation between Tab contents and Tab Title:
77
+
78
+
79
+
80
+ ## Content
81
+
82
+ ### Use sentence case, not title case.
83
+ Only the first letter of the first word should be capitalized unless it's a proper noun.
84
+
85
+ > Image: Example showing the comparison of how to correctly use sentence case and capitalization in Tab titles. The first example with the heart eyes emoji displays the title written in sentence case, with only the first letter of the first word capitalized:
86
+
87
+
88
+ > Image: Example showing the comparison of how to correctly use sentence case and capitalization in Tab titles. The first example with the heart eyes emoji displays the title written in sentence case, with only the first letter of the first word capitalized:
89
+
90
+
91
+ ### Be concise
92
+ Avoid articles (“a”, “an”, “the”) and do not end Tab labels with punctuation.
93
+
94
+ > Image: Example showing the correct article usage in a Tab title. The first example with the heart eyes emoji displays the use of no articles:
95
+
96
+
97
+ > Image: Example showing the correct punctuation usage in a Tab title. The first example with the heart eyes emoji displays the use of no punctuation:
98
+
99
+
100
+ ### Avoid truncation
101
+ Labels shouldn’t drop to a second line, so use clear, simple naming.
102
+
103
+ > Image: Example showing how to use clear and simple label names for Tabs titles in a Tab Bar. The first example with the heart eyes emoji displays a Tab title with only 1-2 words, whereas the second example with a grimacing emoji displays a Tab title that is too long and should be avoided.
104
+
105
+
106
+ [1]: ./Collapsiblepanel
107
+ [2]: ./Paginator
108
+ [3]: ./Modal
109
+ [4]: ./Switch
110
+ [5]: ./Card
111
+ [6]: ./List
112
+
113
+ ## Examples
114
+
115
+
116
+ ### Basic
117
+
118
+ ```typescript
119
+ import React, { useCallback, useState } from 'react';
120
+
121
+ import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
122
+
123
+
124
+ function Basic() {
125
+ const [activeTabId, setActiveTabId] = useState<string | undefined>('one');
126
+
127
+ const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
128
+ setActiveTabId(selectedTabId);
129
+ }, []);
130
+
131
+ return (
132
+ <TabBar activeTabId={activeTabId} onChange={handleChange}>
133
+ <TabBar.Tab label="Tab one" tabId="one" />
134
+ <TabBar.Tab label="Tab two" tabId="two" />
135
+ <TabBar.Tab label="Tab three" tabId="three" />
136
+ <TabBar.Tab label="Tab four" tabId="four" />
137
+ <TabBar.Tab label="Tab five" tabId="five" />
138
+ </TabBar>
139
+ );
140
+ }
141
+
142
+ export default Basic;
143
+ ```
144
+
145
+
146
+
147
+ ### With count
148
+
149
+ ```typescript
150
+ import React, { useCallback, useState } from 'react';
151
+
152
+ import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
153
+
154
+
155
+ function WithCount() {
156
+ const [activeTabId, setActiveTabId] = useState<string | undefined>('one');
157
+
158
+ const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
159
+ setActiveTabId(selectedTabId);
160
+ }, []);
161
+
162
+ return (
163
+ <TabBar activeTabId={activeTabId} onChange={handleChange}>
164
+ <TabBar.Tab label="Tab one" tabId="one" count={1} />
165
+ <TabBar.Tab disabled label="Tab two" tabId="two" count={13} />
166
+ <TabBar.Tab label="Tab three" tabId="three" count={0} />
167
+ <TabBar.Tab label="Tab four" tabId="four" count={4} />
168
+ <TabBar.Tab label="Tab five" tabId="five" count={908} />
169
+ </TabBar>
170
+ );
171
+ }
172
+
173
+ export default WithCount;
174
+ ```
175
+
176
+
177
+
178
+ ### Icons
179
+
180
+ Icons can be used in tabs to provide additional context. Use icons sparingly and only when they add value that the text alone cannot communicate. Icon only tabs are not recommended. If you do use an icon only tab, a tooltip is required to provide an accessible name to the tab.
181
+
182
+ ```typescript
183
+ import React, { useCallback, useState } from 'react';
184
+
185
+ import ChartBar from '@splunk/react-icons/ChartBar';
186
+ import Layout from '@splunk/react-icons/Layout';
187
+ import List from '@splunk/react-icons/List';
188
+ import Magnifier from '@splunk/react-icons/Magnifier';
189
+ import Table from '@splunk/react-icons/Table';
190
+ import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
191
+
192
+
193
+ function IconsLeft() {
194
+ const [activeTabId, setActiveTabId] = useState<string | undefined>('search');
195
+
196
+ const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
197
+ setActiveTabId(selectedTabId);
198
+ }, []);
199
+ return (
200
+ <TabBar activeTabId={activeTabId} onChange={handleChange}>
201
+ <TabBar.Tab label="Search" icon={<Magnifier />} tabId="search" />
202
+ <TabBar.Tab label="Digger" icon={<List />} tabId="events" />
203
+ <TabBar.Tab label="Statistics" icon={<Table />} tabId="data" />
204
+ <TabBar.Tab label="Visualizations" icon={<ChartBar />} tabId="dist" />
205
+ <TabBar.Tab label="Dashboards" icon={<Layout />} tabId="dashboards" />
206
+ </TabBar>
207
+ );
208
+ }
209
+
210
+ export default IconsLeft;
211
+ ```
212
+
213
+
214
+
215
+ ### Vertical
216
+
217
+ ```typescript
218
+ import React, { useCallback, useState } from 'react';
219
+
220
+ import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
221
+
222
+
223
+ function Vertical() {
224
+ const [activeTabId, setActiveTabId] = useState<string | undefined>('one');
225
+
226
+ const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
227
+ setActiveTabId(selectedTabId);
228
+ }, []);
229
+
230
+ return (
231
+ <TabBar activeTabId={activeTabId} onChange={handleChange} layout="vertical">
232
+ <TabBar.Tab label="Tab one" tabId="one" />
233
+ <TabBar.Tab label="Tab two" tabId="two" />
234
+ <TabBar.Tab label="Tab three" tabId="three" />
235
+ <TabBar.Tab label="Tab four" tabId="four" />
236
+ <TabBar.Tab label="Tab five" tabId="five" />
237
+ </TabBar>
238
+ );
239
+ }
240
+
241
+ export default Vertical;
242
+ ```
243
+
244
+
245
+
246
+ ### Vertical icons
247
+
248
+ ```typescript
249
+ import React, { useCallback, useState } from 'react';
250
+
251
+ import ChartBar from '@splunk/react-icons/ChartBar';
252
+ import Layout from '@splunk/react-icons/Layout';
253
+ import List from '@splunk/react-icons/List';
254
+ import Magnifier from '@splunk/react-icons/Magnifier';
255
+ import Table from '@splunk/react-icons/Table';
256
+ import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
257
+
258
+
259
+ function VerticalIconsLeft() {
260
+ const [activeTabId, setActiveTabId] = useState<string | undefined>('search');
261
+
262
+ const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
263
+ setActiveTabId(selectedTabId);
264
+ }, []);
265
+
266
+ return (
267
+ <TabBar activeTabId={activeTabId} onChange={handleChange} layout="vertical">
268
+ <TabBar.Tab label="Search" icon={<Magnifier />} tabId="search" />
269
+ <TabBar.Tab label="Digger" icon={<List />} tabId="events" />
270
+ <TabBar.Tab label="Statistics" icon={<Table />} tabId="data" />
271
+ <TabBar.Tab label="Visualizations" icon={<ChartBar />} tabId="dist" />
272
+ <TabBar.Tab label="Dashboards" icon={<Layout />} tabId="dashboards" />
273
+ </TabBar>
274
+ );
275
+ }
276
+
277
+ export default VerticalIconsLeft;
278
+ ```
279
+
280
+
281
+
282
+ ### Disabled
283
+
284
+ ```typescript
285
+ import React, { useCallback, useState } from 'react';
286
+
287
+ import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
288
+
289
+
290
+ function Disabled() {
291
+ const [activeTabId, setActiveTabId] = useState<string | undefined>('one');
292
+
293
+ const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
294
+ setActiveTabId(selectedTabId);
295
+ }, []);
296
+
297
+ return (
298
+ <TabBar activeTabId={activeTabId} onChange={handleChange}>
299
+ <TabBar.Tab label="Tab one" tabId="one" />
300
+ <TabBar.Tab disabled label="Tab two" tabId="two" />
301
+ <TabBar.Tab disabled label="Tab three" tabId="three" />
302
+ <TabBar.Tab disabled label="Tab four" tabId="four" />
303
+ <TabBar.Tab label="Tab five" tabId="five" />
304
+ </TabBar>
305
+ );
306
+ }
307
+
308
+ export default Disabled;
309
+ ```
310
+
311
+
312
+
313
+ ### Tooltips
314
+
315
+ Tooltips must be used when the entire tab label is not visible: e.g. due to truncation. The tooltip will override the accessible name of the tab. Tooltips should not be used to add a description or additional information.
316
+
317
+ ```typescript
318
+ import React, { useCallback, useState } from 'react';
319
+
320
+ import TabBar, { TabBarChangeHandler } from '@splunk/react-ui/TabBar';
321
+
322
+
323
+ function Tooltips() {
324
+ const [activeTabId, setActiveTabId] = useState<string | undefined>('one');
325
+
326
+ const handleChange: TabBarChangeHandler = useCallback((e, { selectedTabId }) => {
327
+ setActiveTabId(selectedTabId);
328
+ }, []);
329
+
330
+ return (
331
+ <TabBar activeTabId={activeTabId} onChange={handleChange}>
332
+ <TabBar.Tab label="Tab one" tabId="one" tooltip="1.0" />
333
+ <TabBar.Tab label="Tab two" tabId="two" tooltip="2.0" />
334
+ <TabBar.Tab label="Tab three" tabId="three" tooltip="3.0" />
335
+ <TabBar.Tab label="Tab four" tabId="four" tooltip="4.0" />
336
+ <TabBar.Tab label="Tab five" tabId="five" tooltip="5.0" />
337
+ </TabBar>
338
+ );
339
+ }
340
+
341
+ export default Tooltips;
342
+ ```
343
+
344
+
345
+
346
+
347
+ ## API
348
+
349
+
350
+ ### TabBar API
351
+
352
+ #### Props
353
+
354
+ | Name | Type | Required | Default | Description |
355
+ |------|------|------|------|------|
356
+ | activeTabId | string | no | | The `tabId` of the `TabBar.Tab` to activate. |
357
+ | autoActivate | boolean | no | | If `true`, tabs will trigger the `onChange` callback when they receive focus. |
358
+ | children | React.ReactNode | no | | Must be `TabBar.Tab`. |
359
+ | elementRef | React.Ref<HTMLDivElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
360
+ | iconPosition | 'above' \| 'left' | no | 'left' | **DEPRECATED**: This prop is deprecated and will be removed in the next major version. Position of icon in `TabBar.Tab` if it has an icon. Defaults to "left". |
361
+ | layout | 'horizontal' \| 'vertical' | no | 'horizontal' | The layout of tabs. |
362
+ | maxTabWidth | number | no | | Max width of each `TabBar.Tab` in pixels. Leave blank for auto max width. |
363
+ | onChange | TabBarChangeHandler | no | | A callback that receives the event and data (`selectedTabId`). |
364
+
365
+ #### Types
366
+
367
+ | Name | Type | Description |
368
+ |------|------|------|
369
+ | TabBarChangeHandler | ( event: React.MouseEvent<HTMLButtonElement> \| React.FocusEvent<HTMLButtonElement>, data: { selectedTabId?: string } ) => void | |
370
+ | TabBarOnKeyDownHandler | (event: React.KeyboardEvent<HTMLInputElement>) => void | |
371
+
372
+
373
+
374
+ ### TabBar.Tab API
375
+
376
+ #### Props
377
+
378
+ | Name | Type | Required | Default | Description |
379
+ |------|------|------|------|------|
380
+ | ariaControls | string | no | | The ariaControls prop is the element `id` of the content displayed when the tab is selected. |
381
+ | count | number | no | | Inserts number in tab label. |
382
+ | disabled | boolean | no | | Prevents user from clicking the tab. |
383
+ | elementRef | React.Ref<HTMLButtonElement \| HTMLAnchorElement> | no | | A React ref which is set to the DOM element when the component mounts and null when it unmounts. |
384
+ | icon | React.ReactNode | no | | See Icon documentation for more information. |
385
+ | id | string | no | | Placed on the clickable element. For accessibility, the related content must have an `aria-labelledby` attribute that matches this `id`. The `id` must be unique within the document, unlike `tabId`, which must be unique within the `TabBar` instance. |
386
+ | label | React.ReactNode | no | | The text shown in the button. |
387
+ | tabId | string | no | | A unique `id` for this tab and used by the `TabBar` to keep track of the open tab. If not provided, one will be automatically generated for the tab. |
388
+ | to | string | no | | Identifies the URL for a link. If set, Splunk UI applies an <a> tag instead of a <button> tag. |
389
+ | tooltip | React.ReactNode | no | | Content to show in a tooltip when the user hovers over or focuses on the Tab. Note: The tooltip will override the label for the Tab for screen readers. |
390
+
391
+
392
+
393
+
394
+
395
+ ## Accessibility
396
+
397
+ > NOT suported by design system: tab list overflow, configurable (add, delete, reorder) tab lists
398
+
399
+ ## Visual Design
400
+ - Color contrast ratio **MUST** be:
401
+ - &gt= 4.5:1 for normal text: 14 pt (typically 18.66px) and bold or larger [SC 1.4.3][1]
402
+ - &gt= 3:1 for large text: 18 pt (typically 24px) or larger [SC 1.4.3][1]
403
+ - &gt= 3:1 for tab bar against page background [SC 1.4.11][2]
404
+ - Focus State: if the focus ring has a radius of [SC 1.4.11][2]
405
+ - &lt 3px: &gt= 4.5.1 between button &lt&gt focus &lt&gt background
406
+ - &gt 3px: &gt= 3.1 button button &lt&gt focus &lt&gt background
407
+ - `alt=""` for decorative icons [SC 1.1.1][3]
408
+
409
+ ## States
410
+ - Color contrast guidelines do not apply to disabled tabs
411
+
412
+ ## Interaction Design
413
+ - **Define Manual vs. Automatic:** Designers **MUST** specify which interaction model they want in specs for engineering. By default, Splunk Design System uses manual tabs and supports automatic tabs.
414
+ - **Automatic activation:** When a user focuses on a tab, it automatically loads. This is recommended for static text and some images.
415
+ - **Manual activation:** A user must click the tab or use <kbd>Enter/Space</kbd> to load the content in tabs. This is recommended for dynamic content such as tables, visualizations, etc.
416
+ - Focus state does **SHOULD NOT** cover visual design elements that illustate which tab a user is on, or that the elements are not the same color as the selected bar.
417
+ - **MUST** have keyboard navigation [SC 2.1][4]:
418
+ - <kbd>Tab</kbd> and <kbd>Shift+Tab</kbd> to move into the tablist, focusing on active tab
419
+
420
+ - A second <kbd>Tab</kbd> and <kbd>Shift+Tab</kbd> moves to the next interactive element in the sequence
421
+ - If the design has a tablist that runs..
422
+ - Horizontally: <kbd>Left</kbd> and <kbd>Right Arrow</kbd> to circle thru tabs
423
+ - Vertically: <kbd>Up</kbd> and <kbd>Down Arrow</kbd> to circle thru tabs
424
+ - disabled tabs **MUST** be skipped in navigation
425
+
426
+ ## Implementation
427
+ - Tabs **MUST** be implemented as a list so users receive correct information
428
+ - As a fallback mechanism, this allows tabs to gracefully degrade back to a list of content
429
+ - Tabs as part of a navigation bar **MUST** be implemented as links and use manual navigation
430
+ - If tabs use quantifier, this number **MUST** to be announced by screen reader
431
+ - Vertical tab bars **MUST** have `aria-orientation=vertical`
432
+ - Observe specifications for manual or automatic activation as prescribed by the interaction model section
433
+
434
+ [1]: https://www.w3.org/TR/WCAG21/#contrast-minimum
435
+ [2]: https://www.w3.org/TR/WCAG21/#non-text-contrast
436
+ [3]: https://www.w3.org/TR/WCAG21/#non-text-content
437
+ [4]: https://www.w3.org/TR/WCAG21/#keyboard-accessible
438
+
439
+