Override plugin styles #1099
-
Hi, I'm writing a plugin, which provides a Vue component, with an imported stylesheet. The plugin is here: https://github.com/dice-roller/vuepress-plugin/
import { DiceRoller } from '@dice-roller/vue';
import '../styles/vars.css';
import '../styles/dice-roller.css';
export { DiceRoller };
export default DiceRoller; .dice-roller{
margin: 1rem 0;
padding: 1rem 1.5rem;
color: var(--dice-roller-color);
background-color: var(--dice-roller-bg);
}
... :root {
--dice-roller-text-color: #2c3e50;
--dice-roller-bg: #eeeeee;
--dice-roller-color: var(--dice-roller-text-color);
...
} This works fine to load in some default styles for the plugin, but I want people who implement the plugin to be able change the look of the component, by overriding the CSS variables. I followed the docs to create a styelsheet at :root {
--dice-roller-text-color: #ff0000;
...
} Unfortunately though, those styles don't get applied. It looks like they get added to the doc before the plugin stylesheet, so the plugin stylesheet gets precedent, and the styles don't get changed (I can see the local styles in dev tools, being overridden by the plugin ones). Judging by the documentation for the Back To Top plugin, it looks like it should be possible this way: https://v2.vuepress.vuejs.org/reference/plugin/back-to-top.html#styles I did try to change the back to top styles as well, just in case it was an issue with my plugin, but that had the same issue. Can anyone help me with finding a way of easily overriding the styles of a plugin? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Why don't you tell users to use |
Beta Was this translation helpful? Give feedback.
-
I created an issue #1110 and you can tract this. Currently you can use |
Beta Was this translation helpful? Give feedback.
I created an issue #1110 and you can tract this.
Currently you can use
!important
or a higher priority selector as a workaround.