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

Local CSS is overridden by React-generated CSS #482

Closed
EBoisseauSierra opened this issue Dec 6, 2018 · 15 comments
Closed

Local CSS is overridden by React-generated CSS #482

EBoisseauSierra opened this issue Dec 6, 2018 · 15 comments

Comments

@EBoisseauSierra
Copy link

Context

I'm trying to style various DCC elements — say multi-value dropdowns.

Problem

I am using Dash v0.31.0.

I add a css file to my project containing:

.Select--multi .Select-value {
    background-color:#df0a0b;
}

I know the CSS is loaded as other rules (e.g. affecting h1) take effect.
However, for the dropdown, my own styles are overridden by the React select .ccs file — i.e. the file starting with:

/**
 * React Select
 * ============
 * Created by Jed Watson and Joss Mackison for KeystoneJS, http://www.keystonejs.com/
 * https://twitter.com/jedwatson https://twitter.com/jossmackison https://twitter.com/keystonejs
 * MIT License: https://github.com/JedWatson/react-select
*/
.Select {
  position: relative;
}
…
.Select--multi .Select-value {
  background-color: #ebf5ff;
  /* Fallback color for IE 8 */
  background-color: rgba(0, 126, 255, 0.08);
  border-radius: 2px;
  border: 1px solid #c2e0ff;
  /* Fallback color for IE 8 */
  border: 1px solid rgba(0, 126, 255, 0.24);
  color: #007eff;
  display: inline-block;
  font-size: 0.9em;
  line-height: 1.4;
  margin-left: 5px;
  margin-top: 5px;
  vertical-align: top;
}
…

The latter is indeed passed as "inline":
screenshot from 2018-12-06 16-50-03

Question

How to enforce my CSS?

@EBoisseauSierra
Copy link
Author

Quick and dirty fix: replace all .Select with div.Select to gain higher priority.

@valentijnnieman
Copy link
Contributor

What version of dash-core-components are you using? In plotly/dash-core-components#382 we fixed the issue where user supplied styles weren't overriding the React included styles.

@EBoisseauSierra
Copy link
Author

EBoisseauSierra commented Dec 10, 2018

@valentijnnieman indeed, I thought it would have been solved. But I made sure I'm using v0.39.0…

$ pip show dash-core-components
Name: dash-core-components
Version: 0.39.0
...

@anandcu3
Copy link

Same behavior in v0.42.1

@mamay13
Copy link

mamay13 commented Apr 11, 2019

Same behavior in 0.45.0
only with imported dash_table

@jjaraalm
Copy link
Contributor

jjaraalm commented Apr 1, 2020

Same here with dash 1.9.1 using dash_table. Custom CSS is applied correctly on page load, however I have dropdowns in one tab and tables in another. Switching to the table tab causes custom css to be overridde once I switch back.

@elastufka
Copy link

I also have this issue. Any solutions yet? I can't find the part in my CSS which controls the dropdown menu colors.

@Limits0x
Copy link

I am having the exact same issue but with dash_table. Any solutions yet?

@Geometrein
Copy link

Same issue with dcc.tabs.
The actual example that you provide on your website: Styling the Tabs component with CSS Classes contains this issue.
Any solutions yet?

AnnMarieW pushed a commit to AnnMarieW/dash that referenced this issue Jan 6, 2022
Update dashCoreComponents package in R to 0.44.0
@Xzyon
Copy link

Xzyon commented Dec 16, 2022

Same behavior with dash-core-components ver. 2.0.0
React override local CSS of dropdown only when a dash_table is present.

@EBoisseauSierra 's trick works nicely

Quick and dirty fix: replace all .Select with div.Select to gain higher priority

@lance-noel
Copy link

I have the same problem with .Select--multi .Select-value being overwritten by react-select

@ndretex
Copy link

ndretex commented Dec 18, 2023

Hello, Is there any update on a permanent fix for this?

Thanks

@Coding-with-Adam
Copy link
Contributor

Coding-with-Adam commented Dec 21, 2023

@ndretex are you referring to a CSS styling problem related to Dash Core Components or the Dash DataTable?
Can you share your code or sample code that recreates this problem?

@at1047
Copy link

at1047 commented Mar 18, 2024

Another quick and dirty fix, add !important to the css property you want to override

@gvwilson
Copy link
Contributor

Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are most important to our community. If this issue is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. (Please note that we will give priority to reports that include a short reproducible example.) If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson

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