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.

css prop does not override if provided without enclosing { }

See original GitHub issue

This is a bug report. react-spinners version 0.5.3.

The css prop is documented to override the default css, but it does not actually do this, if used like in the documentation, for example like this in my case:

  const cssOverride = css`
    margin: 20% auto 40%;
    display: block;
  `;

  const loader = (
    <ClipLoader
      css={cssOverride}
    />
  );

The display: block; is correctly added, but in a way that it does not override the default display: inline-block (the respective <style data-emotion="css"></style> is added earlier in the DOM).

However, if I enclose the css string in { } inside the template literal, it does override:

  const cssOverride = css`{
    margin: 20% auto 40%;
    display: block;
  }`;

This seems to be the way the default styles are written as well. I’m not experienced with emotion-js, so I cannot explain why that makes the object precedence work as intended, but it seems that’s how it works.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
mountwebscommented, Jan 28, 2021

This is still an issue for me.

1reaction
eoghanmccarthycommented, Sep 17, 2019

This issue still persists in 0.6.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Overriding properties in CSS - Stack Overflow
I would like the first span 's width to be 190px, and second's to be 10px. But both are 190px: why it's not...
Read more >
How to Override CSS Styles - W3docs
An ID selector only takes precedence over a Class selector if they are both used in the same element. Let's now see how...
Read more >
Overriding CSS properties of third-party components in Angular
You can override a third-party component's CSS properties either at an enclosing component or global level. Unless you want to affect all the ......
Read more >
will-change - CSS: Cascading Style Sheets - MDN Web Docs
Indicates that the author expects to animate or change the property with the given name on the element in the near future. If...
Read more >
Styled Components - Emotion
The as prop is only used by styled when it's not forwarded to the underlying element. By default, this means that the as...
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