Skip to content

css @apply input is not the same as the input class #4046

Closed Answered by saadeghi
LuckyTurtleDev asked this question in Q&A
Discussion options

You must be logged in to vote

Tailwind CSS @apply only extends simple selectors. A class name like .input has relative selectors (like child selector, sibling selector, etc) which is ignored by Tailwind's @apply because it will easily create loops or will generate lots of unused styles.

@apply should be used for simple selectors that apply one or two CSS attributes to a single CSS class name. For example @apply p-4 bg-primary. A component class name like .input sets multiple CSS properties to multiple selectors.

To extend styles, use something like class="input my_input" where .my_input includes the modifications.

Let me know if you have any questions

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@LuckyTurtleDev
Comment options

@LuckyTurtleDev
Comment options

Answer selected by LuckyTurtleDev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants