how to remove imported css in create-react-app? - create-react-app

In my content.tsx file I have:
import style from 'style.css';
The CSS file is imported and appended to head when the page is loaded which is fine, but is there a way to remove this style from DOM inside the same content.tsx?
console.log(style) only shows a empty object.

Just remove import style from 'style.css'; from your component if you don't want to include the CSS

Related

How to apply CSS to the input fields of only one react component?

I am trying to apply CSS to the input fields of a react component. I have written CSS in a correspondent CSS file of a component but It is applied to input fields of other components. What can I do to apply the input field styles only for the component that I want? In the image below I have shown the code of CSS input fields of a single component
First of all, make sure your CSS file name is fileName.module.css:
style.module.css
Write your CSS attributes:
.test{color:red;}
Import your CSS file into your React component:
import styles from './style.module.css'
Apply the style:
<h1 className={styles.test}>This is test text.</h1>
Done!

How to access antd less variables when defining a css module for a component?

I'm using customize-cra as suggested by antd documentation to be able to customize the theme and it works fine.
I can access less variables from antd theme by importing the index in my less files and it works fine.
I can use the old fashioned css modules to style my components by defining files with .module.css and it works fine.
However, I would like to import and use the antd theme less variables in my css modules and I can't figure out how to make it work. Does anybody know how it can be achieved?
I am able to use the variables if I import antd.less at the top of the whatevercomponent.less file:
#import 'antd/dist/antd.less';

Strange text in Vue.js

I am trying to develop an application using vue.js2. I am getting some strange texts in source code. You can see those texts in below image.
Could anyone say why it is coming ?
You might be using scoped attribute on styles tag in your .vue files to scope your styling to the component only.
Any styles scoped to a component using the <styles scoped> ... </styles> , the styles will be applied only to the elements in that component only.
So vue-loader which parses the .vue files uses PostCSS behind the scenes to achieve this by add adding those weird and unique data attributes.
See Scoped CSS for more info

Override base CSS in react-select component

I am trying to override the .Select-control css component in react-select.
I want to set a custom height (the default is 36px) so it will look more closely to my other input fields
I have tried to add my own className prop as suggested in the docs however it does not seem to work and just pushes everything down (which makes sense since it's the wrapper for the component)
Is it possible to override the component itself?
I just started working with react-select and ended up overriding the components to bring the elements in line but also had success with passing in my own classes.
.Select-control {
height: 32px
}
I noticed that some of the css selectors can be pretty specific so referencing the css file helped to make sure I overrode the included styles. If you're using ES6 syntax I think you need to import your css after importing the react-select css in order to override.
Hope that helps

Remove Style in Materializecss inputs

How can completely remove the styling of inputs in materializecss? Changing the CSS alone doesn't seem to work as expected.
Use the Materialize class "browser-default".
For example:
<input type="text" class="browser-default"/>
Documentation here: http://materializecss.com/helpers.html#browser-default.
The easiest way to remove the styling of inputs in materializecss is to download the sass file and remove the elements you dont wish to be imported. After that you just have to compile sass to css.
View the source of this if you want to download the compiled css file from which the input styling was removed.
How to install/use sass