1

According to v4 docs, to override existing or define new spacing (which includes margin, padding, min-w/h, etc.) you use theme namespace:

--spacing-*

So let's say I would like to define mx-max to represent:

margin-inline: 100vh;

I could achieve this by including the following theme:

@theme {
  --spacing-max: 100vh;
}

However this also overrides a default utility, for example min-w-max:

Default:
min-width: max-content;

Override:
min-width: 100vh;

I don't want to override other spacing utils, just margin utils. How would I achieve this, considering in previous tailwind versions you could define it in tailwind.config.js:

module.exports = {
  theme: {
    extend: {
      margin: {
       'max': '100vh',
      }
    }
  }
}

1 Answer 1

0

In @theme, only the listed namespaces exist; nothing else can be declared.

From v4 onwards, padding and margin have been redefined and finally equipped with dynamic calculation. This is the dynamic behavior that prompted you to ask the question, as you want to deviate from the standard. You have the option to do so by leveraging CSS features, allowing you to declare a stronger utility.

@layer utilities {
  .mx-max {
    margin-inline: 100vh;
  }
}

From v4 onwards, this can be written using the @utility directive, as recommended in the documentation:

@utility mx-max {
  margin-inline: 100vh;
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.