question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom css to theme key mappings

See original GitHub issue

It 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:closed
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
cour64commented, Mar 6, 2020

Fair enough, I will close this issue to remove clutter.

I was mainly suggesting this for the case of transitions and outlines anyway, once the typescript conversion is done I might add a PR for those

1reaction
jxnblkcommented, Mar 6, 2020

While we do not plan on making the sx prop customizable, properties like transition and outline could (should probably) be added to the implementation

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found