Skip to main content

Tabs

Library
UDS Base
Repository
github.com/telus/universal-design-system
Package
npmjs.com/package/@telus-uds/ds-allium
Package version
1.14.0
Loading...

Introduction

import { Tabs } from '@telus-uds/ds-allium'

Use Tabs to display a horizontal menu of tabs that change the content shown below when pressed.

If there are too many tabs to fit the horizontal space, left and right buttons are shown.

Guidance

  • Use Tabs to show/hide a mutually exclusive content areas.
  • If the tabs should link to a wholly different page with its own URL, use SubNavigation instead
  • Recommend to use labels that are 35 characters or fewer
  • Allow the use of hashes in the URL to automatically load a tab. Eg. http://t.com#premium should load the “Premium” tab
  • Change the page URL to include the hash as tabs change

Accessibility

  • If a user is using tabbed navigation and horizontal scrolling is required, tabbing through tabs scrolls them into view automatically
  • Scrolling methods other than the scroll buttons may also be used, such as touchscreen swipes and touchpad or mousewheel scrolling
  • Consider including an assertive focus effect inside content to move screenreader focus to the appropriate heading or content start when new content is rendered

Controlled usage

Pass value and onChange to control the tabs from a parent. This is usually the easiest way to render different content for different tabs:

  • value should be the id property of the current tab in the items array
  • onChange should be a function that updates the state that selects content and is passed to value
  • To integrate with URL hashes on web so selections remain after returning to a page, choose the default state value based on the URL hash

Platform considerations

The component is available on both native platforms and web.

Touch swipes with momentum may be used to scroll through many tabs, in addition to the scroll buttons.

Keep in mind that URL hashes won't have any effect in an app.

Props

NameTypeDefaultDescription
initialValuestring
itemsArray<{ href: string, label: string, id: string, ref }>[]
itemTokenscustom
onChangefunc
scrollButtonTokenscustom
tokenscustomSystem tokens prop, see tokens for more details
valuestring
variantobjectOfSystem variant prop, see variants for more details

Tokens

In exceptional circumstances, the following tokens can be passed to this component to override its default styles. Do not do this unless absolutely necessary. Read more about overriding styles.

View Tokens
Prop NameToken PropertyToken Type
tokensnextIconicon
previousIconicon
spaceinteger
buttonClearancesize
guttersize
borderBottomColorcolor
borderBottomWidthborder
itemTokenshighlightColorcolor
highlightBarHeightborder
highlightBarBorderRadiusradius
highlightBarBorderWidthborder
highlightTriangleSizesize
backgroundColorcolor
borderColorcolor
borderWidthborder
borderRadiusradius
maxWidthsize
paddingHorizontalsize
paddingVerticalsize
spaceinteger
textAligntextAlign
lineHeightlineHeight
colorcolor
fontSizefontSize
letterSpacingletterSpacing
textTransformtextTransform
fontScaleCapfontSize
fontNamefontName
fontWeightfontWeight
scrollButtonTokensbackgroundColorcolor
borderRadiusradius
borderColorcolor
borderWidthborder
iconColorcolor
iconSizesize
iconScaleiconScale
iconTranslateXsize
iconTranslateYsize
outerBorderWidthborder
outerBorderColorcolor
outerBorderGapsize
paddingsize
shadowshadow

Figma

Variants

Inverse

  • Use on dark backgrounds.
Loading...

Feedback