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.

RaLabeled classname not applied properly

See original GitHub issue

What you were expecting: We’re migrating over to RA 4, and we’ve noticed difficulties with applying style overrides to labelled components.

In the theme object we’re applying the following overrides:

RaLabeled: {
      styleOverrides: {
        label: {
          fontSize: "1.4em",
          color: PrimaryColors.Black,
          border: "1px solid red",
          opacity: 0.87,
          fontWeight: 500,
        },
      },
    },

But these styles aren’t being applied in the app because the classname being generated by RA is the following:

image

This might be a red herring, but it seems that our styles may not be applied properly because the Labeled component’s root cass class is css-8l66u2-MuiStack-root-RaLabeled-root. And it seems we can no longer target it via the theme object.

Do you have a codesandbox that uses RA v4 beta? If so i can create a repro case easily without having to pull from the repo

insert short code snippets here

Other information:

Environment

  • React-admin version: 4.0.0-beta.1.0
  • Last version that did not exhibit the issue (if applicable):
  • React version:
  • Browser:
  • Stack trace (in case of a JS error):

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
djhicommented, Mar 1, 2022

That’s because most of the default inputs don’t use the Labeled component but leverage the defaults of MUI instead.

I forked the codesandbox to show how to customize MUI labels and added a Labeled so that you can check it works.

https://codesandbox.io/s/modern-wave-q63dwi?file=/src/comments/CommentEdit.tsx

0reactions
andrico1234commented, Mar 1, 2022

Thanks a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

className not being correctly applied after server render
Notice that the background is green and the text reads CONTAINER--LARGE (should be blue). The text was server rendered as container--small ( ...
Read more >
Css classname not applied to react component - Stack Overflow
Firstly, you need to guarantee it's defined with: console.log(styles) Im' not sure you import style.scss correctly.
Read more >
The Basics - Manual - PHP
The class name can be any valid label, provided it is not a PHP reserved word. A valid class name starts with a...
Read more >
How to fix className styles not working in React and JavaScript
In this tutorial we can resolve className styles not working in React and JavaScript.Just rename the the css or scss file to filename.module ......
Read more >
className of leaflet popup option does not apply to the ...
I have a problem similar to this post. Basically, the CSS is not applying to the element I am trying to target, and...
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