Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | 9x 9x 9x 206x 33x 33x 3x 116x | import { TabList } from "@mui/lab"; import { styled, SxProps, Tab } from "@mui/material"; import { alpha } from "@mui/material/styles"; const StyledTab = styled(Tab)(({ theme }) => ({ transition: theme.transitions.create("box-shadow", { duration: 120 }), margin: `0 ${theme.spacing(0.75)}`, "&:hover, &.Mui-focusVisible": { boxShadow: `inset 0 -1px ${alpha(theme.palette.primary.main, 0.18)}`, }, [theme.breakpoints.down("md")]: { overflow: "visible", margin: `0 ${theme.spacing(1)}`, }, })); export interface TabBarProps<T extends Record<string, React.ReactNode>> { ariaLabel: string; labels: T; setValue: (value: keyof T) => void; tabSx?: SxProps; tabListSx?: SxProps; } export default function TabBar<T extends Record<string, React.ReactNode>>({ ariaLabel, setValue, labels, tabSx, tabListSx, }: TabBarProps<T>) { const handleChange = (event: React.SyntheticEvent, newValue: keyof T) => { setValue(newValue); }; return ( <TabList aria-label={ariaLabel} onChange={handleChange} indicatorColor="primary" textColor="primary" scrollButtons="auto" allowScrollButtonsMobile variant="scrollable" sx={tabListSx} > {Object.entries(labels).map(([value, label]) => ( <StyledTab key={value} label={label} value={value} sx={tabSx} /> ))} </TabList> ); } |