question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add Theme UI to material-ui transformer

See original GitHub issue

The material-ui library has its own, similar theming API. It’d be great to support using these components within a theme-ui application

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

4reactions
adamsoffercommented, Jul 29, 2019

Thanks @lemes. What I’m doing for now is using theme-ui for everything and anywhere I need to use a material component I just manually get specific theme variables from theme-ui’s context and pass it to the material-ui theme. Basically, I’m doing this for now:


export default () => {
  const context = useThemeUI()

  // Apply theme-ui settings to material-ui component
  const muiTheme = createMuiTheme({
    palette: {
      primary: {
        main: context.theme.colors.background
      },
      secondary: {
        main: context.theme.colors.grey[3]
      },
      ...
    }
  })

  return (
    <div>
      <MuiThemeProvider theme={muiTheme}>
        <MaterialTable />
      </MuiThemeProvider>
    </div>
  )
}
2reactions
jxnblkcommented, Jul 29, 2019

Yeah, ideally there would be a utility/component to use Material UI components within a Theme UI application, where the theme object is defined once in the standard format and used in multiple places. This should negate the need to manually map from one object to the other

An API for this could look something like this:

import React from 'react'
import { ThemeProvider } from 'theme-ui'
import { MaterialUIProvider } from '@theme-ui/material-ui'
import theme from './theme'

export default props =>
  <ThemeProvider theme={theme}>
    <MaterialUIProvider>
      {props.children}
    </MaterialUIProvider>
  </ThemeProvider>
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure material-ui theme on the fly? - Stack Overflow
1 Answer 1 ; '@material-ui/core' · import React · from ; 'react' · import DarkTheme from ; './DarkTheme' · import LightTheme from ...
Read more >
How to Code a Dark Theme with Material UI
Import our light/dark themes · Import our theme handler ( darkModeContext ) · Check the users localStorage to see if a preferred theme...
Read more >
Theming - Material UI - MUI
Customize MUI with your theme. You can change the colors, the typography and much more. The theme specifies the color of the components,...
Read more >
gatsby-theme-material-ui
gatsby-plugin-material-ui solves FOUC, auto prefixing and minification. gatsby-theme-material-ui uses the plugin under the hood, adds web fonts, meta-viewport, ...
Read more >
Using Breakpoints and Media Queries in Material-UI
Material-UI comes with a default theme, including breakpoints. ... In some cases, adding media queries to the styling is not enough.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found