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';Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| ref* | React.Ref<any> | ||
| disabled | boolean | ||
| onChange | (event: React.SyntheticEvent, value: number | string) => void | Callback invoked when new value is being set. | |
| onClick | React.MouseEventHandler | ||
| onFocus | React.FocusEventHandler | ||
| value | number | string | You can provide your own value. Otherwise, we fall back to the child position index. |
Return value
| Name | Type | Default | Description |
|---|---|---|---|
| active | boolean | false | If true, the component will be active. |
| disabled | boolean | false | If true, the component will be disabled. |
| focusVisible | boolean | 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. | |
| selected | boolean | If true, the tab will be selected. | |
| setFocusVisible | React.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';Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| value* | number | string | The value of the TabPanel. It will be shown when the Tab with the corresponding value is selected. |
Return value
| Name | Type | Default | Description |
|---|---|---|---|
| getRootProps | () => { 'aria-labelledby': string | undefined hidden: boolean id: string | undefined } | Resolver for the root slot's props. | |
| hidden | boolean | false | 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';Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| defaultValue | string | 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). |
| selectionFollowsFocus | boolean | If true the selected tab changes on focus. Otherwise it only
changes on activation. | |
| value | string | 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
| Name | Type | Default | Description |
|---|---|---|---|
| tabsContextValue | TabsContextValue | 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';Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| ref* | React.Ref<unknown> | ||
| aria-label | string | ||
| aria-labelledby | string | ||
| children | React.ReactNode | The content of the component. |
Return value
| Name | Type | Default | Description |
|---|---|---|---|
| getRootProps | <TOther extends Record<string, any> = {}>(externalProps?: TOther) => UseTabsListRootSlotProps<TOther> | Resolver for the root slot's props. | |
| isRtl | boolean | false | 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. | |
| value | string | number | false | The value of the currently selected Tab. |