Skip to content

Commit 65eb0de

Browse files
author
Luke Bowerman
authored
docs(Tabs): Per user-feedback simplify Tabs documentation to more clearly illustrate common use-cases (#2097)
1 parent b1da0c7 commit 65eb0de

File tree

1 file changed

+41
-65
lines changed
  • www/src/documentation/components/content

1 file changed

+41
-65
lines changed

www/src/documentation/components/content/tabs.mdx

Lines changed: 41 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -3,81 +3,57 @@ title: Tabs
33
storybook: true
44
---
55

6-
Tabs expects to receive a TabList with one or more Tab components. TabPanels expects TabPanel(s). Tabs manages the visibility of a single TabPanel based on its internal state.
6+
`Tabs` expects to receive a `TabList` with one or more `Tab` components. `TabPanels` expects `TabPanel`(s). `Tabs` manages the visibility of a single `TabPanel` based on its internal state.
77

8-
The order in which elements are placed inside TabList and TabPanels defines the relationship between them. The first Tab is related to the first TabPanel and so on.
8+
The order in which elements are placed inside `TabList` and `TabPanels` defines the relationship between them. The first `Tab` is related to the first `TabPanel` and so on.
99

10-
To create a disabled Tab add the disabled prop. You must still create a TabPanel for each Tab to keep the index positions in sync.
10+
```jsx
11+
<Tabs>
12+
<TabList>
13+
<Tab>Dog</Tab>
14+
<Tab>Cat</Tab>
15+
</TabList>
16+
<TabPanels>
17+
<TabPanel>🐶 Dog</TabPanel>
18+
<TabPanel>🐱 Cat</TabPanel>
19+
</TabPanels>
20+
</Tabs>
21+
```
22+
23+
## Horizonal Scroll
1124

12-
Tabs supports scrolling when the number of Tabs are greater then the space alocated for it. - Try scrolling left-right.
25+
`Tabs` supports scrolling when the tabs' combined width cannot be accomdated within the viewport width. - Try scrolling left-right.
26+
27+
```jsx
28+
<Tabs>
29+
<TabList>
30+
<Tab>Really long tab title that should help demonstrate side-scroll</Tab>
31+
<Tab>Yet-another-tab-title to get things width enough</Tab>
32+
<Tab>Really, you must be obsessed with these long tab titles?</Tab>
33+
<Tab>Okay, okay, we get it you want to see scrolling in action...</Tab>
34+
</TabList>
35+
<TabPanels>
36+
<TabPanel>Tab Content 1</TabPanel>
37+
<TabPanel>Tab Content 2</TabPanel>
38+
<TabPanel>Tab Content 3</TabPanel>
39+
<TabPanel>Tab Content 4</TabPanel>
40+
</TabPanels>
41+
</Tabs>
42+
```
43+
44+
## Disabled Tab(s)
45+
46+
To create a disabled Tab add the `disabled` prop. NOTE: A `TabPanel` must still exist for disabled tabs to allow for tabs to keep the index positions in sync.
1347
1448
```jsx
1549
<Tabs>
1650
<TabList>
17-
<Tab>Dog</Tab>
1851
<Tab>Cat</Tab>
19-
<Tab disabled>Human</Tab>
20-
<Tab>Fox</Tab>
21-
<Tab>Monkey</Tab>
22-
<Tab>Lion</Tab>
23-
<Tab>Pig</Tab>
24-
<Tab>Frog</Tab>
25-
<Tab>Mouse</Tab>
26-
<Tab>Bear</Tab>
27-
<Tab>Cow</Tab>
52+
<Tab disabled>Dog</Tab>
2853
</TabList>
2954
<TabPanels>
30-
<TabPanel>
31-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
32-
🐶 Dog
33-
</Heading>
34-
</TabPanel>
35-
<TabPanel>
36-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
37-
🐱 Cat
38-
</Heading>
39-
</TabPanel>
40-
<TabPanel>Placeholder for disabled "Human" tab</TabPanel>
41-
<TabPanel>
42-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
43-
🦊 Fox
44-
</Heading>
45-
</TabPanel>
46-
<TabPanel>
47-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
48-
🐵 Monkey
49-
</Heading>
50-
</TabPanel>
51-
<TabPanel>
52-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
53-
🦁 Lion
54-
</Heading>
55-
</TabPanel>
56-
<TabPanel>
57-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
58-
🐷 Pig
59-
</Heading>
60-
</TabPanel>
61-
<TabPanel>
62-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
63-
🐸 Frog
64-
</Heading>
65-
</TabPanel>
66-
<TabPanel>
67-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
68-
🐭 Mouse
69-
</Heading>
70-
</TabPanel>
71-
<TabPanel>
72-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
73-
🐻 Bear
74-
</Heading>
75-
</TabPanel>
76-
<TabPanel>
77-
<Heading fontWeight="SemiBold" fontSize="xxxlarge">
78-
🐮 Cow
79-
</Heading>
80-
</TabPanel>
55+
<TabPanel>🐱 Cat</TabPanel>
56+
<TabPanel>🐶 Dog</TabPanel>
8157
</TabPanels>
8258
</Tabs>
8359
```

0 commit comments

Comments
 (0)