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

For examples and details on the usage of this React component, visit the component demo pages:

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.

action

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

Type:

ref

allowScrollButtonsMobile

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.

Type:

bool

Default:

false

aria-label

The label for the Tabs as a string.

Type:

string

aria-labelledby

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

Type:

string

centered

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

Type:

bool

Default:

false

children

The content of the component.

Type:

node

classes

Override or extend the styles applied to the component.

See CSS API below for more details.

Type:

object

component

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

Type:

elementType

indicatorColor

Determines the color of the indicator.

Type:

'primary' | 'secondary' | string

Default:

'primary'

onChange

Callback fired when the value changes.

Type:

func

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

The component orientation (layout flow direction).

Type:

'horizontal' | 'vertical'

Default:

'horizontal'

ScrollButtonComponent

The component used to render the scroll buttons.

Type:

elementType

Default:

TabScrollButton

scrollButtons

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.

Type:

'auto' | false | true

Default:

'auto'

selectionFollowsFocus

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

Type:

bool

slotProps

The extra props for the slot components. You can override the existing props or add new ones.

Type:

{ endScrollButtonIcon?: func | object, startScrollButtonIcon?: func | object }

Default:

{}

slots

The components used for each slot inside.

Type:

{ EndScrollButtonIcon?: elementType, StartScrollButtonIcon?: elementType }

Default:

{}

sx

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

See the `sx` page for more details.

Type:

Array<func | object | bool> | func | object

TabIndicatorProps

Props applied to the tab indicator element.

Type:

object

Default:

{}

TabScrollButtonProps

Props applied to the TabScrollButton element.

Type:

object

Default:

{}

textColor

Determines the color of the Tab.

Type:

'inherit' | 'primary' | 'secondary'

Default:

'primary'

value

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

Type:

any

variant

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.

Type:

'fullWidth' | 'scrollable' | 'standard'

Default:

'standard'

visibleScrollbar

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

Type:

bool

Default:

false

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.


CSS

The following class names are useful for styling with CSS (the state classes are marked).
To learn more, visit the component customization page.


.MuiTabs-rootroot

Styles applied to the root element.


.MuiTabs-verticalvertical

Styles applied to the root element if orientation="vertical".


.MuiTabs-flexContainerflexContainer

Styles applied to the flex container element.


.MuiTabs-flexContainerVerticalflexContainerVertical

Styles applied to the flex container element if orientation="vertical".


.MuiTabs-centeredcentered

Styles applied to the flex container element if centered={true} & !variant="scrollable".


.MuiTabs-scrollerscroller

Styles applied to the tablist element.


.MuiTabs-fixedfixed

Styles applied to the tablist element if !variant="scrollable".


.MuiTabs-scrollableXscrollableX

Styles applied to the tablist element if variant="scrollable" and orientation="horizontal".


.MuiTabs-scrollableYscrollableY

Styles applied to the tablist element if variant="scrollable" and orientation="vertical".


.MuiTabs-hideScrollbarhideScrollbar

Styles applied to the tablist element if variant="scrollable" and visibleScrollbar={false}.


.MuiTabs-scrollButtonsscrollButtons

Styles applied to the ScrollButtonComponent component.


.MuiTabs-scrollButtonsHideMobilescrollButtonsHideMobile

Styles applied to the ScrollButtonComponent component if allowScrollButtonsMobile={true}.


.MuiTabs-indicatorindicator

Styles applied to the TabIndicator component.


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