Skip to content

🎥 Make videos programmatically with React

`@remotion/tailwind-v4`: New package

Jonny Burgere0a912b2a974
diff --git a/packages/cli/package.json b/packages/cli/package.json
index 56fbc2f55d..4fdb3bf19c 100644
--- a/packages/cli/package.json
+++ b/packages/cli/package.json
@@ -57,6 +57,7 @@
"@types/prompts": "^2.4.1",
"@types/prettier": "^2.7.2",
"@remotion/zod-types": "workspace:*",
+ "@remotion/tailwind-v4": "workspace:*",
"@remotion/enable-scss": "workspace:*",
"@remotion/skia": "workspace:*",
"react": "19.0.0",
diff --git a/packages/create-video/src/add-tailwind.ts b/packages/create-video/src/add-tailwind.ts
index 629ca89ccf..c74d1ccd72 100644
--- a/packages/create-video/src/add-tailwind.ts
+++ b/packages/create-video/src/add-tailwind.ts
@@ -19,6 +19,7 @@ export default {
export const addTailwindRootCss = (projectRoot: string) => {
const rootFileTsx = path.join(projectRoot, 'src', 'Root.tsx');
const rootFileJsx = path.join(projectRoot, 'src', 'Root.jsx');
+ const indexCss = path.join(projectRoot, 'src', 'index.css');
const rootFile = fs.existsSync(rootFileTsx) ? rootFileTsx : rootFileJsx;
@@ -28,8 +29,11 @@ export const addTailwindRootCss = (projectRoot: string) => {
const root = fs.readFileSync(rootFile, 'utf-8');
- const newFile = `@import "tailwindcss";\n${root}`;
+ const newFile = `import "./index.css";\n${root}`;
fs.writeFileSync(rootFile, newFile);
+
+ const css = `@import "tailwindcss";\n`;
+ fs.writeFileSync(indexCss, css);
};
export const addTailwindToConfig = (projectRoot: string) => {
diff --git a/packages/docs/components/TableOfContents/api.tsx b/packages/docs/components/TableOfContents/api.tsx
index 9329099624..f49c517161 100644
--- a/packages/docs/components/TableOfContents/api.tsx
+++ b/packages/docs/components/TableOfContents/api.tsx
@@ -10,6 +10,7 @@ import {TableOfContents as OpenAiWhisperTableOfContents} from '../../docs/openai
import {PlayerTableOfContents} from '../../docs/player/TableOfContents';
import {TableOfContents as SkiaTableOfContents} from '../../docs/skia/TableOfContents';
import {TableOfContents as StudioTableOfContents} from '../../docs/studio/TableOfContents';
+import {TableOfContents as TailwindV4TableOfContents} from '../../docs/tailwind-v4/TableOfContents';
import {TableOfContents as TailwindTableOfContents} from '../../docs/tailwind/TableOfContents';
import {TableOfContents as ThreeTableOfContents} from '../../docs/three/TableOfContents';
import {TableOfContents as WebcodecsTableOfContents} from '../../docs/webcodecs/TableOfContents';
@@ -83,8 +84,11 @@ export const TableOfContents: React.FC = () => {
<p>Obtain info about video and audio.</p>
<AnimationUtilsTableOfContents />
<h2>@remotion/tailwind</h2>
- <p>Webpack override for using TailwindCSS</p>
+ <p>Webpack override for using TailwindCSS v3</p>
<TailwindTableOfContents />
+ <h2>@remotion/tailwind-v4</h2>
+ <p>Webpack override for using TailwindCSS v4</p>
+ <TailwindV4TableOfContents />
<h2>@remotion/enable-scss</h2>
<p>Webpack override for enabling SASS/SCSS</p>
<EnableScssTableOfContents />
diff --git a/packages/docs/docs/overwriting-webpack-config.mdx b/packages/docs/docs/overwriting-webpack-config.mdx
index 8bb1ca594b..18c62c9384 100644
--- a/packages/docs/docs/overwriting-webpack-config.mdx
+++ b/packages/docs/docs/overwriting-webpack-config.mdx
@@ -112,7 +112,7 @@ If you have multiple overrides, you should curry them:
```tsx twoslash
import {Config} from '@remotion/cli/config';
import {enableScss} from '@remotion/enable-scss';
-import {enableTailwind} from '@remotion/tailwind';
+import {enableTailwind} from '@remotion/tailwind-v4';
Config.overrideWebpackConfig((c) => enableScss(enableTailwind(c)));
```
@@ -122,7 +122,7 @@ From Remotion v4.0.229, you can also use `Config.overrideWebpackConfig` multiple
```tsx twoslash
import {Config} from '@remotion/cli/config';
import {enableScss} from '@remotion/enable-scss';
-import {enableTailwind} from '@remotion/tailwind';
+import {enableTailwind} from '@remotion/tailwind-v4';
Config.overrideWebpackConfig(enableScss);
Config.overrideWebpackConfig(enableTailwind);
@@ -147,9 +147,7 @@ export const enableMdx: WebpackOverrideFn = (currentConfiguration) => {
module: {
...currentConfiguration.module,
rules: [
- ...(currentConfiguration.module?.rules
- ? currentConfiguration.module.rules
- : []),
+ ...(currentConfiguration.module?.rules ? currentConfiguration.module.rules : []),
{
test: /\.mdx?$/,
use: [
@@ -231,9 +229,7 @@ export const enableSvgr: WebpackOverrideFn = (currentConfiguration) => {
return {
...r,
// Remove Remotion loading SVGs as a URL
- test: new RegExp(
- r.test.toString().replace(/svg\|/g, '').slice(1, -1),
- ),
+ test: new RegExp(r.test.toString().replace(/svg\|/g, '').slice(1, -1)),
};
}),
],
@@ -277,9 +273,7 @@ export const enableGlsl: WebpackOverrideFn = (currentConfiguration) => {
module: {
...currentConfiguration.module,
rules: [
- ...(currentConfiguration.module?.rules
- ? currentConfiguration.module.rules
- : []),
+ ...(currentConfiguration.module?.rules ? currentConfiguration.module.rules : []),
{
test: /\.(glsl|vs|fs|vert|frag)$/,
exclude: /node_modules/,
diff --git a/packages/docs/docs/tailwind-v4/TableOfContents.tsx b/packages/docs/docs/tailwind-v4/TableOfContents.tsx
new file mode 100644
index 0000000000..52c85055f2
--- /dev/null
+++ b/packages/docs/docs/tailwind-v4/TableOfContents.tsx
@@ -0,0 +1,16 @@
+import React from 'react';
+import {Grid} from '../../components/TableOfContents/Grid';
+import {TOCItem} from '../../components/TableOfContents/TOCItem';
+
+export const TableOfContents: React.FC = () => {
+ return (
+ <div>
+ <Grid>
+ <TOCItem link="/docs/tailwind-v4/enable-tailwind">
+ <strong>{'enableTailwind()'}</strong>
+ <div>Override the Webpack config to enable TailwindCSS</div>
+ </TOCItem>
+ </Grid>
+ </div>
+ );
+};
diff --git a/packages/docs/docs/tailwind-v4/enable-tailwind.mdx b/packages/docs/docs/tailwind-v4/enable-tailwind.mdx
new file mode 100644
index 0000000000..de4eed7fed
--- /dev/null
+++ b/packages/docs/docs/tailwind-v4/enable-tailwind.mdx
@@ -0,0 +1,35 @@
+---
+title: enableTailwind()
+crumb: '@remotion/tailwind-v4'
+---
+
+_available from v4.0.256_
+
+A function that modifies the default Webpack configuration to make the necessary changes to support TailwindCSS.
+See the [setup](/docs/tailwind) to see full instructions on how to setup TailwindCSS in Remotion.
+
+```ts twoslash title="remotion.config.ts"
+import {Config} from '@remotion/cli/config';
+import {enableTailwind} from '@remotion/tailwind-v4';
+
+Config.overrideWebpackConfig((currentConfiguration) => {
+ return enableTailwind(currentConfiguration);
+});
+```
+
+## Multiple Webpack changes
+
+If you want to make other configuration changes, you can do so by doing them reducer-style:
+
+```ts twoslash title="remotion.config.ts"
+import {Config} from '@remotion/cli/config';
+import {enableTailwind} from '@remotion/tailwind-v4';
+
+Config.overrideWebpackConfig((currentConfiguration) => {
+ return enableTailwind({
+ ...currentConfiguration,
+
+ // Make other changes
+ });
+});
+```
diff --git a/packages/docs/docs/tailwind-v4/overview.mdx b/packages/docs/docs/tailwind-v4/overview.mdx
new file mode 100644
index 0000000000..1d0ee64777
--- /dev/null
+++ b/packages/docs/docs/tailwind-v4/overview.mdx
@@ -0,0 +1,37 @@
+---
+id: tailwind
+sidebar_label: Overview
+title: '@remotion/tailwind-v4'
+---
+
+import Tabs from '@theme/Tabs';
+import TabItem from '@theme/TabItem';
+import {ExperimentalBadge} from '../../components/Experimental';
+import {TableOfContents} from './TableOfContents';
+
+This package provides utilities useful for integrating [TailwindCSS v4](https://tailwindcss.com/) with Remotion, as documented on our [TailwindCSS](/docs/tailwind) page.
+
+## Installation
+
+Install `@remotion/tailwind-v4` as well as TailwindCSS dependencies.
+
+<Installation pkg="@remotion/tailwind-v4" />
+
+<br />
+
+[Override the Webpack config](/docs/webpack) by using [`enableTailwind()`](/docs/tailwind/enable-tailwind).
+
+```ts twoslash title="remotion.config.ts"
+import {Config} from '@remotion/cli/config';
+import {enableTailwind} from '@remotion/tailwind-v4';
+
+Config.overrideWebpackConfig((currentConfiguration) => {
+ return enableTailwind(currentConfiguration);
+});
+```
+
+Then follow the remaining set up steps from the [TailwindCSS](/docs/tailwind) page.
+
+## APIs
+
+<TableOfContents />
diff --git a/packages/docs/docs/tailwind.mdx b/packages/docs/docs/tailwind.mdx
index 1d3aa64e9e..65f747db8d 100644
--- a/packages/docs/docs/tailwind.mdx
+++ b/packages/docs/docs/tailwind.mdx
@@ -55,7 +55,92 @@ yarn create video
The following templates support scaffolding with TailwindCSS: <TailwindSupport />
-## Install in existing project
+## Installing Tailwind v4 in existing project
+
+_from v4.0.256_
+
+1. Install [`@remotion/tailwind-v4`](/docs/tailwind-v4/tailwind) package and TailwindCSS dependencies.
+
+<Tabs
+defaultValue="npm"
+values={[
+{ label: 'npm', value: 'npm', },
+{ label: 'yarn', value: 'yarn', },
+{ label: 'pnpm', value: 'pnpm', },
+]
+}>
+<TabItem value="npm">
+
+```bash
+npm i -D @remotion/tailwind-v4
+```
+
+ </TabItem>
+
+ <TabItem value="yarn">
+
+```bash
+yarn add -D @remotion/tailwind-v4
+```
+
+ </TabItem>
+ <TabItem value="pnpm">
+
+```bash
+pnpm i -D @remotion/tailwind-v4
+```
+
+ </TabItem>
+</Tabs>
+
+2. Add the Webpack override from `@remotion/tailwind-v4` to your config file:
+
+```ts twoslash title="remotion.config.ts"
+import {Config} from '@remotion/cli/config';
+import {enableTailwind} from '@remotion/tailwind-v4';
+
+Config.overrideWebpackConfig((currentConfiguration) => {
+ return enableTailwind(currentConfiguration);
+});
+```
+
+3. If you use the [`bundle()` or `deploySite()` Node.JS API, add the Webpack override to it as well](/docs/webpack#when-using-bundle-and-deploysite).
+
+4. Create a file `postcss.config.mjs` with the following content:
+
+```css title="postcss.config.mjs"
+export default {
+ plugins: {
+ "@tailwindcss/postcss": {},
+ },
+};
+```
+
+5. Create a file `src/index.css` with the following content:
+
+```css title="src/index.css"
+@import 'tailwindcss';
+```
+
+5. Import the stylesheet in your `src/Root.tsx` file. Add to the top of the file:
+
+```js title="src/Root.tsx"
+import './index.css';
+```
+
+7. Ensure your `package.json` does not have `"sideEffects": false` set. If it has, declare that CSS files have a side effect:
+
+```diff title="package.json"
+{
+// Only if `"sideEffects": false` exists in your package.json.
+- "sideEffects": false
++ "sideEffects": ["*.css"]
+}
+```
+
+8. Start using TailwindCSS! You can verify that it's working by adding `className="bg-red-900"` to any element.
+
+## Installing Tailwind v3 in existing project
_from v3.3.95, see [instructions for older versions](https://github.com/remotion-dev/remotion/blob/88a5d8d17f50d6ab2b8a408556118d15a3686343/packages/docs/docs/tailwind.md)_
diff --git a/packages/docs/docs/tailwind/enable-tailwind.mdx b/packages/docs/docs/tailwind/enable-tailwind.mdx
index e851ca36f0..6eb6aa3c3f 100644
--- a/packages/docs/docs/tailwind/enable-tailwind.mdx
+++ b/packages/docs/docs/tailwind/enable-tailwind.mdx
@@ -6,6 +6,11 @@ crumb: '@remotion/tailwind'
_available from v3.3.95_
+:::note
+This is documentation for enabling Tailwind v3.
+For the Tailwind v4 version of this site, see the [Tailwind v4 documentation](/docs/tailwind-v4/enable-tailwind).
+:::
+
A function that modifies the default Webpack configuration to make the necessary changes to support TailwindCSS.
See the [setup](/docs/tailwind) to see full instructions on how to setup TailwindCSS in Remotion.
diff --git a/packages/docs/docs/tailwind/overview.mdx b/packages/docs/docs/tailwind/overview.mdx
index dd033d4053..ce987b16ef 100644
--- a/packages/docs/docs/tailwind/overview.mdx
+++ b/packages/docs/docs/tailwind/overview.mdx
@@ -10,6 +10,11 @@ import TabItem from '@theme/TabItem';
import {ExperimentalBadge} from '../../components/Experimental';
import {TableOfContents} from './TableOfContents';
+:::note
+This is documentation for enabling Tailwind v3.
+For the Tailwind v4 version of this site, see the [Tailwind v4 documentation](/docs/tailwind-v4).
+:::
+
This package provides utilities useful for integrating [TailwindCSS](https://tailwindcss.com/) with Remotion, as documented on our [TailwindCSS](/docs/tailwind) page.
## Installation
diff --git a/packages/docs/sidebars.js b/packages/docs/sidebars.js
index a540547b75..65e0a69e61 100644
--- a/packages/docs/sidebars.js
+++ b/packages/docs/sidebars.js
@@ -316,6 +316,15 @@ module.exports = {
},
items: ['tailwind/enable-tailwind'],
},
+ {
+ type: 'category',
+ label: '@remotion/tailwind-v4',
+ link: {
+ type: 'doc',
+ id: 'tailwind-v4/tailwind',
+ },
+ items: ['tailwind-v4/enable-tailwind'],
+ },
{
type: 'category',
label: '@remotion/enable-scss',
diff --git a/packages/example/package.json b/packages/example/package.json
index d31d7b034b..cafa56bac5 100644
--- a/packages/example/package.json
+++ b/packages/example/package.json
@@ -58,7 +58,7 @@
"@remotion/skia": "workspace:*",
"@remotion/enable-scss": "workspace:*",
"@remotion/studio": "workspace:*",
- "@remotion/tailwind": "workspace:*",
+ "@remotion/tailwind-v4": "workspace:*",
"@remotion/three": "workspace:*",
"@remotion/transitions": "workspace:*",
"@remotion/media-parser": "workspace:*",
@@ -89,7 +89,8 @@
"style-loader": "2.0.0",
"css-loader": "5.2.7",
"sass-loader": "14.2.1",
- "sass": "1.77.2"
+ "sass": "1.77.2",
+ "tailwindcss": "4.0.0"
},
"devDependencies": {
"prettier-plugin-organize-imports": "3.2.4",
diff --git a/packages/example/postcss.config.mjs b/packages/example/postcss.config.mjs
new file mode 100644
index 0000000000..1970487b54
--- /dev/null
+++ b/packages/example/postcss.config.mjs
@@ -0,0 +1,5 @@
+export default {
+ plugins: {
+ '@tailwindcss/postcss': {},
+ },
+};
diff --git a/packages/example/src/style.css b/packages/example/src/style.css
index b5c61c9567..d4b5078586 100644
--- a/packages/example/src/style.css
+++ b/packages/example/src/style.css
@@ -1,3 +1 @@
-@tailwind base;
-@tailwind components;
-@tailwind utilities;
+@import 'tailwindcss';
diff --git a/packages/example/src/webpack-override.mjs b/packages/example/src/webpack-override.mjs
index d6c801951d..92f3417d81 100644
--- a/packages/example/src/webpack-override.mjs
+++ b/packages/example/src/webpack-override.mjs
@@ -1,6 +1,6 @@
import {enableScss} from '@remotion/enable-scss';
import {enableSkia} from '@remotion/skia/enable';
-import {enableTailwind} from '@remotion/tailwind';
+import {enableTailwind} from '@remotion/tailwind-v4';
import path from 'node:path';
diff --git a/packages/studio-shared/src/installable-packages.ts b/packages/studio-shared/src/installable-packages.ts
index 8b5d3a5d1b..7a7fa0f65f 100644
--- a/packages/studio-shared/src/installable-packages.ts
+++ b/packages/studio-shared/src/installable-packages.ts
@@ -19,6 +19,7 @@ export const listOfInstallableRemotionPackages = [
'@remotion/skia',
'@remotion/studio',
'@remotion/tailwind',
+ '@remotion/tailwind-v4',
'@remotion/three',
'@remotion/transitions',
'@remotion/zod-types',
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index a104a4036f..31aace8438 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -260,6 +260,9 @@ importers:
'@remotion/skia':
specifier: workspace:*
version: link:../skia
+ '@remotion/tailwind-v4':
+ specifier: workspace:*
+ version: link:../tailwind-v4
'@remotion/zod-types':
specifier: workspace:*
version: link:../zod-types
@@ -1042,9 +1045,9 @@ importers:
'@remotion/svg-3d-engine':
specifier: workspace:*
version: link:../svg-3d-engine
- '@remotion/tailwind':
+ '@remotion/tailwind-v4':
specifier: workspace:*
- version: link:../tailwind
+ version: link:../tailwind-v4
'@remotion/three':
specifier: workspace:*
version: link:../three
@@ -1126,6 +1129,9 @@ importers:
styled-components:
specifier: 6.1.13
+ tailwindcss:
+ specifier: 4.0.0
+ version: 4.0.0
three:
specifier: 0.171.0
version: 0.171.0
@@ -16075,7 +16081,7 @@ packages:
peerDependencies:
eslint: ^6.0.0 || ^7.0.0 || ^8.0.0
dependencies:
- '@types/json-schema': 7.0.15
+ '@types/json-schema': 7.0.13
'@typescript-eslint/scope-manager': 5.19.0
'@typescript-eslint/types': 5.19.0
'@typescript-eslint/typescript-estree': 5.19.0([email protected])