Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Aliases for tailwind classes?

I want to change the name of the tailwind hidden class so that whenever I want to use display:none, I can do so by using the word no-display instead of using the word hidden. I am assuming this is a change I can make in the tailwind config file but I can't seem to figure out exactly how and what changes need to be made in that file. Thanks for the help

like image 463
rgc998 Avatar asked Oct 28 '25 01:10

rgc998


1 Answers

You can add custom utilities to your tailwind CSS file.


With the @apply directive:

main.css:

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

@layer utilities {
  .no-display {
    @apply hidden
  }
}

HTML:

<div class="no-display">You can't see this text</div>

Tailwind-play link


With CSS utility:

main.css:

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

@layer utilities {
  .no-display {
    display: none;
  }
}

HTML:

<div class="no-display">You can't see this text</div>

Tailwind-play link

like image 182
ChenBr Avatar answered Oct 30 '25 18:10

ChenBr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!