-
Notifications
You must be signed in to change notification settings - Fork 47.6k
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
inline styles and vendor prefix for values #2020
Comments
Related #723, it's complicated because vendor-prefixes are there for a reason and simply acting as if they weren't there means disregarding at least a part of an intentional design decision. For run-time styles, for maximum performance, one should feature test the browser and only apply styles that are valid (and perhaps fall back to a different layout entirely sometimes). Only for server-rendered DOM would the full list of variations be output. I have no practical advice/insight here for the time being though. |
Right now the only way to do this exactly as you want is with regular CSS. Stylus/nib generate CSS so it works for them. We operate on the DOM node itself which doesn't allow you to specify multiple values like this. You could do what @syranide said and feature/browser detect before specifying the style value. I actually think that's something a whole library could be built for to target React users, but I don't think React should do it itself. |
It seems impossible(?) to use inline flexbox with server-rendered DOMs.
|
Autoprefixing every style is probably out-of-scope for React (just the db for autoprefixer is 500KB), but especially with the push towards inline styles with React Native, it would be nice if foundational technologies like Flexbox and transform were autoprefixed by React. They're consensus APIs that are unprefixed by everyone but Safari. To that end, I whipped this up last night. It solves the problem as long as you remember to litter your codebase with |
@appsforartists https://github.com/cgarvis/react-vendor-prefix does this too but also handles animation properties... |
Ran into this issue myself. Initially solved it by creating a 'display-flexbox' class as per the suggestions above. While tracking down an issue in material-ui, I noticed they had found/thought of an alternative. Apparently you can add more display properties by specifying them as the value of your display key: display: '-webkit-box; display: -moz-box; display: -ms-flexbox; display: -webkit-flex; display: flex', Bit of a hack, but doesn't seem too bad. It solves the issue I was having with Safari (8.0.7) and things are still working in Chrome and FF. I haven't checked IE or older browsers. Kind regards |
Wow, I am stunned that that works On Tue, Jul 21, 2015 at 11:39 AM Elger Lambert [email protected]
Wout. |
FWIW, that hack only works on initial render and only because we use |
Thanks for your comment @zpao! That's good to know/be aware of. |
maybe this will help: |
@zpao, @elgerlambert u guys are awsome, I was strugglling with this for a long time untill I find this issue. |
Does React have a clean solution for vendor prefixing key/value of an inline style? A clear solution being something that works for server side rendering too, not hacky, works always (not only on first render) and all other things that clean solutions are supposed to have. |
What about non-prefix related issues such as |
I think this problem should be listed at doc https://facebook.github.io/react/docs/dom-elements.html#style |
… hack specified in previous commit are not supported, so instead dont use display flex in prefix all and also merge the extra style prop after using prefixAll
Radium solves this nicely by using an array for value prefixing, eg: <div style={{ cursor: ['move', '-webkit-grab', 'grab'] }}> Sounds like something useful enough for having in React's core. Not sure how doable it is though. |
How would I write the following css using inline styles?
Wouldn't be nice if react could internally automatically handle vendor prefixes (similar to stylus + nib)?
The text was updated successfully, but these errors were encountered: