A JavaScript Library to change themes (Light - Dark - Auto)
npm install theme-changer-light-darkcss
body {
background-color: var(--bg);
color: var(--text);
}
`
$3
`js
import themeChanger from "https://codeabinash.github.io/theme-changer.js/index.js";
let theme = new themeChanger({
selector : '.btn',
theme: {
light:
--bg : #ddd;
,
dark:
--text: #eee;
}
})
`
Check The example from here : https://codeabinash.github.io/theme-changer.js/test/
$3
`js
let theme = new themeChanger({
selector : '.btn', // css selector (internally querySelectorAll)
theme: {
light: // css code
--bg : #ddd;
,
dark: // css code
--text: #eee;
}
})
`
$3
`js
let theme = new themeChanger({
theme: {
light: 'CSS code for light theme',
dark: 'CSS code for dark theme';
}
})
`
$3
`js
theme.getCurrentTheme()
// returns 'light' or 'dark'
`
$3
`js
theme.getTheme()
// returns 'Light' or 'Dark' or 'Auto'
`
$3
`js
theme.toggle()
// toggles theme as auto - light - dark
`
$3
`js
theme.applyAutoMode()
// applies auto mode
`
$3
`js
theme.applyLightMode()
// applies light mode
`
$3
`js
theme.applyDarkMode()
// applies dark mode
``