Skip to content

Tabs API

API reference docs for the React Tabs component. Learn about the props, CSS, and other APIs of this exported module.

Demos

Import

import Tabs from '@mui/material/Tabs';
// or
import { Tabs } from '@mui/material';

Learn about the difference by reading this guide on minimizing bundle size.

Props

Props of the native component are also available.

NameTypeDefaultDescription
actionref-

Callback fired when the component mounts. This is useful when you want to trigger an action programmatically. It supports two actions: updateIndicator() and updateScrollButtons()

allowScrollButtonsMobileboolfalse

If true, the scroll buttons aren't forced hidden on mobile. By default the scroll buttons are hidden on mobile and takes precedence over scrollButtons.

aria-labelstring-

The label for the Tabs as a string.

aria-labelledbystring-

An id or list of ids separated by a space that label the Tabs.

centeredboolfalse

If true, the tabs are centered. This prop is intended for large views.

childrennode-

The content of the component.

classesobject-

Override or extend the styles applied to the component.

See CSS classes API below for more details.

componentelementType-

The component used for the root node. Either a string to use a HTML element or a component.

indicatorColor'primary'
| 'secondary'
| string
'primary'

Determines the color of the indicator.

onChangefunc-

Callback fired when the value changes.

Signature:function(event: React.SyntheticEvent, value: any) => void
  • event The event source of the callback. Warning: This is a generic event not a change event.
  • value We default to the index of the child (number)
orientation'horizontal'
| 'vertical'
'horizontal'

The component orientation (layout flow direction).

ScrollButtonComponentelementTypeTabScrollButton

The component used to render the scroll buttons.

scrollButtons'auto'
| false
| true
'auto'

Determine behavior of scroll buttons when tabs are set to scroll:

  • auto will only present them when not all the items are visible.
  • true will always present them.
  • false will never present them.

By default the scroll buttons are hidden on mobile. This behavior can be disabled with allowScrollButtonsMobile.

selectionFollowsFocusbool-

If true the selected tab changes on focus. Otherwise it only changes on activation.

slotProps{ endScrollButtonIcon?: func
| object, indicator?: func
| object, list?: func
| object, root?: func
| object, scrollbar?: func
| object, scrollButtons?: func
| object, scroller?: func
| object, startScrollButtonIcon?: func
| object }
{}

The props used for each slot inside.

slots{ endScrollButtonIcon?: elementType, EndScrollButtonIcon?: elementType, indicator?: elementType, list?: elementType, root?: elementType, scrollbar?: elementType, scrollButtons?: elementType, scroller?: elementType, startScrollButtonIcon?: elementType, StartScrollButtonIcon?: elementType }{}

The components used for each slot inside.

sxArray<func
| object
| bool>
| func
| object
-

The system prop that allows defining system overrides as well as additional CSS styles.

See the `sx` page for more details.

TabIndicatorPropsobject{}

Props applied to the tab indicator element.

TabScrollButtonPropsobject{}

Props applied to the TabScrollButton element.

textColor'inherit'
| 'primary'
| 'secondary'
'primary'

Determines the color of the Tab.

valueany-

The value of the currently selected Tab. If you don't want any selected Tab, you can set this prop to false.

variant'fullWidth'
| 'scrollable'
| 'standard'
'standard'

Determines additional display behavior of the tabs:

  • scrollable will invoke scrolling properties and allow for horizontally scrolling (or swiping) of the tab bar.
  • fullWidth will make the tabs grow to use all the available space, which should be used for small views, like on mobile.
  • standard will render the default state.
visibleScrollbarboolfalse

If true, the scrollbar is visible. It can be useful when displaying a long vertical list of tabs.

The ref is forwarded to the root element.

Theme default props

You can use MuiTabs to change the default props of this component with the theme.

Slots

Slot nameClass nameDefault componentDescription
root.MuiTabs-rootdivThe component used for the popper.
scroller.MuiTabs-scrollerdivThe component used for the scroller.
list.MuiTabs-listdivThe component used for the flex container.
scrollbarScrollbarSizeThe component used for the scroller.
indicator.MuiTabs-indicatorspanThe component used for the tab indicator.
scrollButtons.MuiTabs-scrollButtonsTabScrollButtonThe component used for the scroll button.
startScrollButtonIconKeyboardArrowLeftThe component used for the start scroll button icon.
endScrollButtonIconKeyboardArrowRightThe component used for the end scroll button icon.

CSS classes

These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.

Class nameRule nameDescription
.MuiTabs-centeredcenteredStyles applied to the flex container element if centered={true} & !variant="scrollable".
.MuiTabs-fixedfixedStyles applied to the tablist element if !variant="scrollable".
.MuiTabs-flexContainerflexContainer
.MuiTabs-flexContainerVerticalflexContainerVertical
.MuiTabs-hideScrollbarhideScrollbarStyles applied to the tablist element if variant="scrollable" and visibleScrollbar={false}.
.MuiTabs-scrollableXscrollableXStyles applied to the tablist element if variant="scrollable" and orientation="horizontal".
.MuiTabs-scrollableYscrollableYStyles applied to the tablist element if variant="scrollable" and orientation="vertical".
.MuiTabs-scrollButtonsHideMobilescrollButtonsHideMobileStyles applied to the ScrollButtonComponent component if allowScrollButtonsMobile={true}.
.MuiTabs-verticalverticalStyles applied to the root element if orientation="vertical".

You can override the style of the component using one of these customization options:

Source code

If you did not find the information in this page, consider having a look at the implementation of the component for more detail.