When using tailwind (example, setting height as per documentation here – DOCS),
we have predefined values as such
h-40 height: 10rem; /* 160px */
h-44 height: 11rem; /* 176px */
but the in between values in the range of 160px to 176px are not represented here. As we can see those 16 pixels can be devided in to blocks of 4px hence it SHOULD be
h-40 height: 10rem; /* 160px */
h-41 height: 10.25rem; /* 164px */
h-42 height: 10.50rem; /* 168px */
h-43 height: 10.75rem; /* 172px */
h-44 height: 11rem; /* 176px */
but when I use those values (which are not documented, they DON’T work). The workaround is to use
h-[164px], h-[168px], h-[172px]
Which is not ideal. Is there a way to use the undocumented tailwind classes such as
h41, h-42, h43 without hardcoding pixel values?
2
Answers
You can extend the tailwind theme like this.
Tailwind Playground
Tailwind Docs
The values increase by
0.25rem
in a regular pattern. If we write a function in the tailwind.config.js file that provides the appropriate rem for each height from 1 to 96, you can declare these by default as well. If you increase the value from 96, you can further extend the default list.tailwind.config.js
height
– TailwindCSS Docs