Pular para o conteúdo

Tabs API

Documentação da API para o componente React Tabs . Aprenda sobre as propriedades disponíveis e a API CSS.

Demonstrações

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

Importação

import Tabs from '@mui/material/Tabs';
// ou
import { Tabs } from '@mui/material';
Você pode aprender sobre a diferença lendo este guia sobre como minimizar o tamanho do pacote.

Nome do componente

The name MuiTabs can be used when providing default props or style overrides in the theme.

Propriedades

Propriedades do componente nativo também estão disponíveis.

NomeTipoPadrãoDescrição
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
O conteúdo do componente.
classesobject
Sobrescreve ou extende os estilos aplicados para o componente. Veja a API CSS abaixo para maiores detalhes.
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: object, 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 group 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.
selectionFollowsFocusboolfalse
If true the selected tab changes on focus. Otherwise it only changes on activation.
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.

O ref é encaminhado para o elemento raiz.

CSS

Nome da regraClasse globalDescrição
root.MuiTabs-rootEstilos aplicados ao elemento raiz.
vertical.MuiTabs-verticalEstilos aplicados para o elemento raiz se orientation="vertical".
flexContainer.MuiTabs-flexContainerEstilos aplicados a the flex container element.
flexContainerVertical.MuiTabs-flexContainerVerticalEstilos aplicados para the flex container element se orientation="vertical".
centered.MuiTabs-centeredEstilos aplicados para the flex container element se centered={true} & !variant="scrollable".
scroller.MuiTabs-scrollerEstilos aplicados a the tablist element.
fixed.MuiTabs-fixedEstilos aplicados para the tablist element se !variant="scrollable".
scrollableX.MuiTabs-scrollableXEstilos aplicados para the tablist element se variant="scrollable" and orientation="horizontal".
scrollableY.MuiTabs-scrollableYEstilos aplicados para the tablist element se variant="scrollable" and orientation="vertical".
hideScrollbar.MuiTabs-hideScrollbarEstilos aplicados para the tablist element se variant="scrollable" and visibleScrollbar={false}.
scrollButtons.MuiTabs-scrollButtonsEstilos aplicados a the ScrollButtonComponent component.
scrollButtonsHideMobile.MuiTabs-scrollButtonsHideMobileEstilos aplicados para the ScrollButtonComponent component se allowScrollButtonsMobile={true}.
indicator.MuiTabs-indicatorEstilos aplicados a the TabIndicator component.

Você pode sobrescrever o estilo do componente usando uma dessas opções de customização: