For width on an element with tailwind you can set it by a percentage or fixed rem value. For setting max-width you can only set it to the size of a breakpoint.
Why is this?
Is there any way to set max-width to a percentage or a fixed size that isn't a breakpoint?
Yes, in your theme as described in the answers above.
BUT, from the v3 docs, "…If you need to use a one-off max-width value that doesn’t make sense to include in your theme, use square brackets to generate a property on the fly using any arbitrary value…"
<div class="max-w-[50%]">
<!-- ... -->
</div>
the answer of Dmitry is correct, but beware:
If you do it like he mentioned, none of the maxWidth values will work, except the values in the configuration.
If you want to just extend the base maxWidth values (provided by tailwind), you have to put the configuration inside the extend section like so:
// tailwind.config.js
module.exports = {
theme: {
extend: {
maxWidth: {
'1/4': '25%',
'1/2': '300px',
'3/4': '75%',
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With