🌐
GitHub
github.com › styled-components › babel-plugin-styled-components › issues › 274
Add prefix to class of all the styled components · Issue #274 · styled-components/babel-plugin-styled-components
March 14, 2020 - displayName: true/false - give the option to see in the class the file name and the component name. fileName: true/false -give the option to show just the styled component without the file name What if i want to add prefix to all the class name, for example I want to add "TEST-״ and then that styled-components will generate his own id.
Author   OriAmir
🌐
GitHub
github.com › styled-components › styled-components › issues › 3186
[Feature] Prefix hash class · Issue #3186 · styled-components/styled-components
June 30, 2020 - For obvious reasons we wouldn't want them to use styled component generated classes in the css selector so need to be able to provide known patterns of classes that are auto generated ex: sc-*. A potential solution: add an environment variable process.env.SC_HASH_PREFIX which we could prepend to the hash classname:
Author   gcoombe
🌐
GitHub
github.com › styled-components › styled-components › issues › 1671
Manually set class prefix in TypeScript without Babel · Issue #1671 · styled-components/styled-components
September 4, 2018 - import * as styledComponents from 'styled-components' export interface Theme {...} const { default: _styled, css, injectGlobal, keyframes, ThemeProvider } = styledComponents as styledComponents.ThemedStyledComponentsModule<Theme> function styled<TTag extends keyof JSX.IntrinsicElements = 'div'>(name: string, tag?: TTag) { let result = tag ? _styled(tag) : _styled.div // Use private API to add class prefix result = (result as any).withConfig({ displayName: name, }) return result } export { styled, css, injectGlobal, keyframes, ThemeProvider }
Author   andraaspar
🌐
GitHub
github.com › styled-components › styled-components › issues › 976
More meaningful/semantic class names during development · Issue #976 · styled-components/styled-components
July 7, 2017 - Currently all generated class names look like this: And it really causes problems while debugging. I do not understand where I am. Well of course I can switch between react devtools and inspector -- but it does not make it more convenien...
Author   deathmood
🌐
GitHub
github.com › styled-components › babel-plugin-styled-components › issues › 345
Remove or replace the `sc-` class prefix · Issue #345 · styled-components/babel-plugin-styled-components
February 8, 2021 - I'd like to remove/replace the sc- prefix thats added before each class name. I am using the Babel module. And I've tried namespace, but it does not remove sc-. And I don't want the __ ...
Author   brsnik
🌐
GitHub
github.com › styled-components › styled-components › issues › 1604
Styled Components naming convention · Issue #1604 · styled-components/styled-components
March 13, 2018 - However, this of course isn't possible since you can't have a component name which is the same as the class name. That's why I decided to go with class + Wrapper naming. In this case that leads to my ProductDetailWrapper name. ... // Styled Components import { Image, ImageWrapper } from './Image.sc'; export default class ProductDetailImage extends React.PureComponent { // Some stuff here render() { const { variantsAreBeingShown } = this.props; const { imageURL } = this.state; return( <ImageWrapper variantsAreBeingShown={variantsAreBeingShown}> <Image innerRef={ref => this.image = ref} onLoad={this.imageIsLoaded} src={imageURL} /> </ImageWrapper> ); } }
Author   daviddelusenet
🌐
GitHub
github.com › styled-components › styled-components › issues › 1789
Feature: Adding selector scoping for generated classNames · Issue #1789 · styled-components/styled-components
June 2, 2018 - If the hashed CSS classes for StyledCard was .13jdhx, they will now render as html #App .213jdhx. Any SC components that live within this ThemeProvider will receive this scoping.
Author   ItsJonQ
🌐
GitHub
github.com › styled-components › styled-components › issues › 291
Proposal: CSS Class Composition · Issue #291 · styled-components/styled-components
December 5, 2016 - For the most part, Styled Components is pretty hands-off about your CSS - there aren’t any special rules and other than auto prefixing, it doesn’t let you plug in PostCSS plugins of your own - is this sort of extra manipulation in the spirit ...
Author   ticky
Find elsewhere
🌐
GitHub
github.com › styled-components › styled-components › issues › 2113
Can we use styled components export className ? · Issue #2113 · styled-components/styled-components
October 18, 2018 - const Wrapper = styled.div` &-icon { color: #fff; } ` render() { const cls = Wrapper.getClassName(); return <Wrapper> <div className={`${cls}-icon`}>xxx</div> </Wrapper> } This saves a lot on the definition of the styled component。 · Reactions are currently unavailable ·
Author   windyGex
🌐
Daggala
daggala.com › differentiating-between-styled-compoonent-and-react-compoonent
Differentiating between a styled-component and a React component
When you define the styled component, you can add the prefix “Styled-” like <StyledButton/>, <StyledList /> etc. Like here. In this Github example the prefixing is however not being used for the same purposes.
Top answer
1 of 3
3

Currently styled-components uses MurmurHash algorithm to create a unique identifier and then converts the hash number to alphabetic name.

Each component instance with unique props has it’s own CSS class name which is generated by means of the MurmurHash algorithm, the componentId and the evaluatedStyles string:

const className = hash(componentId + evaluatedStyles);

Then this class name is stored in the component state as generatedClassName.

2 of 3
3

This was about all I could find in the styled-components FAQ

Each node actually has two classes connected to it: one is static per component, meaning each element of a styled component has this class. It hasn't any style attached to it. Instead, it's used to quickly identify which styled component a DOM objects belongs to or to make minor changes in the DevTools. It's also used for component selectors. The static class probably will look something like: .sc-fVOeaW.

The other is dynamic, meaning it will be different for every element of your styled component with different props, based on what the interpolations result in. It will probably look like .fVOeaW (note the lack of "sc" prefix.)

For example, the styled component <Button /> would render with the same static class every time. If the styles are changed using interpolations, like <Button secondary />, then the dynamic class will be a different one, while the static class would remain the same.

Also, Motivation

No class name bugs: styled-components generates unique class names for your styles. You never have to worry about duplication, overlap or misspellings.

TL;DR They are automagically generated and maintained by styled-components.

🌐
GitHub
github.com › RIP21 › with-styled-class-names
GitHub - RIP21/with-styled-class-names: Tiny utility function for styled-components helps to override 3rd parties components with custom className props for their deep nested children or different states · GitHub
May 10, 2021 - This is a tiny (666 bytes gzipped) zero dependency helpful utility function for styled-components which helps to override 3rd parties components with custom className props for their deep nested children or different states.
Author   RIP21
🌐
styled-components
styled-components.com › docs › api
styled-components
Ampersands (&) get replaced by our generated, unique classname for that styled component, making it easy to have complex logic.
🌐
GitHub
github.com › styled-components › styled-components › issues › 418
Using classNames instead of props · Issue #418 · styled-components/styled-components
January 27, 2017 - Recently attempting the switch to styled components. Loving it so far, with a few quibbles. Here's one. In my previous workflow, with plain old scss, I'd often do something like this: //component.js import './component.scss'; import cx from 'classnames'; const Component = (props) => { const className = cx(props.className, 'component', { off: props.off, active: props.id == 0, }); return ( <div className={className}>'Some text'</div> ); } //component.scss .component { font-size: 20px; background: black; color: white; width: 20em; height: 10em; &.off { color: black; height: 0em; } &.active { background: blue; outline: 1px solid white; width: 30em; height: 20em; } }
Author   clarityflowers
🌐
GitHub
github.com › styled-components › styled-components › issues › 1180
Specifying class names · Issue #1180 · styled-components/styled-components
September 27, 2017 - In order for us to use styled-components (or glamorous, for that matter), we need to be able to create CSS files with predictable class names (i.e.
Author   selbekk
🌐
Softchris
softchris.github.io › pages › react-styled-components.html
Styled components, the styling library for your React apps you don’t want to be without
As you can see above calling the styled() function means that it under the hood produces a className that it injects into our component that we need to set to our top-level element, for it to take effect.
🌐
GitHub
github.com › styled-components › styled-components › issues › 1165
Identifier (e.g. className) uglifying or hashing · Issue #1165 · styled-components/styled-components
September 14, 2017 - Identifier (e.g. className) uglifying or hashing#1165 ... This may be either a question or a feature request. I used to develop React application with Webpack, and one of the most useful gimmicks of Webpack was its css-loader's localIdentName. What localIdentName does was to give the reference to the css selector with a hashed name. For example, if there is a style definition as following,
Author   eldenpark
🌐
Smashing Magazine
smashingmagazine.com › 2020 › 07 › styled-components-react
How To Use Styled-Components In React — Smashing Magazine
July 23, 2020 - Apart from helping you to scope styles, styled components include the following features: Automatic vendor prefixing You can use standard CSS properties, and styled components will add vendor prefixes should they be needed.
🌐
Medium
tenosiswono.medium.com › micro-frontends-fixing-duplicate-class-name-in-styled-component-in-7d4486017925
Micro-frontends: Fixing duplicate class name in Styled Component | by Teno Siswono | Medium
January 6, 2022 - <div id="micro-1"> ... </div>#micro-1 .classname · styled-components use stylis for CSS Preprocessor, lucky there is some plugin available in styles to add parent scope · github.com · Next, we add this stylish plugin into some provider · In our microfe we just need to wrap with this provider ·