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 of the native component are also available.
Name | Type | Default | Description |
---|---|---|---|
action | ref | - | Callback fired when the component mounts. This is useful when you want to trigger an action programmatically. It supports two actions: |
allowScrollButtonsMobile | bool | false | If |
aria-label | string | - | The label for the Tabs as a string. |
aria-labelledby | string | - | An id or list of ids separated by a space that label the Tabs. |
centered | bool | false | If |
children | node | - | The content of the component. |
classes | object | - | Override or extend the styles applied to the component. See CSS classes API below for more details. |
component | elementType | - | 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. |
onChange | func | - | Callback fired when the value changes. Signature: function(event: React.SyntheticEvent, value: any) => void
|
orientation | 'horizontal' | 'vertical' | 'horizontal' | The component orientation (layout flow direction). |
ScrollButtonComponent | elementType | TabScrollButton | The component used to render the scroll buttons. |
scrollButtons | 'auto' | false | true | 'auto' | Determine behavior of scroll buttons when tabs are set to scroll:
By default the scroll buttons are hidden on mobile.
This behavior can be disabled with |
selectionFollowsFocus | bool | - | If |
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. |
sx | Array<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. |
TabIndicatorProps | object | {} | Props applied to the tab indicator element. |
TabScrollButtonProps | object | {} | Props applied to the |
textColor | 'inherit' | 'primary' | 'secondary' | 'primary' | Determines the color of the |
value | any | - | The value of the currently selected |
variant | 'fullWidth' | 'scrollable' | 'standard' | 'standard' | Determines additional display behavior of the tabs:
|
visibleScrollbar | bool | false | If |
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.
Slot name | Class name | Default component | Description |
---|---|---|---|
root | .MuiTabs-root | div | The component used for the popper. |
scroller | .MuiTabs-scroller | div | The component used for the scroller. |
list | .MuiTabs-list | div | The component used for the flex container. |
scrollbar | ScrollbarSize | The component used for the scroller. | |
indicator | .MuiTabs-indicator | span | The component used for the tab indicator. |
scrollButtons | .MuiTabs-scrollButtons | TabScrollButton | The component used for the scroll button. |
startScrollButtonIcon | KeyboardArrowLeft | The component used for the start scroll button icon. | |
endScrollButtonIcon | KeyboardArrowRight | The component used for the end scroll button icon. |
These class names are useful for styling with CSS. They are applied to the component's slots when specific states are triggered.
Class name | Rule name | Description |
---|---|---|
.MuiTabs-centered | centered | Styles applied to the flex container element if centered={true} & !variant="scrollable" . |
.MuiTabs-fixed | fixed | Styles applied to the tablist element if !variant="scrollable" . |
.MuiTabs-flexContainer | flexContainer | |
.MuiTabs-flexContainerVertical | flexContainerVertical | |
.MuiTabs-hideScrollbar | hideScrollbar | Styles applied to the tablist element if variant="scrollable" and visibleScrollbar={false} . |
.MuiTabs-scrollableX | scrollableX | Styles applied to the tablist element if variant="scrollable" and orientation="horizontal" . |
.MuiTabs-scrollableY | scrollableY | Styles applied to the tablist element if variant="scrollable" and orientation="vertical" . |
.MuiTabs-scrollButtonsHideMobile | scrollButtonsHideMobile | Styles applied to the ScrollButtonComponent component if allowScrollButtonsMobile={true} . |
.MuiTabs-vertical | vertical | Styles applied to the root element if orientation="vertical" . |
You can override the style of the component using one of these customization options:
- With a global class name.
- With a rule name as part of the component's
styleOverrides
property in a custom theme.
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.