Skip to content

Commit 23abd17

Browse files
committed
add new features to readme
1 parent 35b854a commit 23abd17

1 file changed

Lines changed: 40 additions & 10 deletions

File tree

README.md

Lines changed: 40 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import '@github/tab-container-element'
1616

1717
```html
1818
<tab-container>
19-
<div role="tablist">
20-
<button type="button" id="tab-one" role="tab" aria-selected="true">Tab one</button>
21-
<button type="button" id="tab-two" role="tab" tabindex="-1">Tab two</button>
22-
<button type="button" id="tab-three" role="tab" tabindex="-1">Tab three</button>
23-
</div>
19+
<button type="button" id="tab-one" role="tab" aria-selected="true">Tab one</button>
20+
<button type="button" id="tab-two" role="tab" tabindex="-1">Tab two</button>
21+
<button type="button" id="tab-three" role="tab" tabindex="-1">Tab three</button>
2422
<div role="tabpanel" aria-labelledby="tab-one">
2523
Panel 1
2624
</div>
@@ -35,8 +33,17 @@ import '@github/tab-container-element'
3533

3634
### Events
3735

38-
- `tab-container-change` (bubbles, cancelable): fired on `<tab-container>` before a new tab is selected and visibility is updated. `event.detail.relatedTarget` is the tab panel that will be selected if the event isn't cancelled.
39-
- `tab-container-changed` (bubbles): fired on `<tab-container>` after a new tab is selected and visibility is updated. `event.detail.relatedTarget` is the newly visible tab panel.
36+
- `tab-container-change` (bubbles, cancelable): fired on `<tab-container>` before a new tab is selected and visibility is updated. `event.tab` is the tab that will be focused and `tab.panel` is the panel that will be shown if the event isn't cancelled.
37+
- `tab-container-changed` (bubbles): fired on `<tab-container>` after a new tab is selected and visibility is updated. `event.tab` is the tab that is now active (and will be focused right after this event) and `event.panel` is the newly visible tab panel.
38+
39+
### Parts
40+
41+
- `::part(tablist)` is the container which wraps all tabs. This element appears in ATs as it is `role=tablist`.
42+
- `::part(panel)` is the container housing the currently active tabpanel.
43+
- `::part(before-tabs)` is the container housing any elements that appear before the first `role=tab`. This also can be directly slotted with `slot=before-tabs`.
44+
- `::part(after-tabs)` is the container housing any elements that appear after the last `role=tab`. This also can be directly slotted with `slot=after-tabs`.
45+
- `::part(after-panels)` is the container housing any elements that appear after the last `role=tabpanel`. This can be useful if you want to add a visual treatment to the container but have content always appear visually below the active panel.
46+
4047

4148
### When tab panel contents are controls
4249

@@ -46,10 +53,33 @@ In those cases, apply `data-tab-container-no-tabstop` to the `tabpanel` element.
4653

4754
```html
4855
<tab-container>
49-
<div role="tablist">
50-
<button type="button" id="tab-one" role="tab" aria-selected="true">Tab one</button>
51-
<button type="button" id="tab-two" role="tab" tabindex="-1">Tab two</button>
56+
<button type="button" id="tab-one" role="tab" aria-selected="true">Tab one</button>
57+
<button type="button" id="tab-two" role="tab" tabindex="-1">Tab two</button>
58+
<div role="tabpanel" aria-labelledby="tab-one" data-tab-container-no-tabstop>
59+
<ul role="menu" aria-label="Branches">
60+
<li tabindex="0">branch-one</li>
61+
<li tabindex="0">branch-two</li>
62+
</ul>
5263
</div>
64+
<div role="tabpanel" aria-labelledby="tab-two" data-tab-container-no-tabstop hidden>
65+
<ul role="menu" aria-label="Commits">
66+
<li tabindex="0">Commit One</li>
67+
<li tabindex="0">Commit Two</li>
68+
</ul>
69+
</div>
70+
</tab-container>
71+
```
72+
73+
### Vertical tabs
74+
75+
If `<tab-container>` is given the `vertical` attribute it will apply the `aria-orientation=vertical` attribute to the tablist. This will present to ATs as a vertical tablist, and you can use the attribute to style the tabs accordingly.
76+
77+
In those cases, apply `data-tab-container-no-tabstop` to the `tabpanel` element.
78+
79+
```html
80+
<tab-container vertical>
81+
<button type="button" id="tab-one" role="tab" aria-selected="true">Tab one</button>
82+
<button type="button" id="tab-two" role="tab" tabindex="-1">Tab two</button>
5383
<div role="tabpanel" aria-labelledby="tab-one" data-tab-container-no-tabstop>
5484
<ul role="menu" aria-label="Branches">
5585
<li tabindex="0">branch-one</li>

0 commit comments

Comments
 (0)