Custom css to theme key mappings
See original GitHub issueIt would be nice to manually define css style props to theme keys/scales mappings.
Say for instance I wanted to map the outline
css prop the the border
scale, or perhaps a custom outline
scale then I could do something like this in my theme object:
const myTheme = {
bloop: {
error: '1px solid tomato',
success: '1px solid springgreen',
info: '1px solid skyblue'
},
// customise theme spec here
customSpec: {
// define in the form 'css style prop': 'theme key'
'outline': 'bloop',
// overwrite mappings
'border': 'bloop'
}
}
This would then work in the sx
prop like so:
sx={{ outline: 'error' }}
Of course I could use functional values but it can be come a bit cumbersome.
I am suggesting this since I have many outline: theme => theme.borders.outline
in my code but perhaps there are other cases where it could be useful, maybe opacities or transitions? I’m happy to submit a PR for this if need be.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Coding a CSS Theme Switcher - a Multitude of Web Dev Options
So many options for building a theme switcher or customization - CSS, ... allow nesting of key-pair maps that can hold any valid...
Read more >How to Edit, Customize, and Override Bootstrap CSS to Suit ...
Learn how to override Bootstrap CSS using simple CSS overrides or Sass variables and maps to customize your site.
Read more >SASS Tutorial (build your own CSS library) #8 - Maps - YouTube
Hey gang, in this SASS tutorial we'll be talking a look at maps and how we can use them to group together several...
Read more >Working with Custom CSS in Divi: Beginner Guide 2022
A comprehensive, complete guide for Divi users who want to use custom CSS in Divi. Available as text and video tutorial to help...
Read more >Theming Bootstrap
Now, theming is accomplished by Sass variables, Sass maps, and custom CSS. There's no more dedicated theme stylesheet; instead, you can enable the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Fair enough, I will close this issue to remove clutter.
I was mainly suggesting this for the case of
transitions
andoutlines
anyway, once the typescript conversion is done I might add a PR for thoseWhile we do not plan on making the
sx
prop customizable, properties liketransition
andoutline
could (should probably) be added to the implementation