In the age of NPM, nobody needs .CSS files
yarn add styled-components
// or:
npm install styled-components
// then, just import it:
import styled from "styled-components"
const Headline = styled.h1`
color: green;
`
function App() {
return (
<Headline>
The Headline
</Headline>
)
}
const Headline = styled.h1`
color: green;
font-size: 25px;
margin: 0;
`
const Headline = styled.h1`
color: green;
`
const HeadlineItalic = styled(Headline)`
font-style: italic;
`
const Headline = styled.h1`
color: ${props => props.color};
`
function App() {
return (
<Headline color="red">
Text
</Headline>
)
}
const Headline = styled.h1`
visibility: ${props => (
props.show ? "visible" : "hidden")
};`
function App() {
return (
<Headline show={false}>
Text
</Headline>
)
}
import styled, { ThemeProvider} from "styled-components"
const Head = styled.h1`
color: ${props => props.theme.main};
`
const theme = {
main: "#14114a"
}
function App() {
return (
<ThemeProvider theme={theme}>
<Head>Headline</Head>
</ThemeProvider>
)
}
const Headline = ({ className, children}) => (
<h1 className={className}>{children}</h1>
)
const HeadlineStyled = styled(Headline)`
color: red;
`
const Headline = styled.h1({
color: "red",
fontSize: "50px"
})
const Wrapper = styled.div`
height: 400px;
width: 400px;
background-color: green;
`
const Text = styled.div`
color: red;
${Wrapper}:hover & {
color: blue;
}`
<Wrapper>
<Text>Some Text</Text>
</Wrapper>