ThemeProvider not working with Rebass
See original GitHub issueThemeProvider is not applying theme
To reproduce:
Simple example from the rebass documentation and create-react-app: https://rebassjs.org/getting-started
import React from 'react';
import './App.css';
import {Heading} from 'rebass'
import { ThemeProvider } from '@emotion/react'
import styled from '@emotion/styled'
const theme = ...
function App() {
return (
<ThemeProvider theme={theme}>
<div className="app">
<Heading fontSize={7}>Hello</Heading>
</div>
</ThemeProvider>
);
}
Expected behavior:
Theme is not applied to Rebass components
Environment information:
react
version: 4.0@emotion/react
version: 11.4
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Theming - Rebass
ThemeProvider. To apply themes to Rebass components, add a ThemeProvider component to the root of your application and pass a theme object as...
Read more >Rebass not picking up values defined in Theme ui theme
My index file where I wrap the App component with the ThemeProvider. Index.tsx import React from 'react'; import ReactDOM from 'react-dom'; ...
Read more >React Rebass Theming - GeeksforGeeks
We can customize the theming of project components very easily by using the theme provider. ThemeProvider: We will have to add a theme...
Read more >Theming - Rebass
To apply themes to Rebass components, add a ThemeProvider component to the root of your application and pass a theme object as a...
Read more >rebass-sandbox - CodeSandbox
OR use 'rebass/styled-components'. Browser. Tests. (0.46x). Mobile. Console. 0. Problems. 0. React DevTools. 0. All, Info, Warning, Error, Debug. b486fa213.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
When you write code like
import { ThemeProvider } from 'emotion-theming'
, your code andrebass
use same oneThemeContext
from@emotion/core
, and if your write code likeimport { ThemeProvider } from '@emotion/react
, your code use@emotion/react
’s ThemeContext andrebass
use@emotion/core
's ThemeContext, so that’s why your code not work as expected. I suggest you use emotion-theming or pushrebass
library author to support@emotion/react
(But it’s looks like inpossible causerebass
is not a active project currently).Here’s a code example: https://codesandbox.io/s/sweet-agnesi-53h0s?file=/src/App.js