question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[React Native] Expand supported CSS for React Native

See original GitHub issue

I would like to start a discussion on expanding the CSS supported by styled-components/native. Primary items of interest:

  • rem/em/viewport units
  • global syles
  • media queries
  • subset of pseudo classes

It would seem that some of this functionality could be included in css-to-react-native… further improving the convenience of writing styles for React Native components with styled-components. @jacobp100, this looks to be your domain.

It appears this has been discussed in at least a limited manner, but that was in context of a specific method of accomplishing these features and was some time ago.

Looking to precedent in styled-components

Based on the inclusion of shortand and convenient syntax for properties like transform, it seems that styled-components is not limiting itself to simple mapping of styles to RN. (https://www.styled-components.com/docs/basics#react-native)

Looking elsewhere in the React Native ecosystem

Addressing template questions

  • How is this product-centric? By allowing usage of em/rem units, viewport units, and media queries… creating native apps in a responsive manner (so they look ideal on all devices) would become much easier. Other included items improve convenience as well.

  • How does it make workarounds straight forward? Any functionality that is included eliminates the need for using helper libraries or each app having their own method to deal with responsiveness of their styles.

Limitations of React Native in regards to styling.

As discussed here: https://github.com/styled-components/styled-components/issues/1243, some css properties (such as text-transform) aren’t going to be easy to support, as limitations in React Native prevent them. This discussion is meant for CSS that can be supported (as evidenced elsewhere in the React Native ecosystem) with the current state of React Native.

Related issues

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:31
  • Comments:63 (20 by maintainers)

github_iconTop GitHub Comments

7reactions
henrymoultoncommented, Jun 26, 2019

I think what’s changed in the last 2/3 years for React Native developers is that they recognise that some scaling is required across device sizes - React Native Extended Stylesheet’s increased download count might support this claim.

Having a way to achieve this inside of Styled Components would be ideal.

7reactions
micimizecommented, May 7, 2018

@jacobp100 I think the reasons for rejecting #489 should be reconsidered. The reasons given, as far as I can tell: 1. hesitance to take on more/incorrect dependencies 2. the consideration of a more general solution in #504 3. “nobody has asked for this feature”

2 got shot down and 3 is clearly no longer the case, so that just leaves 1. I don’t see why leveraging external libraries today means we can’t replace them later, either with internal implementations or other libraries. If adding extended-stylesheet support is still even close to as simple as 489 makes it look, we could really have most of this functionality by tomorrow.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Layout Props - React Native
The following example shows how different properties can affect or shape a React Native layout. You can try for example to add or...
Read more >
Layout with Flexbox - React Native
A component can specify the layout of its children using the Flexbox algorithm. Flexbox is designed to provide a consistent layout on different ......
Read more >
Transforms - React Native
Transforms are style properties that will help you modify the appearance and position of your components using 2D or 3D transformations.
Read more >
Height and Width - React Native
A component can only expand to fill available space if its parent has dimensions greater than 0 . If a parent does not...
Read more >
Style - React Native
With React Native, you style your application using JavaScript. All of the core components accept a prop named style.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found