|
| 1 | +import * as React from 'react'; |
| 2 | +import { useTheme } from '@mui/system'; |
| 3 | +import Tabs from '@mui/base/Tabs'; |
| 4 | +import TabsList from '@mui/base/TabsList'; |
| 5 | +import TabPanel from '@mui/base/TabPanel'; |
| 6 | +import { buttonClasses } from '@mui/base/Button'; |
| 7 | +import Tab, { tabClasses } from '@mui/base/Tab'; |
| 8 | + |
| 9 | +export default function UnstyledTabsCustomized() { |
| 10 | + return ( |
| 11 | + <React.Fragment> |
| 12 | + <Tabs defaultValue={1}> |
| 13 | + <TabsList className="CustomTabsList"> |
| 14 | + <Tab className="CustomTab" value={1}> |
| 15 | + One |
| 16 | + </Tab> |
| 17 | + <Tab className="CustomTab" value={2}> |
| 18 | + Two |
| 19 | + </Tab> |
| 20 | + <Tab className="CustomTab" value={3}> |
| 21 | + Three |
| 22 | + </Tab> |
| 23 | + </TabsList> |
| 24 | + <TabPanel className="CustomTabPanel" value={1}> |
| 25 | + First page |
| 26 | + </TabPanel> |
| 27 | + <TabPanel className="CustomTabPanel" value={2}> |
| 28 | + Second page |
| 29 | + </TabPanel> |
| 30 | + <TabPanel className="CustomTabPanel" value={3}> |
| 31 | + Third page |
| 32 | + </TabPanel> |
| 33 | + </Tabs> |
| 34 | + <Styles /> |
| 35 | + </React.Fragment> |
| 36 | + ); |
| 37 | +} |
| 38 | + |
| 39 | +const cyan = { |
| 40 | + 50: '#E9F8FC', |
| 41 | + 100: '#BDEBF4', |
| 42 | + 200: '#99D8E5', |
| 43 | + 300: '#66BACC', |
| 44 | + 400: '#1F94AD', |
| 45 | + 500: '#0D5463', |
| 46 | + 600: '#094855', |
| 47 | + 700: '#063C47', |
| 48 | + 800: '#043039', |
| 49 | + 900: '#022127', |
| 50 | +}; |
| 51 | + |
| 52 | +function useIsDarkMode() { |
| 53 | + const theme = useTheme(); |
| 54 | + return theme.palette.mode === 'dark'; |
| 55 | +} |
| 56 | + |
| 57 | +function Styles() { |
| 58 | + // Replace this with your app logic for determining dark mode |
| 59 | + const isDarkMode = useIsDarkMode(); |
| 60 | + return ( |
| 61 | + <style> |
| 62 | + {` |
| 63 | + .CustomTabsList { |
| 64 | + min-width: 400px; |
| 65 | + background-color: ${cyan[500]}; |
| 66 | + border-radius: 12px; |
| 67 | + margin-bottom: 16px; |
| 68 | + display: flex; |
| 69 | + align-items: center; |
| 70 | + justify-content: center; |
| 71 | + align-content: space-between; |
| 72 | + box-shadow: 0px 4px 6px ${ |
| 73 | + isDarkMode ? 'rgba(0,0,0, 0.4)' : 'rgba(0,0,0, 0.2)' |
| 74 | + }; |
| 75 | + } |
| 76 | +
|
| 77 | + .CustomTab { |
| 78 | + font-family: 'IBM Plex Sans', sans-serif; |
| 79 | + color: white; |
| 80 | + cursor: pointer; |
| 81 | + font-size: 0.875rem; |
| 82 | + font-weight: bold; |
| 83 | + background-color: transparent; |
| 84 | + width: 100%; |
| 85 | + line-height: 1.5; |
| 86 | + padding: 8px 12px; |
| 87 | + margin: 6px; |
| 88 | + border: none; |
| 89 | + border-radius: 8px; |
| 90 | + display: flex; |
| 91 | + justify-content: center; |
| 92 | + } |
| 93 | +
|
| 94 | + .CustomTab:hover { |
| 95 | + background-color: ${cyan[400]}; |
| 96 | + } |
| 97 | +
|
| 98 | + .CustomTab:focus { |
| 99 | + color: #fff; |
| 100 | + outline: 3px solid ${cyan[200]}; |
| 101 | + } |
| 102 | +
|
| 103 | + .CustomTab.${tabClasses.selected} { |
| 104 | + background-color: #fff; |
| 105 | + color: ${cyan[600]}; |
| 106 | + } |
| 107 | +
|
| 108 | + .CustomTab.${buttonClasses.disabled} { |
| 109 | + opacity: 0.5; |
| 110 | + cursor: not-allowed; |
| 111 | + } |
| 112 | +
|
| 113 | + .CustomTabPanel { |
| 114 | + width: 100%; |
| 115 | + font-family: 'IBM Plex Sans', sans-serif; |
| 116 | + font-size: 0.875rem; |
| 117 | + } |
| 118 | + `} |
| 119 | + </style> |
| 120 | + ); |
| 121 | +} |
0 commit comments