Skip to content

@apply directive not working anymore? #17795

Answered by wongjn
tamerkalieh asked this question in Help
Discussion options

You must be logged in to vote

In this case, I split class names up into multiple lines like:

<div
  class="
    px-2 md:px-4 lg:px-8
    …other classes…
  "
>

If you reuse this group a lot, you could refactor this string to a constant and use it elsewhere:

export const PX = 'px-2 md:px-4 lg:px-8';
<div class="{PX} …other classes…">

Or perhaps abstract it to a CSS variable:

<div class="[--px:--spacing(2)] md:[--px:--spacing(4)] lg:[--px:--spacing(8)]"><!-- Some deep level component -->
  <div class="px-(--px)">

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

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

wongjn Apr 27, 2025
Collaborator

Answer selected by tamerkalieh
@tamerkalieh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants