Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Convert rem|em values to pixel values #376

Closed
franky47 opened this issue Oct 7, 2018 · 4 comments
Closed

[Feature Request] Convert rem|em values to pixel values #376

franky47 opened this issue Oct 7, 2018 · 4 comments

Comments

@franky47
Copy link

franky47 commented Oct 7, 2018

I have a use case for a function that transform relative (em, rem) units into pixel values. Basically the opposite of what the em and rem functions do.

The reason behind this is that I use rem units throughout my styles for consistent UI component design, and I came across an issue where SVG elements sized with rem units don't work across all browsers.

As an example, Chrome renders ok with rem units:
chrome
But Firefox doesn't :
ff

They do however seem to work with em units, but since that's dependent on whatever context the component is used in, it does not seem solid for my use case.

The API could look something like this:

import { px } from 'polished'

const valueInPx = px('3rem')

If it seems like a good idea, I could give a try to implementing it. Suggestions for naming and API are welcome !

@franky47 franky47 changed the title [Feature Proposal] Convert rem|em values to pixel values [Feature Request] Convert rem|em values to pixel values Oct 7, 2018
@bhough bhough closed this as completed Mar 15, 2020
@peterjcaulfield
Copy link

peterjcaulfield commented Sep 14, 2020

I just hit a bug where rem values aren't working for height and width attributes for svgs in firefox on windows so I need to convert the rem value to px to solve. I looked at the polished docs for a helper and saw the rem helper but no px helper and ended up here.

Why was this closed without comment?

@amorphius
Copy link

I have similar needs

@bhough bhough reopened this Jan 21, 2021
@bhough
Copy link
Contributor

bhough commented Jan 21, 2021

Reopening for evaluation...

@bhough
Copy link
Contributor

bhough commented Jan 24, 2021

We've released v4.1.0 which includes a remToPx helper for converting rem values to px. This was the primary use case we saw the most support for.

We will continue to monitor future feature requests for a helper that covers em or other values. We will be closing this issue permanently, so please create a new request if this doesn't cover your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants