Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/react-core/src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ export interface TabsProps extends Omit<React.HTMLProps<HTMLElement | HTMLDivEle
isBox?: boolean;
/** Enables vertical tab styling */
isVertical?: boolean;
/** Enables no border bottom tab styling */
hasBorderBottom?: boolean;
/** Aria-label for the left scroll button */
leftScrollAriaLabel?: string;
/** Aria-label for the right scroll button */
Expand Down Expand Up @@ -135,6 +137,7 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
isSecondary: false,
isVertical: false,
isBox: false,
hasBorderBottom: true,
leftScrollAriaLabel: 'Scroll left',
rightScrollAriaLabel: 'Scroll right',
component: TabsComponent.div,
Expand Down Expand Up @@ -288,6 +291,7 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
isSecondary,
isVertical,
isBox,
hasBorderBottom,
leftScrollAriaLabel,
rightScrollAriaLabel,
'aria-label': ariaLabel,
Expand Down Expand Up @@ -356,6 +360,7 @@ export class Tabs extends React.Component<TabsProps, TabsState> {
isBox && styles.modifiers.box,
showScrollButtons && !isVertical && styles.modifiers.scrollable,
usePageInsets && styles.modifiers.pageInsets,
!hasBorderBottom && styles.modifiers.noBorderBottom,
formatBreakpointMods(inset, styles),
variantStyle[variant],
className
Expand Down
17 changes: 17 additions & 0 deletions packages/react-core/src/components/Tabs/__tests__/Tabs.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,20 @@ test('should render box tabs of light variant', () => {
expect(view.container).toMatchSnapshot();
});

test('should render tabs with no bottom border', () => {
const view = render(
<Tabs id="noBottomBorderTabs" hasBorderBottom={false}>
<Tab id="tab1" eventKey={0} title={<TabTitleText>"Tab item 1"</TabTitleText>}>
Tab 1 section
</Tab>
<Tab id="tab2" eventKey={1} title={<TabTitleText>"Tab item 2"</TabTitleText>}>
Tab 2 section
</Tab>
<Tab id="tab3" eventKey={2} title={<TabTitleText>"Tab item 3"</TabTitleText>}>
Tab 3 section
</Tab>
</Tabs>
);
expect(view.container).toMatchSnapshot();
});

Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,149 @@ exports[`should render tabs with eventKey Strings 1`] = `
</div>
`;

exports[`should render tabs with no bottom border 1`] = `
<div>
<div
class="pf-c-tabs pf-m-no-border-bottom"
data-ouia-component-id="OUIA-Generated-Tabs-14"
data-ouia-component-type="PF4/Tabs"
data-ouia-safe="true"
id="noBottomBorderTabs"
>
<button
aria-hidden="true"
aria-label="Scroll left"
class="pf-c-tabs__scroll-button"
disabled=""
>
<svg
aria-hidden="true"
fill="currentColor"
height="1em"
role="img"
style="vertical-align: -0.125em;"
viewBox="0 0 256 512"
width="1em"
>
<path
d="M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z"
/>
</svg>
</button>
<ul
class="pf-c-tabs__list"
>
<li
class="pf-c-tabs__item pf-m-current"
>
<button
aria-controls="pf-tab-section-0-tab1"
class="pf-c-tabs__link"
data-ouia-component-type="PF4/TabButton"
data-ouia-safe="true"
id="pf-tab-0-tab1"
>
<span
class="pf-c-tabs__item-text"
>
"Tab item 1"
</span>
</button>
</li>
<li
class="pf-c-tabs__item"
>
<button
aria-controls="pf-tab-section-1-tab2"
class="pf-c-tabs__link"
data-ouia-component-type="PF4/TabButton"
data-ouia-safe="true"
id="pf-tab-1-tab2"
>
<span
class="pf-c-tabs__item-text"
>
"Tab item 2"
</span>
</button>
</li>
<li
class="pf-c-tabs__item"
>
<button
aria-controls="pf-tab-section-2-tab3"
class="pf-c-tabs__link"
data-ouia-component-type="PF4/TabButton"
data-ouia-safe="true"
id="pf-tab-2-tab3"
>
<span
class="pf-c-tabs__item-text"
>
"Tab item 3"
</span>
</button>
</li>
</ul>
<button
aria-hidden="true"
aria-label="Scroll right"
class="pf-c-tabs__scroll-button"
disabled=""
>
<svg
aria-hidden="true"
fill="currentColor"
height="1em"
role="img"
style="vertical-align: -0.125em;"
viewBox="0 0 256 512"
width="1em"
>
<path
d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z"
/>
</svg>
</button>
</div>
<section
aria-labelledby="pf-tab-0-tab1"
class="pf-c-tab-content"
data-ouia-component-type="PF4/TabContent"
data-ouia-safe="true"
id="pf-tab-section-0-tab1"
role="tabpanel"
tabindex="0"
>
Tab 1 section
</section>
<section
aria-labelledby="pf-tab-1-tab2"
class="pf-c-tab-content"
data-ouia-component-type="PF4/TabContent"
data-ouia-safe="true"
hidden=""
id="pf-tab-section-1-tab2"
role="tabpanel"
tabindex="0"
>
Tab 2 section
</section>
<section
aria-labelledby="pf-tab-2-tab3"
class="pf-c-tab-content"
data-ouia-component-type="PF4/TabContent"
data-ouia-safe="true"
hidden=""
id="pf-tab-section-2-tab3"
role="tabpanel"
tabindex="0"
>
Tab 3 section
</section>
</div>
`;

exports[`should render tabs with separate content 1`] = `
<div>
<div
Expand Down
5 changes: 5 additions & 0 deletions packages/react-core/src/demos/Tabs.md
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ TabsOpenWithSecondaryTabsDemo = () => {
```js isFullscreen file="./examples/Tabs/TabsAndTable.tsx"
```

### Tables and tabs, auto width tabs

```js isFullscreen file="./examples/Tabs/TabsAndTablesAutoWidthTabs.tsx"
```

### Modal tabs

```js isFullscreen file="./examples/Tabs/ModalTabs.tsx"
Expand Down
Loading