tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Max-h-* is not working

Open eminaydin opened this issue 5 years ago • 10 comments

I am using tailwind in my project where I have noticed no single problem at all. But when I try to set maxHeight with the default values from Tailwind, no css is applied. For example if I give max-h-80 to any element it is not working but if I set a value for this class in tailwind.config.js file then I get the styles. Seems like there is a bug with the corresponding issue.

eminaydin avatar Dec 17 '20 08:12 eminaydin

Hey! I can't reproduce this, as you can see here it is working as expected:

https://play.tailwindcss.com/GXM6e3GptJ

Closing since no reproduction was provided, please follow the issue template if you would like more help.

adamwathan avatar Dec 17 '20 15:12 adamwathan

I have these problem

dejurin avatar Jan 18 '21 18:01 dejurin

Just a note here for people that this is happening to - this seems to happen if you don't have a postcss.config.js file in your root (alongside tailwind.config.js). I got caught out by this when upgrading to the new tailwind as I only had tailwind.config.js.

Running npx tailwindcss init -p in your root will generate a new, empty one. When this was added I found all the styles were working properly.

mwaddoups avatar Jan 11 '22 09:01 mwaddoups

For anyone else running into this, it can happen if you put your custom maxHeight values in tailwind.config.js under theme.maxHeight instead of theme.extend.maxHeight. Setting theme.maxHeight means that Tailwind will only pull in the maxHeight custom values you specify.

Docs: https://tailwindcss.com/docs/max-height#customizing-your-theme

shivakilaru avatar Mar 09 '22 19:03 shivakilaru

I've had this for some time, I thought it was intended behavior.

I have postcss.config.cjs and I don't extend maxHeight so both solutions don't work for me

Sodj avatar Mar 30 '23 11:03 Sodj

I've just had the same issue. Spent about 1 hour scratching my head why everything else would work but max-h-*.

I re-ran npm run dev and it started working again. Odd. Only seemed to affect max-h-*. Any other class (even if I've never used it before) seemed to be fine.

GalahadXCIX avatar Oct 04 '23 11:10 GalahadXCIX

I bumped into this. Problem was me, not tailwind. Make sure you're doing

class="max-h-[390px]"

as opposed to

class=max-h-[${maxHeight}]

The latter will fail silently, since tailwind needs a statically readable value at build-time, from the source file.

Or, to cut down on the repetition, this will work too

  const MAX_SVG_HEIGHT = 390;
  const maxHeightStyle = "max-h-[390px]";

and then interpolate maxHeightStyle however you need. The point is, the fully-formed style rule has to be readable from source, anywhere.

arackaf avatar Oct 30 '23 04:10 arackaf

I just encountered this issue with "max-h-*", rerunning npm dev seems to fix it, but this is an odd one 😁

naourass avatar Apr 11 '24 08:04 naourass

I had this problem with max-w-* classes, they just weren't being built into the styles (weirdly, the -md/-lg type classes worked, as did arbitrary -[100px] values, but not the -16, -24 etc.) Restarting run dev didn't fix it, but updating tailwind/postcss and rerunning the server did.

acewert avatar Apr 13 '24 20:04 acewert

I think you can edit the tailwind.config.js file For example image

lxl-sql avatar Jul 03 '24 02:07 lxl-sql