Equivalent of scss @import for styled-components?
You can declare css styles with the css
helper from styled-components
and then invoke it where you need it:
export const cleanSlateRules = css`
// styles
`;
export const StyledWhatever = styled.div`
${cleanSlateRules}
`;
EDIT: Turns out this currently doesn't work in prod. I think because of the same issue as the @import problem.
EDIT 2: I got this to work in production using the babel plugin for styled components. The custom css was successfully applied after that. See my answer here: styled-components only rendering certain styles after successful build with parcel
How to get Scss in styled component?
I suggest you use the styled-component and styled-system
import styled from "styled-component";
const StyledComponent = styled.p `
// scss content
color:red;
...
`
Const StyledComponent1 = styled(StyledComponent)`
// scss content
`
You can use your object it already have done by you easily.
const AnyStyledComponent = styled(AnyComponent)(
{
// style object(as you have done)
},
variant({
prop: "color",
variants: {
white: {
color: "#fff"
},
black: {
color: "#000"
}
}
})
)
And also you can refer to Theming in styled-components
Related Topics
How to Solve the Table Row Background Image Problem, in Chrome, in Multi Celled Tables
CSS Background-Image Refuses to Display in ASP.NET MVC
CSS Positioning Elements Next to Each Other
CSS Image Layouting Before Image Loaded
How to Force Firefox to Render Textarea Padding the Same as in a Div
How to Create Custom Tooltips with CSS Pseudoelements
Css: Height- Fill Out Rest of Div
Css3 Transitions: Is There an on Click Option Without Using Jquery
Jqgrid Zebra/Alt Rows Background Not Working Due to UI Theme Class
Extracting Content in :After Using Xpath
How to Use a Data Attribute to Set a Background-Image in CSS
What Is That Thing Between CSS "Selectors" Called
Has the ::-Webkit-Selection Selector Ever Been Supported
Clip-Path on Chrome Leaves a Strange Line on the Edge
Is It Bad to Work with Pixels in CSS
@Font-Face Svg Not Working Properly in Chrome