TailwindCSS with CSS Variables #1267
Answered
by
lordelogos
andrecasal
asked this question in
Q&A
-
I have a {
theme: {
extend: {
colors: {
background: 'hsl(var(--color-background) / <alpha-value>)',
// ...
},
},
},
} declared in a @tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--color-background: 0 0% 100%; /* white */
// ...
}
} When using the The following does not work: import { Container, Head, Html, Link, Tailwind, Text, Body } from '@react-email/components'
import tailwindConfig from '../../../../tailwind.config.ts'
import tailwindStylesheetUrl from '../../../styles/tailwind.css'
export function SomeEmail() {
return (
<Tailwind config={tailwindConfig}>
<Html lang="en" dir="ltr">
<Head>
<meta charSet="utf-8" />
<title>Welcome to André Casal!</title>
<style type="text/css">{tailwindStylesheetUrl}</style>
</Head>
<Body className="bg-background">
<Container>
<h1>
<Text>Welcome to André Casal!</Text>
</h1>
</Container>
</Body>
</Html>
</Tailwind>
)
} |
Beta Was this translation helpful? Give feedback.
Answered by
lordelogos
Aug 15, 2023
Replies: 9 comments 7 replies
This comment has been hidden.
This comment has been hidden.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
-
I figured out a way to use variables directly in your You can use the plugin I made a gist containing a demo, you can find it here Let me know if you have any issues |
Beta Was this translation helpful? Give feedback.
7 replies
Answer selected by
gabrielmfern
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@andrecasal @LeathanTeal
I figured out a way to use variables directly in your
<Tailwind/>
component.You can use the plugin
@mertasan/tailwindcss-variables
NPM: @mertasan/tailwindcss-variables
I made a gist containing a demo, you can find it here
Let me know if you have any issues