├── public ├── favicon.ico ├── logo192.png ├── logo512.png ├── manifest.json └── index.html ├── src ├── index.js ├── App.js ├── TabContent.js ├── TabPanel.js └── TabsDemo.js └── .gitignore /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacklawson-dev/mui-tab-panel-demo/HEAD/public/favicon.ico -------------------------------------------------------------------------------- /public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacklawson-dev/mui-tab-panel-demo/HEAD/public/logo192.png -------------------------------------------------------------------------------- /public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jacklawson-dev/mui-tab-panel-demo/HEAD/public/logo512.png -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | import ReactDOM from "react-dom" 2 | import { App } from "./App" 3 | 4 | ReactDOM.render(, document.getElementById("root")) 5 | -------------------------------------------------------------------------------- /src/App.js: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { CssBaseline } from "@material-ui/core" 3 | import { TabsDemo } from "./TabsDemo" 4 | 5 | export function App() { 6 | return ( 7 | <> 8 | 9 | 10 | 11 | ) 12 | } 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /src/TabContent.js: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | 3 | export function TabContent1() { 4 | React.useEffect(() => { 5 | console.log(`mount content component 1`) 6 | }, []) 7 | 8 | return content 1 9 | } 10 | 11 | export function TabContent2() { 12 | React.useEffect(() => { 13 | console.log(`mount content component 2`) 14 | }, []) 15 | 16 | return content 2 17 | } 18 | export function TabContent3() { 19 | React.useEffect(() => { 20 | console.log(`mount content component 3`) 21 | }, []) 22 | 23 | return content 3 24 | } 25 | -------------------------------------------------------------------------------- /public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /src/TabPanel.js: -------------------------------------------------------------------------------- 1 | import { useTabContext } from "@material-ui/lab/TabContext" 2 | 3 | export function TabPanel(props) { 4 | const { 5 | children, 6 | className, 7 | style, 8 | value: id, 9 | containerProps, 10 | ...other 11 | } = props 12 | 13 | const context = useTabContext() 14 | 15 | if (context === null) { 16 | throw new TypeError("No TabContext provided") 17 | } 18 | const tabId = context.value 19 | 20 | return ( 21 |
35 | {children} 36 |
37 | ) 38 | } 39 | -------------------------------------------------------------------------------- /src/TabsDemo.js: -------------------------------------------------------------------------------- 1 | import * as React from "react" 2 | import { Tab } from "@material-ui/core" 3 | import { TabContext, TabList } from "@material-ui/lab" 4 | import { TabPanel } from "./TabPanel" 5 | import { TabContent1, TabContent2, TabContent3 } from "./TabContent" 6 | 7 | export function TabsDemo() { 8 | const [tabId, setTabId] = React.useState("tab1") 9 | const handleChange = (event, id) => setTabId(id) 10 | 11 | return ( 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ) 29 | } 30 | -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 15 | 16 | 25 | MUI TabPanel demo 26 | 27 | 28 | 29 | 30 |
31 | 41 | 42 | 43 | --------------------------------------------------------------------------------