Ionic-framework: bug: Progress bar doesn't use theme colors

Created on 17 Dec 2019  路  7Comments  路  Source: ionic-team/ionic-framework

Bug Report

Ionic version:


[x] 4.x

Current behavior:

Using an ion-progress-bar with a dark theme results in a white progress bar.

Expected behavior:

Progress bar would pick up the theme colors.

Steps to reproduce:

  1. Create an app with a progress bar
  2. Use the dark theme
  3. Progress bar is a white strip

Related code:
I had to do the following to fix it:

ion-progress-bar {
  --buffer-background: var(--ion-background-color);
  --background: var(--ion-background-color);
  --progress-background: var(--ion-color-step-400);
}

It seems like that should be the default.

Ionic info:

Ionic:

   Ionic CLI       : 5.4.12 
   Ionic Framework : @ionic/react 4.11.6

Capacitor:

   Capacitor CLI   : 1.2.1
   @capacitor/core : 1.3.0

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v12.11.0 
   npm    : 6.13.4
   OS     : macOS Mojave
core bug

Most helpful comment

Ok, I found a solution and will create a pull-request soon. It works with a wrapper for the circles buffer bar. It's moved by absolute position left and overflow hidden. Tested with reversed bar and theme light / dark.
fixed

All 7 comments

Thanks for the issue! The progress bar background is actually using --buffer-background: rgba( 56,128,255 ,0.2); which is appearing as white, but it is a shade of the primary color.

Per the Material Design spec for dark theme, it does need to be a darker shade of the primary color:

Screen Shot 2019-12-18 at 4 16 32 PM

I am adding all of this because this is a bug but when this issue is fixed it won't be using the colors you are setting it to. 馃檪

Thanks for the update. I don't expect it to be the colors I picked, per se, but I assume it would pick up the appropriate theme colors.

A year later... Here's a demo on Stackblitz

<ion-progress-bar value="0.5" color="primary"></ion-progress-bar>

image

image

image
(Toggle the background in Browser DevTools)

Why is the background set to 255, 255, 255 (white)? It's not a variable. No half opacity. It's just fixed white. (--buffer-background does not work.)

https://github.com/ionic-team/ionic-framework/blob/0a765c7172d49211e94ca5f37ca6059a33844b40/core/src/components/progress-bar/progress-bar.scss#L77

btw. I would suggest implementing a dark mode switch for the examples on the docs page.

Ionic 5 (5.4.4)
No solution yet.

The progress bar background is actually using --buffer-background: rgba( 56,128,255 ,0.2); which is appearing as white, but it is a shade of the primary color.

This is not exactly right. It does not appearing as white. It is set to white ('#fff'). See line 77 (code block below). It violates style conventions. Any idea is welcome. ...

Here is the reason for the solid color.

https://github.com/ionic-team/ionic-framework/blob/0a765c7172d49211e94ca5f37ca6059a33844b40/core/src/components/progress-bar/progress-bar.scss#L74-L77

Changing to this:

.progress-buffer-bar {
  background: var(--buffer-background);
}

Result:

demo-dark

demo-light

But, this should not be the solution. Never use fixed colors. Use theme variables or fixed colors with semi transparent color which does not interfere the theme.

We need a dark mode for the test bench during development and in the docs.
But back to this issue: Any suggestions? A spontaneous ideas: Use width and position for the buffer dots. So that the elements do not overlay. Or use a solid theme color. ... I see that the .buffer-circles animation is based on position (translateX). This limits possible quick fixes like using width / scale. 馃 Maybe with a wrapper overlay hidden? ...

Could we assign --buffer-background with default #fff to keep the current behavior. But with the option that the user can change it? It's better than a fixed solid color. I think the buffer feature is more rarely used than the default appearance. So with the accessibility to the buffer background variable I can control that color. And implement a workaround in my app. The long term solution is to replace the fixed solid color and use the theme variable like all other components.

Ok, I found a solution and will create a pull-request soon. It works with a wrapper for the circles buffer bar. It's moved by absolute position left and overflow hidden. Tested with reversed bar and theme light / dark.
fixed

Just for info: I see that the Angular Material UI framework also has this issue. I guess for that same reason. 馃槂 (You can switch the theme light / dark in the toolbar above.)
demo
(You see the Angular Material progress-bar) 馃憥

To be honest, I have to say that I don't like the Angular Material Framework. Because it is too limited. A good material design framework is Vuetify. Which has a great progress-bar with the same behavior as the Ionic progress bar with my changes. I have not checked the source code yet. ... It's not about code theft. It's about being inspired.
demo-vue
(You see the Vuetify progress-bar) 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daveshirman picture daveshirman  路  3Comments

BilelKrichen picture BilelKrichen  路  3Comments

gio82 picture gio82  路  3Comments

vswarte picture vswarte  路  3Comments

brandyscarney picture brandyscarney  路  3Comments