Skip to content

[v4] Using mixins with poscss-mixins plugin and tailwind postcss #16562

Closed Answered by wongjn
dvzrd asked this question in Help
Discussion options

You must be logged in to vote

You can achieve this without postcss-mixin, using Tailwind CSS syntax:

@utility box-bordered {
  border-style: solid;
  border-width: 2px;

  &:where(.box-xs) {
    border-width: 1.5px;
  }

  &:where(.box-sm),
  &:where(.box-md) {
    border-width: 2px;
  }

  &:where(.box-lg),
  &:where(.box-xl) {
    border-width: 3px;
  }
}
@reference "path/to/mixin.css";

.card {
   @apply box-bordered;
   border-color: var(--color-red-500);
}

Though really, you should try to forgo the component CSS altogether and use Tailwind classes directly where you can:

-<div class="card">
+<div class="box-bordered border-red-500">

Or even without the @utility, converting the box-* class modifiers to be data-box

Replies: 1 comment 2 replies

Comment options

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

@dvzrd
Comment options

Answer selected by dvzrd
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