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.

Extending a variant does not override its styles

See original GitHub issue

Describe the bug I would not only extend a variant but also alter some of its defined styles. In my case I’m defining some heading style and would like to extend those by overriding color.

To Reproduce define the following in your config:

colors: {
    text: '#000',
    primary: '#f00',
},
text: {
    heading: {
      fontFamily: 'heading',
      fontWeight: 'heading',
      lineHeight: 'heading',
      color: 'text'
    },
    headingLight: {
      variant: 'text.heading',
      color: 'primary'
    }
  }

and use <Heading variant='headingLight'>Testing</Heading> somewhere.

Expected behavior Headline should be red, but it is using the text color.

Additional context It works if you remove color: 'text' from the headling variant.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
lachlanjccommented, Jan 14, 2020

I’d absolutely love this. For example, I have a set of container styles, & they’re mostly the same, but I want to change the maxWidth on each one. Some basic composition/overrides like this would shorten my theme enormously.

0reactions
joernroedercommented, Jan 23, 2020

I revisited the components recently and now its working as expected. Not sure if it was related but having to pass down className all the time wasnt clear to me before reading through https://github.com/system-ui/theme-ui/issues/396 Maybe a high level explanation in the docs@Guides/HowToBuildYourOwnComponent so people can start with an example from there. Thanks for all the work btw, its amazing to work with!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MUI v5 - Extending Typography variant in TypeScript creates ...
Show activity on this post. I am setting up the base for an app with MUI v5 and TypeScript.
Read more >
Create and use variants - Figma Help Center
You can override Figma's default behavior and arrange variants in any way you choose. Select a variant and move it to new co-ordinates...
Read more >
Adding Custom Styles - Tailwind CSS
This guide covers topics like customizing your design tokens, how to break out of those constraints when necessary, adding your own custom CSS,...
Read more >
Theming Bootstrap
Every Sass variable in Bootstrap 4 includes the !default flag allowing you to override the variable's default value in your own Sass without...
Read more >
Advanced (LEGACY) - MUI System
⚠️ @mui/styles is the legacy styling solution for MUI. It depends on JSS as a styling solution, which is not used in 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