Tailwindcss: Feature request: Add an option to generate styles using px instead of rem's (ref. #800)

Created on 12 Jun 2019  路  2Comments  路  Source: tailwindlabs/tailwindcss

I'm opening this issue as a follow-up because the original issue is now closed.

rem is ok for a number of reasons as discussed in #800, but sometimes it could still be useful to have px. I'm using an HTML to PDF converter that only supports pixels and it'd be very useful to have the generated css in px.

Would it be possible to add an option to replace the rem with px?

All 2 comments

I think the best way to handle this for now would be to create a separate package that converts the default config and re-exports it so you can do something like this:

// tailwind.config.js
module.exports = require('tailwindcss-px-config')

I can't think of a great way to handle this inside of Tailwind that wouldn't add some gross configuration options or anything, so I think just creating a separate reusable package is the best solution at least for now 馃憤

Btw, in the meantime this rude workaround "works":

  1. extract styles.css
  2. use perl to replace rems and ems with px (assuming 16px as base).

perl -p -i -e 's/([\d+.]+)rem/($1*16).px/ge' styles.css
perl -p -i -e 's/([\d+.]+)em/($1*16).px/ge' styles.css

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quineone picture Quineone  路  3Comments

nternetinspired picture nternetinspired  路  3Comments

spyric picture spyric  路  3Comments

chintanbanugaria picture chintanbanugaria  路  3Comments

rgaufman picture rgaufman  路  3Comments