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

[Bug Report] Impossible to set color of List Item text #9285

Closed
varna opened this issue Oct 8, 2019 · 17 comments · Fixed by #13719 or #14207
Closed

[Bug Report] Impossible to set color of List Item text #9285

varna opened this issue Oct 8, 2019 · 17 comments · Fixed by #13719 or #14207
Labels
C: VList VList help wanted We are looking for community help T: bug Functionality that does not work as intended/expected
Milestone

Comments

@varna
Copy link

varna commented Oct 8, 2019

Environment

Vuetify Version: 2.1.1
Vue Version: 2.6.10
Browsers: Chrome 77.0.3865.90
OS: Mac OS 10.14.6

Steps to reproduce

Try to set color (text/icon) of not active list item with available tools:

  • color prop on list item;
  • active-class prop on list item;
  • class on list item;
  • css;
  • css with !important;
  • inline css;

Expected Behavior

image

Actual Behavior

image

Impossible to replace light* text color of dark list item without inline css.
With inline css active tile is effected and cannot be styled to have dark* text color.

*light = the white color used for light theme backgrounds and dark theme texts.
*dark = the black color used for dark theme backgrounds and white theme texts.

image

Reproduction Link

https://codepen.io/JesusCrow/pen/OJJPqVb?editors=0100

Other comments

I tried everything I could think up to create a list item that has a certain color for text and icon. I think that this is impossible without inline css. Using inline css disables me from styling active item text.

@ghost ghost added the S: triage label Oct 8, 2019
@UglyHobbitFeet
Copy link

FYI you can make custom css per theme. https://stackoverflow.com/questions/58067386/vuetify-themes-with-custom-css

@varna
Copy link
Author

varna commented Oct 11, 2019

So if I want to change color of text in list items located at my navigation drawer I should overwrite dark mode text color? Which would change color of ANY text anywhere where dark mode is used? And it still wouldn't work, because of rules like:

.theme--dark.v-list-item:not(.v-list-item--active):not(.v-list-item--disabled) {
  color: #fff!important;
}

Or are you trying to suggest that I would create inline style with .theme--dark. Because I don't know anything that could overturn last css statement with !important without using inline css. And I have never seen inline css selectors.

@UglyHobbitFeet
Copy link

I'm trying to say you can do an easy customization that way as a temporary or permanent workaround to your issue. Just label your html code with class/id tags and reference them using the theme. As an example you could have your nav drawer as <v-navigation drawer class="myClass" .../> and then in the css you could either use SASS/SCSS or just do something like .v-application.theme--light myClass { color:black; } and .v-application.theme--dark myClass { color:white; }

@UglyHobbitFeet
Copy link

To get to the text in a list item in a navigation drawer you can use css rules to drill down from the starting point of the navigation drawer. https://www.w3schools.com/cssref/sel_element_gt.asp

@varna
Copy link
Author

varna commented Oct 17, 2019

Thanks! Totally forgot that I can add classes and ids without style and use them as selectors...

#SidebarNavigation .theme--dark.v-icon {
  color: #f2a52b !important;
}

@johnleider
Copy link
Member

Can you please reduce this to a minimal reproduction, thank you!

@johnleider johnleider added the S: needs reproduction The issue does not contain a valid reproduction label Oct 24, 2019
@varna
Copy link
Author

varna commented Oct 25, 2019

Vuetify "provides" 3 styling approaches via props color, class and active-class. This is very obscure. It's impossible to use a simple cascading approach to style list with provided api.

There are 6 colors of interest while styling item list:

  • color (text color);
  • background (background color);
  • color:selected (text color of selected list item);
  • background:selected (background color of selected list item);
  • color:hover (text color of hovered list item);
  • background:hover (background color of hovered list item).

I only wanted to apply background, color, background:selected and color:selected.
In this example:
✅Background should be black;
⚠️ Color of text should be grey;
⚠️ Background of active item should be amber;
✅Color of active item text should be green.

First problem is that you apply some sort of tint that is not removed when active-class prop is applied.

Second problem is that you can't simply set the text color of list item. Most of props only apply styles to selected items instead of normal items. Even if you manage to add some styles to normal text, it gets overwritten by some other styles applied by child components or !important css.

@johnleider johnleider added help wanted We are looking for community help T: bug Functionality that does not work as intended/expected and removed S: needs reproduction The issue does not contain a valid reproduction S: triage labels Nov 5, 2019
@acarlstein
Copy link

acarlstein commented Feb 20, 2020

FYI you can make custom css per theme. https://stackoverflow.com/questions/58067386/vuetify-themes-with-custom-css

This solution only works if you are allowed to use styles that are not scoped. Plus, if you are allowed to use CSS class names inside the scoped style that are not in the template. If you have restrictions by using a strict version of ESLint, then the alternative is to set a global scss in your vue.config.js:

'use strict'

module.exports = {
  transpileDependencies: [
    'vuetify'
  ],
  css: {
    loaderOptions: {
      scss: {
        prependData: '@import "@/scss/app.scss";'
      }
    }
  }
}

And then put the CSS changes in the app.scss file.
However, make sure that your component has a non-empty style with `lang="scss", else it will not be included.

You can also check out the Webpack plugin as an alternative.

@a-di-ez

This comment has been minimized.

@runlong-yao
Copy link

The color property of v-list-item is not working,because of default color style in vuetify.
For easy use,color property's style should override default color style

@AshrafBasry

This comment has been minimized.

@varna
Copy link
Author

varna commented Mar 30, 2021

Still not Fixed ?

I don't think it will ever be fixed with such "verbose" description.
Should probably close this issue and create something like:

Bug: v-list-item class="color--text" is only applied to active-class

@Tofandel
Copy link
Contributor

I'll make a PR, we should just remove the important keyword here, the selector is already quite powerful and it's really not needed

Tofandel added a commit to Tofandel/vuetify that referenced this issue May 28, 2021
@johnleider
Copy link
Member

I'm not sure that this is something we should touch in v2 at this point. I'll keep the conversation into consideration while working on v-list for v3.

@johnleider johnleider self-assigned this May 30, 2021
@johnleider johnleider added this to the v3.0.0 milestone May 30, 2021
@johnleider johnleider added this to To do in Vuetify 3 - Titan via automation May 30, 2021
@Tofandel
Copy link
Contributor

Tofandel commented May 30, 2021

Well just in case, the PR addresses this. The bug happens because the color prop applies all the time and the !important keyword was added to override this, a quick fix is to only apply the color class when the item is active (like the documentation suggests actually) and remove the important keyword. I would classify this as a minor breaking change, since the color class is not present anymore by default

Then it makes sense to also add a prop to be able to change the base color when the item is not active

Anyways, I saw so many dirty workarounds in the projects I oversee referencing this issue that I decided to tackle this, so I'd be happy to see it in v2.6 as well as its my understanding there is still several months of waiting until v3 is ready

Otherwise the 5 specifier long css selector + important will have to do 😞

@johnleider johnleider added the C: VList VList label Jun 10, 2021
@johnleider johnleider moved this from To do to Done in Vuetify 3 - Titan Jun 10, 2021
@johnleider
Copy link
Member

Fixed in 34a2683

If you have any questions, please reach out to us in our Discord community.

@KaelWD KaelWD modified the milestones: v3.0.0, v2.5.x Jun 13, 2021
johnleider added a commit that referenced this issue Jun 14, 2021
fixes #8137
fixes #9285
fixes #12826

Co-authored-by: Kael <kaelwd@gmail.com>
johnleider added a commit that referenced this issue Jun 14, 2021
fixes #8137
fixes #9285
fixes #12826

Co-authored-by: Kael <kaelwd@gmail.com>
@KaelWD KaelWD removed this from the v2.5.x milestone Sep 28, 2021
@KaelWD KaelWD reopened this Sep 28, 2021
@KaelWD
Copy link
Member

KaelWD commented Sep 28, 2021

Reverted in 4e4b1ea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: VList VList help wanted We are looking for community help T: bug Functionality that does not work as intended/expected
Projects
No open projects
9 participants