{"id":16597235,"url":"https://github.com/adrianmcli/styled-mui-next","last_synced_at":"2025-10-30T05:19:15.822Z","repository":{"id":73736872,"uuid":"122027214","full_name":"adrianmcli/styled-mui-next","owner":"adrianmcli","description":"An example application of using Styled-Components and Next.js with Material-UI","archived":false,"fork":false,"pushed_at":"2018-02-19T06:52:12.000Z","size":49,"stargazers_count":13,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-15T04:43:45.103Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/adrianmcli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-19T06:39:05.000Z","updated_at":"2021-11-29T21:16:13.000Z","dependencies_parsed_at":"2023-04-01T10:33:35.262Z","dependency_job_id":null,"html_url":"https://github.com/adrianmcli/styled-mui-next","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/adrianmcli/styled-mui-next","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fstyled-mui-next","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fstyled-mui-next/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fstyled-mui-next/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fstyled-mui-next/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adrianmcli","download_url":"https://codeload.github.com/adrianmcli/styled-mui-next/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adrianmcli%2Fstyled-mui-next/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281748750,"owners_count":26554835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-30T02:00:06.501Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T23:55:17.993Z","updated_at":"2025-10-30T05:19:15.796Z","avatar_url":"https://github.com/adrianmcli.png","language":"JavaScript","readme":"# Barebones example of Next.js with Styled-Components and Material-UI\n\nIntegrating the Material-UI with Next.js and Styled-Components can be a pain. This repo serves as an example of how to do this.\n\n## Configurable Styles\n\nThere are two configurable style files you need to be aware of:\n\n1. `/lib/styles/global-styles.js` — These are global styles that are injected via Styled-Components.\n2. `/lib/styles/mui-theme.js` — These are theme overrides for Material-UI.\n\n## Styled-Components\n\nThe API is not too complex here, much of the heavy work is done inside `/pages/_document.js`. For a better understanding of what is going on, please look at the base [example](https://github.com/zeit/next.js/tree/canary/examples/with-styled-components) from the official Next.js repo.\n\n## Material-UI\n\nMuch of the complexity is dealt with inside the two files located in the `/lib/material-ui` directory.\n\n1. `withRoot.js` is the higher-order component that needs to wrap each and every page.\n2. `getPageContext.js` is the code required for Next.js to handle how to inject Material-UI into the page. This is used inside `/pages/_document.js`.\n\n## Combining the two\n\nYou will notice that much of the work is done inside the method `getInitialProps()` inside `_document.js`.\n\n## Caveats\n\nSince the default behavior of JSS is to inject style tags at the bottom of the `\u003chead\u003e` tag in the document, the Material-UI theme will override any styled-component settings we apply on it. As a result, you have to remember to use `!important` when customizing your one-off Material-UI components with styled-components (if there are overlapping styles).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmcli%2Fstyled-mui-next","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadrianmcli%2Fstyled-mui-next","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadrianmcli%2Fstyled-mui-next/lists"}