
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
react-theme-provider
Advanced tools
https://github.com/sm-react/react-theme-provider
A generic theme provider and (very) simple CSS styler
now it is under development, see live demo, and this README
theme data
to your React Components via context
. You don't need to have Material-UI in dependencies if you just want to pass your created theme to your non Material-UI components.html
elements - it will be based on your theme settings.html
elements. They will have same appearance with the marerial ones if wrapped in this provider.It's just plain javascript object, typically with two levels of nesting.
Primer:
const greyTheme = {
themeName: 'Grey Theme',
themeFile: 'greyTheme.json',
palette: {
primary1Color: '#00bcd4',
alternateTextColor: '#4a4a4a',
canvasColor: '#616161',
textColor: '#bdbdbd',
secondaryTextColor: 'rgba(255, 255, 255, 0.54)',
disabledColor: '#757575',
accent1Color: '#607d8b',
},
};
You can develop your own themes with this tool (or see Live Demo)
a string containing CSS rules. Typically it's a template string with passed theme props:
.themed div {
color: ${palette.textColor};
background-color: ${palette.canvasColor};
}
.themed a {
color: ${palette.primary1Color};
}
Explore this live demo project:
<ThemeProvider
themes={[greyTheme, altTheme]}
themeInd={1}
override
setCSS={CSSrule}
>
<ThemedComponent />
</ThemeProvider>
themes
- array with themes created in storybook-addon-material-ui. not required
themeInd
- to set the current theme from themes
. not required
override
- if you use it inside of MuiThemeProvider
(Material-UI) it will override theme. not required
setCSS
- your custom CSS style function. You can set your own rules for CSS styling based on the theme setting. not required
if you use it without any props inside the
MuiThemeProvider
, it will provide CSS style for yourhtml
elements based on the current theme
if you use it without any props outside the
MuiThemeProvider
, it will provide CSS style for yourhtml
elements based on the default theme and pass this theme to your components via context same way asMuiThemeProvider
.
by default you will have follow CSS settings:
.${className} div {
color: ${palette.textColor};
background-color: ${palette.canvasColor};
border-width: 1px;
border-color: ${palette.borderColor};
}
.${className} a {
color: ${palette.primary1Color};
}
.${className} span {
color: ${palette.accent1Color};
}
.${className} ::selection {
background: ${palette.primary2Color};
}
npm i react-theme-provider --save
import ThemeProvider from 'react-theme-provider';
<ThemeProvider>
<YourThemedComponentOrPlainHTML />
</ThemeProvider>
FAQs
The part of 'React Theming' project
We found that react-theme-provider demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.