Я использую styled-system
с styled components
и имею такой базовый случай:
const buttonFont = {
fontFamily: "Chilanka"
};
// style a boilerplate for text
const Text = styled.div`
${typography}
${color}
`;
// button blueprint
const Button = ({ children, ...rest }) => {
return (
<Text as="button" {...buttonFont } {...rest}>
{children}
</Text>
);
};
// styled button using button
const StyledButton = styled(Button)`
color: white;
background-color: gray;
padding: 10px 20px;
border: 2px solid black;
`;
// When using "as" this component does not includes buttonFont styles
const StyledLabel = styled(StyledButton).attrs({
as: "label"
})``;
Я хочу создать StyledLabel
, который унаследует все стили от StyledButton
, но изменит тег на label
. Но StyledLabel
не получает стилей buttonFont
при использовании атрибута "as"
.
См. Живой пример здесь: демонстрация