How to use forms plugin in Tailwind CSS

In this section we will see how to use tailwind css forms plugin. tailwind forms plugin is official first party package. its provides lots of features. There is two way you can install tailwind forms plugin in tailwind css.


Tailwind CSS Form plugin with CDN

You can simply use tailwind form plugin cdn. plz note forms cdn plugin use only testing purpose don't use in production.

    <link href="https://unpkg.com/@tailwindcss/forms@0.2.1/dist/forms.min.css" rel="stylesheet">

login.html

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tailwind CSS 3 form plugin with CDN</title>
    <script src="https://cdn.tailwindcss.com/"></script>
    <link href="https://unpkg.com/@tailwindcss/forms@0.2.1/dist/forms.min.css" rel="stylesheet">
  </head>

  <body>
    
    <div class="flex justify-center mt-20">
      <div class="py-12">
        <h2 class="text-2xl font-bold">Tailwind v3 with form plugin</h2>
        <div class="max-w-md mt-8">
          <div class="grid grid-cols-1 gap-6">
            <label class="block">
              <span class="text-gray-700">Email</span>
              <input type="email" class="block w-full mt-1" placeholder="" />
            </label>
            <label class="block">
              <span class="text-gray-700">Password</span>
              <input
                type="password"
                class="block w-full mt-1"
                placeholder=""
              />
            </label>
            <button
              class="block py-2 text-purple-100 bg-purple-600 rounded shadow-lg shadow-purple-300"
            >
              Login
            </button>
          </div>
        </div>
      </div>
    </div>


  </body>

</html>


Shorthand

tailwind css 3 with forms plugin

<script src="https://cdn.tailwindcss.com/?plugins=forms"></script>

3 interesting new features added in Tailwind CSS 3

login.html

<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tailwind CSS 3 form plugin with CDN</title>
    <script src="https://cdn.tailwindcss.com/?plugins=forms"></script>
  </head>

  <body>
    
    <div class="flex justify-center mt-20">
      <div class="py-12">
        <h2 class="text-2xl font-bold">Tailwind v3 with form plugin</h2>
        <div class="max-w-md mt-8">
          <div class="grid grid-cols-1 gap-6">
            <label class="block">
              <span class="text-gray-700">Email</span>
              <input type="email" class="block w-full mt-1" placeholder="" />
            </label>
            <label class="block">
              <span class="text-gray-700">Password</span>
              <input
                type="password"
                class="block w-full mt-1"
                placeholder=""
              />
            </label>
            <button
              class="block py-2 text-purple-100 bg-purple-600 rounded shadow-lg shadow-purple-300"
            >
              Login
            </button>
          </div>
        </div>
      </div>
    </div>


  </body>

</html>



Install @tailwindcss/forms via npm

Install the plugin from npm:

npm install -D @tailwindcss/forms


Then add the plugin to your tailwind.config.js file:

// tailwind.config.js
module.exports = {
  theme: {
    // ...
  },
  plugins: [
    require('@tailwindcss/forms'),
    // ...
  ],
}


Read Also

Tailwind CSS 3 FAQ Accordion UI Example

Tailwind CSS 3 Alert Message Example

Tailwind CSS 3 Avatars Example

Tailwind CSS 3 Breadcrumb Example

Tailwind CSS v3 Button Examples

Tailwind CSS v3 Cards Examples

How to use dark mode toggle switch in Tailwind CSS 3

Tailwind CSS 3 Login Page UI Example