Long labels will automatically wrap on tabs.
If the label is too long for the tab, it will overflow, and the text will not be visible.
<Tabsvalue={value}onChange={handleChange}aria-label="wrapped label tabs example"><Tabvalue="one"label="New Arrivals in the Longest Text of Nonfiction that should appear in the next line"wrapped/><Tabvalue="two"label="Item Two"/><Tabvalue="three"label="Item Three"/></Tabs>
Fixed tabs should be used with a limited number of tabs, and when a consistent placement will aid muscle memory.
Full width
The variant="fullWidth" prop should be used for smaller views.
This demo also uses react-swipeable-views to animate the Tab transition, and allowing tabs to be swiped on touch devices.
Item One
Centered
The centered prop should be used for larger views.
Left and right scroll buttons are never be presented with scrollButtons={false}.
All scrolling must be initiated through user agent scrolling mechanisms (e.g. left/right swipe, shift mouse wheel, etc.)
By default, the icon is positioned at the top of a tab. Other supported positions are start, end, bottom.
<Tabsvalue={value}onChange={handleChange}aria-label="icon position tabs example"><Tabicon={<PhoneIcon/>}label="top"/><Tabicon={<PhoneMissedIcon/>}iconPosition="start"label="start"/><Tabicon={<FavoriteIcon/>}iconPosition="end"label="end"/><Tabicon={<PersonPinIcon/>}iconPosition="bottom"label="bottom"/></Tabs>
Press Enter to start editing
Third-party routing library
One frequent use case is to perform navigation on the client only, without an HTTP round-trip to the server.
The Tab component provides the component prop to handle this use case.
Here is a more detailed guide.
The following steps are needed in order to provide necessary information for assistive technologies:
Label Tabs via aria-label or aria-labelledby.
Tabs need to be connected to their
corresponding [role="tabpanel"] by setting the correct id, aria-controls and aria-labelledby.
An example for the current implementation can be found in the demos on this page. We've also published an experimental API in @mui/lab that does not require
extra work.
Keyboard navigation
The components implement keyboard navigation using the "manual activation" behavior. If you want to switch to the
"selection automatically follows focus" behavior you have pass selectionFollowsFocus to the Tabs component. The WAI-ARIA authoring practices have a detailed guide on how to decide when to make selection automatically follow focus.
Demo
The following two demos only differ in their keyboard navigation behavior.
Focus a tab and navigate with arrow keys to notice the difference, e.g. Arrow Left.
/* Tabs where selection follows focus */<TabsselectionFollowsFocus/>
/* Tabs where each tab needs to be selected manually */<Tabs/>
Unstyled
The component also comes with an unstyled version. It's ideal for doing heavy customizations and minimizing bundle size.