You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
chore(Tabs): Update separate content examples (#12021)
Separate content examples did not make it clear enough that the hidden attribute on TabContent is used to set the initial state of Tabs with separate content. I updated the example so it is managed programmatically and updated the docs. I also added some tests to make sure it is working as advertised.
@@ -35,6 +46,7 @@ Tabs can be styled as 'default' or 'boxed':
35
46
- Boxed tabs are outlined to emphasize the area that a tab spans. To preview boxed tabs in the following examples, select the 'isBox' checkbox, which sets the `isBox` property to true.
36
47
37
48
```ts file="./TabsDefault.tsx"
49
+
38
50
```
39
51
40
52
### Boxed secondary tabs
@@ -44,6 +56,7 @@ To change the background color of boxed tabs or the tab content, use the `varian
44
56
Toggle the tab color by selecting the 'Tabs secondary variant' checkbox in the following example.
45
57
46
58
```ts file="./TabsBoxSecondary.tsx"
59
+
47
60
```
48
61
49
62
### Vertical tabs
@@ -53,6 +66,7 @@ Vertical tabs are placed on the left-hand side of a page or container and may ap
53
66
To style tabs vertically, use the `isVertical` property.
54
67
55
68
```ts file="./TabsVertical.tsx"
69
+
56
70
```
57
71
58
72
### Vertical expandable tabs
@@ -64,20 +78,23 @@ Expandable tabs can be enabled at different breakpoints. The following example p
64
78
To flag vertical tabs when they're expanded, use the `isExpanded` property.
65
79
66
80
```ts file="./TabsVerticalExpandable.tsx"
81
+
67
82
```
68
83
69
84
### Vertical expandable uncontrolled
70
85
71
86
To flag the default expanded state for uncontrolled tabs, use the `defaultIsExpanded` property.
By default, overflow is applied when there are too many tabs for the width of the container they are in. This overflow can be navigated by side-scrolling within the tabs section, or by selecting the left and right arrows.
79
95
80
96
```ts file="./TabsDefaultOverflow.tsx"
97
+
81
98
```
82
99
83
100
### Horizontal overflow tabs
@@ -89,6 +106,7 @@ To enable horizontal overflow, use the `isOverflowHorizontal` property.
89
106
In the following example, select the 'Show overflowing tab count' checkbox to add a count of overflow items to the final “more” tab.
90
107
91
108
```ts file="./TabsHorizontalOverflow.tsx"
109
+
92
110
```
93
111
94
112
### With tooltip react ref
@@ -98,28 +116,31 @@ When using a React ref to link a tooltip to a tab component via the `reference`
98
116
The tooltip should also have the `id` property passed in. The value of `id` should be passed into the tab's `aria-describedby` property. This ensures a tooltip used with a React ref will be announced by the JAWS and NVDA screen readers.
99
117
100
118
```ts file="./TabsTooltipReactRef.tsx"
119
+
101
120
```
102
121
103
122
### Uncontrolled tabs
104
123
105
124
To allow the `<Tabs>` component to manage setting the active tab and displaying correct content itself, use uncontrolled tabs, as shown in the following example.
106
125
107
-
108
126
```ts file="./TabsUncontrolled.tsx"
127
+
109
128
```
110
129
111
130
### With adjusted inset
112
131
113
132
To adjust the inset of tabs and visually separate them more, use the `inset` property. You can set the inset to "insetNone", "insetSm", "insetMd", "insetLg", "insetXl", or "inset2xl" at "default", "sm", "md", "lg, "xl, and "2xl" breakpoints.
114
133
115
134
```ts file="./TabsInset.tsx"
135
+
116
136
```
117
137
118
138
### With page insets
119
139
120
140
To adjust the left padding of tabs, use the `usePageInsets` property. This property aligns the tabs padding with the default padding of the page section, which makes it easier to align tabs with page section content.
121
141
122
142
```ts file="./TabsPageInsets.tsx"
143
+
123
144
```
124
145
125
146
### With icons and text
@@ -129,6 +150,7 @@ You can render different content in the `title` property of a tab to add icons a
129
150
To add an icon to a tab, pass a `<TabTitleIcon>` component that contains the icon of your choice into the `title`. To use an icon alongside styled text, keep the text in the `<TabTitleText>` component.
130
151
131
152
```ts file="./TabsIconAndText.tsx"
153
+
132
154
```
133
155
134
156
### Subtabs
@@ -138,13 +160,15 @@ Use subtabs within other components, like modals. Subtabs have less visually pro
138
160
To apply subtab styling to tabs, use the `isSubtab` property.
139
161
140
162
```ts file="./TabsSubtabs.tsx"
163
+
141
164
```
142
165
143
166
### Filled tabs with icons
144
167
145
168
To allow tabs to fill the available width of the page section, use the `isFilled` property.
146
169
147
170
```ts file="./TabsFilledWithIcons.tsx"
171
+
148
172
```
149
173
150
174
### Tabs linked to nav elements
@@ -154,27 +178,31 @@ To let tabs link to nav elements, pass `{TabsComponent.nav}` into the `component
154
178
Nav tabs should use the `href` property to link the tab to the URL of another page or page section. A tab with an `href` will render as an `<a>` instead of a `<button>`.
155
179
156
180
```ts file="./TabsNav.tsx"
181
+
157
182
```
158
183
159
184
### Subtabs linked to nav elements
160
185
161
186
Subtabs can also link to nav elements.
162
187
163
188
```ts file="./TabsNavSubtab.tsx"
189
+
164
190
```
165
191
166
192
### With separate content
167
193
168
-
If a `<TabContent>` component is defined outside of a `<Tabs>` component, use the `tabContentRef` and `tabContentId` properties
194
+
If a `<TabContent>` component is defined outside of a `<Tabs>` component, use the `tabContentRef` and `tabContentId` properties. The `hidden` property is used on `TabContent` to set the initial visible content.
169
195
170
196
```ts file="./TabsSeparateContent.tsx"
197
+
171
198
```
172
199
173
200
### With tab content with body and padding
174
201
175
202
To add a content body to a `<TabContent>` component, pass a `<TabContentBody>`. To add padding to the body section, use the `hasPadding` property.
176
203
177
204
```ts file="./TabsContentWithBodyPadding.tsx"
205
+
178
206
```
179
207
180
208
### Children mounting on click
@@ -184,29 +212,33 @@ To mount tab children (add to the DOM) when a tab is clicked, use the `mountOnEn
184
212
Note that this property does not create the tab children until the tab is clicked, so they are not preloaded into the DOM.
185
213
186
214
```ts file="./TabsChildrenMounting.tsx"
215
+
187
216
```
188
217
189
218
### Unmounting invisible children
190
219
191
220
To unmount tab children (remove from the DOM) when they are no longer visible, use the `unmountOnExit` property.
You may control tabs from outside of the tabs component. For example, select the "Hide tab 2" button below to make "Tab item 2" invisible.
228
+
You may control tabs from outside of the tabs component. For example, select the "Hide tab 2" button below to make "Tab item 2" invisible.
199
229
200
230
The tab its content should only be mounted when the tab is visible.
201
231
202
232
```ts file="./TabsToggledSeparateContent.tsx"
233
+
203
234
```
204
235
205
236
### Dynamic tabs
206
237
207
238
To enable closeable tabs, pass the `onClose` property to the `<Tabs>` component. To enable a button that adds new tabs, pass the `onAdd` property to `<Tabs>`.
208
239
209
240
```ts file="./TabsDynamic.tsx"
241
+
210
242
```
211
243
212
244
### With help action popover
@@ -216,6 +248,7 @@ You may add a help action to a tab to provide users with additional context in a
216
248
To render an action beside the tab content, use the `actions` property of a `<Tab>`. Pass a popover and a `<TabsAction>` component into the `actions` property.
217
249
218
250
```ts file="./TabsHelp.tsx"
251
+
219
252
```
220
253
221
254
### With help and close actions
@@ -225,4 +258,5 @@ To add multiple actions to a tab, create a `<TabAction>` component for each acti
225
258
The following example passes in both help popover and close actions.
0 commit comments