Comments (3)
Why do you need to call extendTheme
based on the existing theme? It's not designed to be used like this. If you need multiple themes, they should be independent or you should extract shared tokens.
const tokens = { … };
cons theme1 = extendTheme(tokens);
const theme2 = extendTheme(tokens);
from material-ui.
It's not designed to be used like this
Is it not supposed to mimic createTheme
? According to the docs here:
When the value for a theme option is dependent on another theme option, you should compose the theme in steps.
let theme = createTheme({ palette: { primary: { main: '#0052cc', }, secondary: { main: '#edf2ff', }, }, }); theme = createTheme(theme, { palette: { info: { main: theme.palette.secondary.main, }, }, });
The app I'm trying to migrate from createTheme
to extendTheme
uses this idea of constructing the theme in steps. I know it's still experimental but the docs kind of imply that extendTheme
and createTheme
can be 1:1 swapped for each other
from material-ui.
Having the same issue over here. My use case is that I have a function that is used to automatically configure locales for various themes. So it takes a language and an existing theme object and adds the locales to it. Works with createTheme, but getting the error above when trying to switch to the new extendTheme.
export const useThemeWithLocale = (
language: LanguageType,
theme: CssVarsTheme,
...args: object[]
): CssVarsTheme => {
const muiLanguage = language.replace(/-/g, '');
return useMemo(
() =>
extendTheme(
// current theme
theme,
// core translations
muiBaseLocales[muiLanguage],
// current language
{ language },
...args,
),
[args, language, muiLanguage, theme],
);
};
My current workaround is to take a CssVarsThemeOptions argument instead, but this is less than ideal since not all of the themes that we are dealing with have a separate options object created for them (we don't manage the code for all of the themes that we accept into this function).
from material-ui.
Related Issues (20)
- [docs] CSS modules customization guide is incomplete
- Upgrading to 5.16.1 ignores `defaultProps` in MUI theme HOT 1
- [material-ui][TextField] `id` in `InputProps` in TextField is reflected in its HTML input, not parent div. HOT 3
- [material-ui] Blog template has broken image links HOT 1
- [material-ui] Blog template has broken image links HOT 2
- @mui/[email protected] missing dependency @popperjs/core HOT 4
- Significant Bundle Size Increase After Recent MUI Update HOT 6
- npm install with v5.16.2 is throwing popper/node_modules does not exist HOT 1
- Could not resolve "@popperjs/core" HOT 1
- Make more compatible with Terser Mangler HOT 1
- TS Module Augmentation: Allow adding a new color to all components HOT 1
- [Joy-ui] [Table] Focus style on table rows is inconsistent
- [material-ui] Outlined Input component needs to get min value for its number type! HOT 1
- [material-ui][Select] Changing IconComponent makes the new icon unclickable HOT 2
- [material-ui][TextField] The override for MuiTextField does not work after changing from version 5.15.21 to 5.16.4 HOT 6
- [docs] StylesProvider to avoid ID changes with RTL snapshots HOT 2
- [material-ui][Autocomplete] Make multiple selected values available to FormData HOT 2
- Keyboard scrolling doesn't work in fullscreen Dialog
- Styles not added to shadow DOM when wrapping MUI in a library HOT 2
- [joy-ui] Overriding Drawer Size throws browser error in Dev build HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from material-ui.