css-modules

Using SCSS variables in CSS Modules

风格不统一 提交于 2021-02-18 22:33:06
问题 I've a _color.scss file which consists of 400 colors as variables. And I've like 20 components which needs this color variables in their styles. I'm using SCSS + CSS Modules to construct my styles. As of now, I'm importing this _color.scss in each and every component's style.scss . Example: component1.scss @import "color.scss"; component2.scss @import "color.scss"; component3.scss @import "color.scss"; Previously, when I was using SCSS standalone, I'll import the color.scss to my index.scss

How do I fix typescript compiler errors on css files?

女生的网名这么多〃 提交于 2021-02-09 09:05:45
问题 I'm trying to create a React project with typescript using webpack. But I can't manage to get CSS modules working. I keep getting this error when trying to import the CSS files in typescript: ERROR in src/components/Button.module.css:1:0 [unknown]: Parsing error: Declaration or statement expected. > 1 | .myButton { 2 | box-shadow: 0px 0px 0px -1px #1c1b18; 3 | background:linear-gradient(to bottom, #eae0c2 5%, #ccc2a6 100%); 4 | background-color:#eae0c2; ℹ 「wdm」: Failed to compile. To me this

How do I fix typescript compiler errors on css files?

被刻印的时光 ゝ 提交于 2021-02-09 09:04:27
问题 I'm trying to create a React project with typescript using webpack. But I can't manage to get CSS modules working. I keep getting this error when trying to import the CSS files in typescript: ERROR in src/components/Button.module.css:1:0 [unknown]: Parsing error: Declaration or statement expected. > 1 | .myButton { 2 | box-shadow: 0px 0px 0px -1px #1c1b18; 3 | background:linear-gradient(to bottom, #eae0c2 5%, #ccc2a6 100%); 4 | background-color:#eae0c2; ℹ 「wdm」: Failed to compile. To me this

How do I fix typescript compiler errors on css files?

。_饼干妹妹 提交于 2021-02-09 09:03:13
问题 I'm trying to create a React project with typescript using webpack. But I can't manage to get CSS modules working. I keep getting this error when trying to import the CSS files in typescript: ERROR in src/components/Button.module.css:1:0 [unknown]: Parsing error: Declaration or statement expected. > 1 | .myButton { 2 | box-shadow: 0px 0px 0px -1px #1c1b18; 3 | background:linear-gradient(to bottom, #eae0c2 5%, #ccc2a6 100%); 4 | background-color:#eae0c2; ℹ 「wdm」: Failed to compile. To me this

using css modules in react how can I pass a className as a prop to a component

眉间皱痕 提交于 2021-02-06 10:18:26
问题 If I have a react component and I want to pass in a className, how do I do this with CSS Modules. It currently just gives the className but not the hash generated css module name which I would get for <div className={styles.tile + ' ' + styles.blue}> Here is my Tile.js component import React, { Component } from 'react'; import styles from './Tile.css'; class Tile extends Component { render() { return ( <div className={styles.tile + ' ' + this.props.color}> {this.props.children} </div> ); } };

css-loadel - how to correct use with webpack 5

回眸只為那壹抹淺笑 提交于 2021-01-29 13:56:15
问题 I have some files. Webpack config { test: cssModuleRegex, use: [ { loader: 'style-loader' }, { loader: 'css-loader', options: { modules: true, } }, ] }, main.module.scss .page { height: 100vh; display: flex; align-items: center; justify-content: center; } and i use it in react component as css-module import styles from './main.module.scss'; export class Main extends PureComponent<Props> { render() { return ( <div className={ styles.page }> <Logo /> </div> ); } } But it doesn't work If i

How to overwrite styles with classes and css modules?

陌路散爱 提交于 2021-01-28 13:35:49
问题 Focused, checked classes seems to not work properly. I need to always use !important or use jss styles provided by material-ui. For example: https://codesandbox.io/s/css-modules-nvy8s?file=/src/CssModulesButton.js CssModulesButton.module.css .checkboxtest { color: blue; } .checkboxtestworking { color: blue !important; } CssModulesButton.js import React from "react"; // webpack, parcel or else will inject the CSS into the page import styles from "./CssModulesButton.module.css"; import Checkbox

How to overwrite styles with classes and css modules?

ぐ巨炮叔叔 提交于 2021-01-28 13:34:50
问题 Focused, checked classes seems to not work properly. I need to always use !important or use jss styles provided by material-ui. For example: https://codesandbox.io/s/css-modules-nvy8s?file=/src/CssModulesButton.js CssModulesButton.module.css .checkboxtest { color: blue; } .checkboxtestworking { color: blue !important; } CssModulesButton.js import React from "react"; // webpack, parcel or else will inject the CSS into the page import styles from "./CssModulesButton.module.css"; import Checkbox

How can I style react-datepicker?

随声附和 提交于 2021-01-26 19:34:53
问题 I'm using webpack , react-datepicker and have managed to import its css with the provided css module. import 'react-datepicker/dist/react-datepicker-cssmodules.css The component looks fine and dandy, but now I want to make it full width like the time element above it. Looking at the CSS, what it needs is for the react-datepicker-wrapper element that gets dynamically added by the library to have display: block . Any modifications I make to react-datepicker-wrapper in my own css does nothing.

How can I style react-datepicker?

人走茶凉 提交于 2021-01-26 19:30:02
问题 I'm using webpack , react-datepicker and have managed to import its css with the provided css module. import 'react-datepicker/dist/react-datepicker-cssmodules.css The component looks fine and dandy, but now I want to make it full width like the time element above it. Looking at the CSS, what it needs is for the react-datepicker-wrapper element that gets dynamically added by the library to have display: block . Any modifications I make to react-datepicker-wrapper in my own css does nothing.