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.

[system] Prefer styled-components's css prop over Box css

See original GitHub issue
  • I have searched the issues of this repository and believe that this is not a duplicate.

Summary šŸ’”

A css prop had been added in Styled-components v4: https://www.styled-components.com/docs/api#css-prop. It is a very handy way to stylize a component, and personnaly I use it a lot.

However, it doesnā€™t work on the Box component because Box has already a css property. I think it would be preferable not to have one to make it possible to use Styled-components one.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
lcswillemscommented, Oct 20, 2020

I am not sure about what you ask me to think about precisely but I largely prefer option 2 (ā€œwrite them under one propā€) over the other one for these reasons:

  1. ā€œall system props would be easily discoverableā€ as @mnajdova said. I donā€™t know how many styling props there are (letā€™s say 50). Then if I want to use a new component I donā€™t know well, it will be very hard to find the properties that are really specific to it.
  2. I prefer when styling props are grouped because I am used to separating css and html or separating css and logic props.

I hope my answer helps, and if I answered about the good thing.

0reactions
mnajdovacommented, Nov 9, 2020

Now that we have the sx prop is safe to drop the css prop. Will work on a PR šŸ‘

Read more comments on GitHub >

github_iconTop Results From Across the Web

[system] Prefer styled-components's css prop over Box css
I prefer when styling props are grouped because I am used to separating css and html or separating css and logic props. I...
Read more >
Basics - styled-components
Automatic critical CSS: styled-components keeps track of which components are rendered on a page and injects their styles and nothing else, fully automatically....
Read more >
Getting Started - Styled System
Styled System is a collection of utility functions that add style props to your React components and allows you to control styles based...
Read more >
Styled Components, Styled Systems and How They Work
This code created a React component named Box that receives the props color and bg . <Box color="#fff" bg="tomato"> TomatoĀ ...
Read more >
A Comparison of Three Methods for Styling Components in ...
Styled-components is the premier library for using CSS-in-JS. ... Notice how we are now computing styles based on props.
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