@@ -38,6 +38,7 @@ export type ThemeOptions = false | {
3838 themes ?: Record < string , ThemeDefinition >
3939 stylesheetId ?: string
4040 scope ?: string
41+ unimportant ?: boolean
4142}
4243export type ThemeDefinition = DeepPartial < InternalThemeDefinition >
4344
@@ -49,6 +50,7 @@ interface InternalThemeOptions {
4950 themes : Record < string , InternalThemeDefinition >
5051 stylesheetId : string
5152 scope ?: string
53+ unimportant : boolean
5254}
5355
5456interface VariationsOptions {
@@ -197,6 +199,7 @@ function genDefaults () {
197199 } ,
198200 } ,
199201 stylesheetId : 'vuetify-theme-stylesheet' ,
202+ unimportant : false ,
200203 }
201204}
202205
@@ -357,6 +360,7 @@ export function createTheme (options?: ThemeOptions): ThemeInstance & { install:
357360
358361 const styles = computed ( ( ) => {
359362 const lines : string [ ] = [ ]
363+ const important = parsedOptions . unimportant ? '' : ' !important'
360364
361365 if ( current . value ?. dark ) {
362366 createCssClass ( lines , ':root' , [ 'color-scheme: dark' ] , parsedOptions . scope )
@@ -377,14 +381,14 @@ export function createTheme (options?: ThemeOptions): ThemeInstance & { install:
377381 const colors = new Set ( Object . values ( computedThemes . value ) . flatMap ( theme => Object . keys ( theme . colors ) ) )
378382 for ( const key of colors ) {
379383 if ( key . startsWith ( 'on-' ) ) {
380- createCssClass ( fgLines , `.${ key } ` , [ `color: rgb(var(--v-theme-${ key } )) ! important` ] , parsedOptions . scope )
384+ createCssClass ( fgLines , `.${ key } ` , [ `color: rgb(var(--v-theme-${ key } ))${ important } ` ] , parsedOptions . scope )
381385 } else {
382386 createCssClass ( bgLines , `.bg-${ key } ` , [
383387 `--v-theme-overlay-multiplier: var(--v-theme-${ key } -overlay-multiplier)` ,
384- `background-color: rgb(var(--v-theme-${ key } )) ! important` ,
385- `color: rgb(var(--v-theme-on-${ key } )) ! important` ,
388+ `background-color: rgb(var(--v-theme-${ key } ))${ important } ` ,
389+ `color: rgb(var(--v-theme-on-${ key } ))${ important } ` ,
386390 ] , parsedOptions . scope )
387- createCssClass ( fgLines , `.text-${ key } ` , [ `color: rgb(var(--v-theme-${ key } )) ! important` ] , parsedOptions . scope )
391+ createCssClass ( fgLines , `.text-${ key } ` , [ `color: rgb(var(--v-theme-${ key } ))${ important } ` ] , parsedOptions . scope )
388392 createCssClass ( fgLines , `.border-${ key } ` , [ `--v-border-color: var(--v-theme-${ key } )` ] , parsedOptions . scope )
389393 }
390394 }
0 commit comments