gpt4 book ai didi

javascript - 启用带有情感的全局主题?

转载 作者:行者123 更新时间:2023-11-28 09:15:56 25 4
gpt4 key购买 nike

我关注了https://github.com/emotion-js/emotion/issues/546其中 Emotion 的作者 Kye 提到了一个解决方案,虽然我没有完全理解。

所以我做了一个小CodeSandBox实现问题中提供的详细信息。如何让 background-color 主题在 injectGlobal 中工作?

最佳答案

为使用情绪 10 的人们更新:

import React from 'react'
import { useTheme, ThemeProvider } from 'emotion-theming'
import { css, Global } from '@emotion/core'

const GlobalStyles = () => {
const theme = useTheme()
return (
<Global styles={css`
body {
background: ${theme.bg};
}
`} />
)
}


const App = () => (
<ThemeProvider theme={{ bg: 'tomato' }}>
<main>
<h1>Hi</h1>
<GlobalStyles />
</main>
</ThemeProvider>
)

关于javascript - 启用带有情感的全局主题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51637950/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com