Skip to content

Unstyled Tabs

Tabs are UI elements for organizing and navigating between groups of related content.

useTab API

Import

import useTab from '@mui/base/useTab';
// or
import { useTab } from '@mui/base';
You can learn about the difference by reading this guide on minimizing bundle size.

Parameters

NameTypeDefaultDescription
ref*React.Ref<any>
disabledboolean
onChange(event: React.SyntheticEvent, value: number | string) => void
Callback invoked when new value is being set.
onClickReact.MouseEventHandler
onFocusReact.FocusEventHandler
valuenumber | string
You can provide your own value. Otherwise, we fall back to the child position index.

Return value

NameTypeDefaultDescription
activebooleanfalse
If true, the component will be active.
disabledbooleanfalse
If true, the component will be disabled.
focusVisibleboolean
If true, the tab's focus will be visible.
getRootProps<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseTabRootSlotProps<TOther>
Resolver for the root slot's props.
selectedboolean
If true, the tab will be selected.
setFocusVisibleReact.Dispatch<React.SetStateAction<boolean>>
Callback for setting the focusVisible param.


useTabPanel API

Import

import useTabPanel from '@mui/base/useTabPanel';
// or
import { useTabPanel } from '@mui/base';
You can learn about the difference by reading this guide on minimizing bundle size.

Parameters

NameTypeDefaultDescription
value*number | string
The value of the TabPanel. It will be shown when the Tab with the corresponding value is selected.

Return value

NameTypeDefaultDescription
getRootProps() => { 'aria-labelledby': string | undefined hidden: boolean id: string | undefined }
Resolver for the root slot's props.
hiddenbooleanfalse
If true, it indicates that the tab panel will be hidden.


useTabs API

Import

import useTabs from '@mui/base/useTabs';
// or
import { useTabs } from '@mui/base';
You can learn about the difference by reading this guide on minimizing bundle size.

Parameters

NameTypeDefaultDescription
defaultValuestring | number | false
The default value. Use when the component is not controlled.
direction'ltr' | 'rtl''ltr'
The direction of the text.
onChange(event: React.SyntheticEvent, value: number | string | boolean) => void
Callback invoked when new value is being set.
orientation'horizontal' | 'vertical''horizontal'
The component orientation (layout flow direction).
selectionFollowsFocusboolean
If true the selected tab changes on focus. Otherwise it only changes on activation.
valuestring | number | false
The value of the currently selected Tab. If you don't want any selected Tab, you can set this prop to false.

Return value

NameTypeDefaultDescription
tabsContextValueTabsContextValue
Returns the values to be passed to the tabs context provider.


useTabsList API

Import

import useTabsList from '@mui/base/useTabsList';
// or
import { useTabsList } from '@mui/base';
You can learn about the difference by reading this guide on minimizing bundle size.

Parameters

NameTypeDefaultDescription
ref*React.Ref<unknown>
aria-labelstring
aria-labelledbystring
childrenReact.ReactNode
The content of the component.

Return value

NameTypeDefaultDescription
getRootProps<TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseTabsListRootSlotProps<TOther>
Resolver for the root slot's props.
isRtlbooleanfalse
If true, it will indicate that the text's direction in right-to-left.
orientation'horizontal' | 'vertical''horizontal'
The component orientation (layout flow direction).
processChildren() => React.ReactElement<any, string | React.JSXElementConstructor<any>>[] | null | undefined
Callback for processing the children of the tabs list. It adds the necessary attributes for correct a11y and navigation.
valuestring | number | false
The value of the currently selected Tab.