TailwindCSS
Using the template
The easiest way to get started with Tailwind and Remotion is to use the template by cloning it on GitHub or running the following:
- npm
- yarn
- pnpm
bash
bash
bash
bash
bash
bash
Install in existing project
- Install the following dependencies:
- npm
- yarn
- pnpm
bash
bash
bash
bash
bash
bash
- Create a function for overriding the webpack config
src/enable-tailwind.tstsWebpackOverrideFn } from "remotion";export constenableTailwind :WebpackOverrideFn = (currentConfiguration ) => {return {...currentConfiguration ,module : {...currentConfiguration .module ,rules : [...(currentConfiguration .module ?.rules ?currentConfiguration .module .rules : []).filter ((rule ) => {if (rule === "...") {return false;}if (rule .test ?.toString ().includes (".css")) {return false;}return true;}),{test : /\.css$/i,use : ["style-loader","css-loader",{loader : "postcss-loader",options : {postcssOptions : {plugins : ["postcss-preset-env","tailwindcss","autoprefixer",],},},},],},],},};};
src/enable-tailwind.tstsWebpackOverrideFn } from "remotion";export constenableTailwind :WebpackOverrideFn = (currentConfiguration ) => {return {...currentConfiguration ,module : {...currentConfiguration .module ,rules : [...(currentConfiguration .module ?.rules ?currentConfiguration .module .rules : []).filter ((rule ) => {if (rule === "...") {return false;}if (rule .test ?.toString ().includes (".css")) {return false;}return true;}),{test : /\.css$/i,use : ["style-loader","css-loader",{loader : "postcss-loader",options : {postcssOptions : {plugins : ["postcss-preset-env","tailwindcss","autoprefixer",],},},},],},],},};};
- Add the Webpack override to your config file:
remotion.config.tstsConfig } from "remotion";import {enableTailwind } from "./src/enable-tailwind";Config .Bundling .overrideWebpackConfig (enableTailwind );
remotion.config.tstsConfig } from "remotion";import {enableTailwind } from "./src/enable-tailwind";Config .Bundling .overrideWebpackConfig (enableTailwind );
- If you use the - bundle()or- deploySite()Node.JS API, add the Webpack override to it as well.
- Create a file - src/style.csswith the following content:
src/style.csscss
src/style.csscss
- Import the stylesheet in your src/Video.tsxfile. Add to the top of the file:
src/Video.tsxjs
src/Video.tsxjs
- Add a tailwind.config.jsfile to the root of your project:
tailwind.config.jsjs
tailwind.config.jsjs
- Ensure your package.jsondoes not have"sideEffects": falseset. If it has, declare that CSS files have a side effect:
package.jsondiff
package.jsondiff
- Start using TailwindCSS! You can verify that it's working by adding className="bg-red-900"to any element.