Answer the question
In order to leave comments, you need to log in
Why aren't the styles applied to the component already wrapped (styled-components)?
There is a ListItem component, inside it is nested the Label component, which is already styled earlier.
import Label from './../../Elements/Label/Label';
const LabelStyled = styled(Label)`
width: 10%;
flex-grow: 1
`;
export default (props) => {
return (
<ListItem>
<LabelStyled>{ 'Ярлык' }</LabelStyled>
</ListItem>
)
}
import React from 'react';
import styled from 'styled-components';
const Label = styled.div`
border: none;
border-radius: 20px;
background-color: #f63;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
height: 40px;
`;
export default (props) => {
return (
<Label>
{ props.children }
</Label>
)
}
Answer the question
In order to leave comments, you need to log in
It turns out you still need to pass className
import React from 'react';
import styled from 'styled-components';
const Label = styled.div`
border: none;
border-radius: 20px;
background-color: #f63;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
height: 40px;
`;
export default (props) => {
return (
<Label className={props.className}>
{ props.children }
</Label>
)
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question