nanobar
nanobar copied to clipboard
Is there a way to change color of progress bar via options in js?
Hi, is it possible to change color of progress bar via
var nanobar = new Nanobar( { barCss: {'background-color': 'green' } );
I dont want to have it in less file.
No, it's not possible. But you can add a css line with javascript, nanobar is already doing that so you can use the same css tag:
const nanobar = new Nanobar()
const styleTag = document.getElementById('nanobarcss')
styleTag.innerHTML += '.nanobar .bar{background:#bdf;}'
Can I ask you, why do you do it this way? Is it faster or what?
I don't do it this way, I use css:
.nanobar .bar.errorbar {
background: #e44;
}
Of course, but if it would be in settings option it would be at one place. That's all.
I had to use the following styling to style the nanobar progress bar correctly:
.nanobar .bar { background-color: #0074d9; }