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

className does not work as expected #262

Open
5 tasks done
garethbjohnson opened this issue Feb 20, 2020 · 2 comments
Open
5 tasks done

className does not work as expected #262

garethbjohnson opened this issue Feb 20, 2020 · 2 comments

Comments

@garethbjohnson
Copy link

Bug Report

Prerequisites

  • Can you reproduce the problem in a MWE?
  • Are you running the latest version?
  • Did you check the FAQs to see if that helps you?
  • Are you reporting to the correct repository?
  • Did you perform a search in the issues?

Versions

1.1.1

Description

When I pass a className that I define in my CSS, the style is overridden by the Precise UI component. I would expect my class to override the default component style.

Here is an example.

Steps to Reproduce

  1. Make this CSS class:
.red {
  color: red;
}
  1. Render this JSX:
<Button className="red">Hello</Button>
  1. Check the colour of the button text.

Expected behavior: The text would be red.

Actual behavior: The text is white.

Environment details: macOS 10.15.3, Chrome 80 and Firefox

@kbariotis
Copy link

Disclaimer: I am not a maintainer of this project.

@garethbjohnson this is not necessarily an issue with this library. This is the expected behavior of the styled-components library.

Looking quickly through the code it seems like the className property is just being passed down each styled component, so you will probably be able to override it based on the documentation.

@garethbjohnson
Copy link
Author

@kbariotis I understand that this is caused by styled-components. However, I did not expect to have to know such a detail of the underlying third-party library in order to use Precise UI in this way. Additionally, I do not like the coupling of concerns in having to increase the specificity of the CSS declaration for each class that I pass to a Precise UI component. Further, I expect that passing className to add style would be a common approach for any project not using styled-components for internal styling. Thus, I do consider this to be an issue with this library.

To anyone else having the same issue as me: read this styled-components documentation.

To any maintainer reading this: if you expect users to increase the specificity of the CSS declaration for any passed className used for styling, then please document this prominently enough for them to read about it before trying it.

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

No branches or pull requests

2 participants