How to extract own classes with Tailwindcss to separate file

Viewed 3735

I have app.css file like

@tailwind base;
@tailwind components;
    
@import url('features/login/login.css');
    
@tailwind utilities;

In login.css code like

.login-button {
  @apply w-full flex justify-center border border-transparent;
}
        
body {
  background-color: red !important;
}

The rule for body works, but for the login-button does not

How I can create own css class based on tailwind classe in our css files?

Thanks

update: added html file (it Aurelia-framework template) Original template

<template>
  <span class="login-button-wrapper">
   <button type="submit" class="login-button">
    Sign in
   </button>
  </span>
</template>

Fixed template

<template>
<require from="./login.css"></require>
<span class="login-button-wrapper">
 <button type="submit" class="login-button">
    Sign in
 </button>
</span>
</template>
3 Answers

You can write your style under your tailwind assets

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

.login-button {
  @apply w-full flex justify-center border border-transparent;
}
        
body {
  background-color: red !important;
}

like this, if prefer using the file you can also use the directive before that you need to make sure you have installed

npm install postcss-import
    

 @import url("path");
     or
  @import "path";

You need to check if the path is correct and rebuild your app again this will work

Related