TabScrollButton

The button that scrolls a row of tabs. A Tabs with overflowBehavior="scroll" shows one at each end while its tabs overflow; it is out of the tab order and hidden from assistive technology, since the...

The button that scrolls a row of tabs. A Tabs with overflowBehavior="scroll" shows one at each end while its tabs overflow; it is out of the tab order and hidden from assistive technology, since the arrow keys already reach every tab.

import {
  Tab,
  Tabs,
  TabScrollButton,
  type TabScrollButtonProps,
} from '@soroush.tech/design-system/Tabs'

// A button of your own, in place of the default one.
function Arrow(props: TabScrollButtonProps) {
  return <TabScrollButton {...props}>{props.direction === 'start' ? '‹' : '›'}</TabScrollButton>
}

;<Tabs overflowBehavior="scroll" slots={{ scrollButton: Arrow }} aria-label="Components">
  {names.map((name) => (
    <Tab key={name} value={name} label={name} />
  ))}
</Tabs>

Demos

For usage examples, visit the component demo page: Tabs

Import

import { TabScrollButton } from '@soroush.tech/design-system/Tabs'

Props

PropTypeDefaultDescription
direction'start' | 'end'-Which way it scrolls the row. Required.
orientation'horizontal' | 'vertical'its Tabs', else 'horizontal'The row's orientation - a chevron left/right, or up/down.
disabledbooleanfalseNowhere further to scroll this way - kept, but off.
isHiddenbooleanfalseNowhere further to scroll this way - hidden, keeping its room.
colorkeyof theme.palettethe selected tab'sIts stretch of an enclosed row's divider.
textColorkeyof theme.textits Tabs', else 'primary'The chevron's color.
onClick(event) => void-Fired when pressed. In a Tabs, it scrolls by the visible size.
childrenReactNodea chevronWhat it shows.

A replacement given through slots.scrollButton receives these same props from the Tabs.

Its styles are theme.components.Tabs.styleOverrides.scrollButton. Inside a Tabs it takes the row's look - its stretch of the divider in the enclosed look - and hides on narrow screens unless the Tabs has shouldShowScrollButtonsOnMobile. As a tab's, its own value wins: its color, then theme.components.TabScrollButton.defaultProps, then the row's line - the selected tab's color; its textColor, then the row's, then the theme's defaultProps, then the row's default.

Source code

If this page does not answer your question, have a look at the implementation of the component for more detail.