Add Display Name to CSS classNames for Easy Debugging
See original GitHub issueOpening a separate issue as requested by @hendrikniemann in https://github.com/chakra-ui/chakra-ui/issues/211.
It would be very helpful if chakra-ui
adds component names to CSS classes it generates, like styled-components
does. So that we can see components names not only in react developer tools, but in Elements panel as well.
ATM it looks like this: and it’s very hard to understand anything.
If it’s Flex-css-5vq3nc
or Box-css-5vq3nc
- it’s at least something.
I’m not sure if we can add names of custom components like styled-components
does this, so that
import React from 'react`
import styled from 'styled-components'
const StyledSomething = styled.div`
display: flex;
`
const CustomComponent = () => <StyledSomething />
export default CustomComponent
becomes CustomComponent-css-5vq3nc
.
If it’s possible, it would be super helpful.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:10
- Comments:9 (4 by maintainers)
Top Results From Across the Web
CSS Naming Conventions that Will Save You Hours of ...
Using the BEM naming convention, element class names are derived by adding two underscores, followed by the element name. For example:
Read more >Debugging CSS - Learn web development | MDN
Select an element on your page, either by right/ctrl-clicking on it and selecting Inspect, or selecting it from the HTML tree on the...
Read more >CSS Class Selectors: How to Use to Style an HTML Element
Do you want to stylize HTML elements without hassle? CSS classes will help you do the job! Here, you'll learn how to use...
Read more >Applying CSS by Component's displayName? - Stack Overflow
Calling all experts! I am trying to add a class to disable all element's descendants to be read only, the style is fine,...
Read more >Readable Classnames with Styled-Components - Medium
Please note that this articles purpose is to aid in debugging the dom tree when ... Styled-components allow developers to write styles using...
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
Since
babel-plugin-emotion
is adding that Contextual Class Names. You can setbabel-loader
to not exclude@chakra-ui
inwebpack.config.js
in the js loader rule:I tested it and it started to show chakra’s components names in the classNames, but mostly
Box
andBox-PseudoBox
so probably not what you wanted.you could do this: