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.

Responsive variants take precedence over inline sx styles

See original GitHub issue

Issue

Works as intended. DripText gets the styles fonts-size: 2px:

const theme = {
  text: {
    primary: {
      fontSize: 40,
    },
  },
}

...

<DripText variant="primary" sx={{ fontSize: 2 }}>
    joi
</DripText>

Doesn’t work as intended. DripText maintains the responsive styles e.i 40px, 50px, 60px:

const theme = {
  text: {
    primary: {
      fontSize: [40, 50, 60],
    },
  },
}

...

<DripText variant="primary" sx={{ fontSize: 2 }}>
    joi
</DripText>

Other notes

  • When inline sx fontSize is changed to a string value e.i "2px" I get the same behavior.
  • Reproduced on example app and in my own applications

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nandorojocommented, Nov 25, 2020

In terms of order, precedence should take place based on each item in the array. So a responsive value from superStyle should override any style for the same style key before it. It looks like this is just checking if a non-responsive value already exists for a given key, and if it does, use that. I believe this would mean that we wouldn’t be able to override theme values with any responsive style props.

I’ll think this one over as well.

The main question: how do we get styles to cascade in order from top to bottom of styleArray, where each style overwrites the previous one, and where we only sometimes have a responsive array?

0reactions
nandorojocommented, May 18, 2021

Closing since there hasn’t been activity here in a while

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Ultimate Guide to the MUI 'sx' Prop - Smart Devpreneur
Both of the new APIs offer the following advantages over makeStyles : ... Easy responsive styling – properties in sx can accept an...
Read more >
Responsive values is variant styles override sx styles #720
Pretty sure I'm having the same issue: My cards.primary defines p: [2, 3] . To set padding to 0, I have to do...
Read more >
The `sx` Prop - Theme UI
The sx prop lets you style elements inline, using values from your theme. To use the sx prop, add the custom /** @jsxImportSource...
Read more >
Style library interoperability - Material UI - MUI
Note: Most CSS-in-JS solutions inject their styles at the bottom of the HTML <head> , which gives MUI precedence over your custom styles....
Read more >
Component Style - Chakra UI
Variant : A component can have different visual styles (e.g. outline, solid, ghost); Color scheme: For a given variant, a component can have...
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