Skip to content

Commit 3ab0518

Browse files
committed
feat(docs): Updated Tailwind "Known limitations"
1 parent daa68f2 commit 3ab0518

File tree

1 file changed

+6
-56
lines changed

1 file changed

+6
-56
lines changed

apps/docs/components/tailwind.mdx

Lines changed: 6 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ const Email = () => {
170170
## Known limitations
171171

172172
<AccordionGroup>
173-
<Accordion title="Support up to Tailwind v3.3.2">
174-
Due to an internal technical limitation, we are still running on Tailwind `3.3.2`. This is
175-
because Tailwind migrated into using async APIs internally after [`3.3.3`](https://github.com/tailwindlabs/tailwindcss/releases/tag/v3.3.3)
176-
and the only way we can migrate is by using Suspense on the Tailwind component which would
177-
force everyone into using only `renderAsync`.
173+
<Accordion title="No support for contexts inside the component">
174+
Currently adding a context's provider inside of the Tailwind component, won't allow you
175+
to properly call the `useContext` in any of the children of it, due to some technical limitations
176+
regarding on how we currently map the classNames into styles.
178177

179-
You can track our progress on [this issue](https://github.com/resend/react-email/issues/1372).
178+
The current workaround for this right now is to move the context's provider higher than the Tailwind
179+
component, so that all children inside Tailwind can properly call `useContext` with the context.
180180
</Accordion>
181181
<Accordion title="No support for prose from @tailwindcss/typography">
182182
We do not yet support `prose`, and beyond that, we don't yet support classes that might
@@ -196,54 +196,4 @@ do the same for `hover:` styles though, but since [their support is not best](ht
196196
In the future, we will be inlining all the styles we can by actually matching the
197197
selectors *against the elements* themselves.
198198
</Accordion>
199-
<Accordion title="Limitations when trying to manipulate classes">
200-
Currently, the component works, at a high level, going through the following steps:
201-
202-
1. Do a very surface-level rendering on the children to have something resembling the HTML
203-
2. Run `tailwind` as a `postcss` plugin in the new fake rendered email template to generate a CSS stylesheet with all the styles of the template
204-
3. Generate a map of all the class names pointing to their respective styles
205-
4. Run recursively through all elements, and their children, by looking up class by class to add the appropriate styles to it while removing the classes
206-
207-
The biggest cause of limitation here is going to be `1.`. Since that fake rendering process does not render
208-
the components, that means that, if a class name doesn't appear in the resulting HTML, it won't have
209-
its style either, so the class isn't removed. Here's an example:
210-
211-
```jsx
212-
const Component = ({ className, style }) => {
213-
console.log(className, style);
214-
return <div className={`bg-red-500`} style={style} />;
215-
};
216-
217-
export default function Email() {
218-
return <Tailwind>
219-
<Component className="bg-blue-400" />
220-
</Tailwind>;
221-
};
222-
```
223-
224-
The prop for `className` will come in as `bg-blue-400` which would seem like you can manipulate the `className`,
225-
but once you add it somewhere to the resulting HTML, like:
226-
227-
```jsx
228-
const Component = ({ className, style }) => {
229-
console.log(className, style);
230-
return <div className={`bg-red-500 ${className}`} style={style} />;
231-
};
232-
233-
export default function Email() {
234-
return <Tailwind>
235-
<Component className="bg-blue-400" />
236-
</Tailwind>;
237-
};
238-
```
239-
240-
The email will render with a red background and a `class="undefined"` attribute as the class will have
241-
been removed. This means that manipulations are very unstable in the current version.
242-
243-
In a future version, the behavior is going to be of resolving the styles regardless of them appearing
244-
in the HTML, and it will not remove the classes that were inlined if they were done in a React component,
245-
so that you are able to manipulate both the `className` and `style` at the same time.
246-
247-
On small email templates this is most likely not going to be an issue, though.
248-
</Accordion>
249199
</AccordionGroup>

0 commit comments

Comments
 (0)