Skip to content

Adding Tailwind CSS

Lets add Tailwind before we implement anything so we can stylize our app.


Tailwind CSS is self-described as a utility first CSS framework. Rather than focusing on the functionality of the item being styled, Tailwind is centered around how it should be displayed.

Install tailwindcss and its peer dependencies via npm, and then run the init command to generate both tailwind.config.js and postcss.config.js.

npm install -D tailwindcss postcss autoprefixer

npx tailwindcss init -p

In order to be able to use Tailwind in our files JavaScript we need the paths to all of your template files in your tailwind.config.js file.

module.exports = {
content: [
theme: {
    extend: {},
plugins: [],

Add the @tailwind directives for each of Tailwind’s layers to your ./src/index.css file.


Directives are custom Tailwind-specific at-rules you can use in your CSS that offer special functionality for Tailwind CSS projects.

@tailwind base;
@tailwind components;
@tailwind utilities;

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;

code {
    font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',

Cool, we can now use any classes that Tailwind provides. To see all avalilable classes and other things, please visit We will use some of them through the tutorial.

Last update: March 28, 2022