Skip to main content

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:

bash
npx create-video --tailwind
bash
npx create-video --tailwind

Install in existing project

  1. Install the following dependencies:
bash
npm i postcss-loader postcss postcss-preset-env tailwindcss autoprefixer
bash
npm i postcss-loader postcss postcss-preset-env tailwindcss autoprefixer
  1. Add the following to your remotion.config.ts file:
ts
Config.Bundling.overrideWebpackConfig((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",
],
},
},
},
],
},
],
},
};
});
ts
Config.Bundling.overrideWebpackConfig((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",
],
},
},
},
],
},
],
},
};
});
  1. Create a file src/style.css with the following content:
css
@tailwind base;
@tailwind components;
@tailwind utilities;
css
@tailwind base;
@tailwind components;
@tailwind utilities;
  1. Import the stylesheet in your src/Video.tsx file. Add to the top of the file:
js
import "./style.css";
js
import "./style.css";
  1. Add a tailwind.config.js file to the root of your project:
js
/* eslint-env node */
module.exports = {
content: ["./src/**/*.{ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
js
/* eslint-env node */
module.exports = {
content: ["./src/**/*.{ts,tsx}"],
theme: {
extend: {},
},
plugins: [],
};
  1. Start using TailwindCSS! You can verify that it's working by adding className="bg-red-900" to any element.

See also