() => {const [value, setValue] = React.useState(0);const handleChange = (event, newValue) => {setValue(newValue);};return (<TabsonChange={handleChange}variant="scrollable"scrollButtons="auto"value={value}aria-label="tabs"><Tab label="Section1" disableFocusRipple /><Tab label="Section2" disableFocusRipple /><Tab label="Section4" disableFocusRipple /><Tab label="Section5" disableFocusRipple /><Tab label="Section6" disableFocusRipple /><Tab label="Section7" disableFocusRipple /></Tabs>);};
Prop | 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: updateIndicator() and updateScrollButtons() | |
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. | |
aria-describedby | string | Identifies the element (or elements) that describes the element on which the attribute is set. | |
centered | bool | false | If true, the tabs are centered. This prop is intended for large views. |
children | node | The content of the component. | |
classes | object | object | |
onChange | func | Callback fired when the value changes. | |
orientation | horizontal | vertical | horizontal | The component orientation (layout flow direction). |
scrollButtons | auto | true | false | 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. |
ScrollButtonComponent | elementType | TabScrollButton | The component used to render the scroll buttons. |
selectionFollowsFocus | bool | If true the selected tab changes on focus. Otherwise it only changes on activation. | |
slotProps | { endScrollButtonIcon?: func | object, startScrollButtonIcon?: func | object } | {} | The extra props for the slot components. You can override the existing props or add new ones. |
slots | { EndScrollButtonIcon?: elementType, StartScrollButtonIcon?: elementType } | {} | The components used for each slot inside. |
sx | Array | The system prop that allows defining system overrides as well as additional CSS styles. | |
TabIndicatorProps | object | {} | Props applied to the tab indicator element. |
textColor | 0 | primary | Determines the color of the Tab |
value | any | The value of the currently selected Tab. If you do not want any selected Tab, you can set this prop to false. | |
variant | fullWidth | scrollable | standard | standard | Determines additional display behavior of 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. |
visibleScrollbar | bool | false | If true, the scrollbar is visible. It can be useful when displaying a long vertical list of tabs. |
() => {const [value, setValue] = React.useState(0);const handleChange = (event, newValue) => {setValue(newValue);};return (<Tabs onChange={handleChange} value={value} aria-label="tabs"><Tab label="Section1" disableFocusRipple /><Tab label="Section2" disableFocusRipple /><Tab label="Section3" disableFocusRipple /></Tabs>);};
() => {const [value, setValue] = React.useState(null);const handleChange = (event, newValue) => {setValue(newValue);};return (<Tabs onChange={handleChange} value={value} aria-label="tabs"><Tab label="Section1" disableFocusRipple /><Tab label="Section2" disableFocusRipple /><Tab label="Section3" disableFocusRipple /></Tabs>);};
Technically it is button, but this is to make it accessible with the keyboard
() => {const [value, setValue] = React.useState(0);const handleChange = (event, newValue) => {setValue(newValue);};const [openToolTipId, setOpenToolTipId] = React.useState(null);const handleTooltipClose = () => {setOpenToolTipId(null);};const handleTooltipOpen = (id) => {setOpenToolTipId(id);};const tabLabel = (tab, amount) => {return (<div><span style={{marginRight: '4px'}}>{tab}</span><><Tooltiptitle="Bad things"placement="top"disableInteractivedisableFocusListeneronClose={handleTooltipClose}open={openToolTipId === 'bad'}><Buttoncolor="error"size="small"data-testid="bad-count"onFocus={() => {handleTooltipOpen('bad');}}onBlur={() => {handleTooltipClose();}}onMouseOver={() => {handleTooltipOpen('bad');}}sx={{minWidth: '28px',padding: '0',minHeight: '18px',fontSize: '12px',border: 'none',marginRight: '4px',}}>{amount}</Button></Tooltip><Tooltiptitle="Good things"placement="top"disableInteractivedisableFocusListeneronClose={handleTooltipClose}open={openToolTipId === 'good'}><Buttoncolor="success"size="small"data-testid="good-count"onFocus={() => {handleTooltipOpen('good');}}onBlur={() => {handleTooltipClose();}}onMouseOver={() => {handleTooltipOpen('good');}}sx={{minWidth: '28px',padding: '0',minHeight: '18px',fontSize: '12px',border: 'none',}}>{amount - 40}</Button></Tooltip></></div>);};return (<Tabs onChange={handleChange} value={value} aria-label="tabs"><Tab label={tabLabel('Section1', 134)} disableFocusRipple /><Tab label="Section2" disableFocusRipple /><Tab label="Section3" disableFocusRipple /></Tabs>);};