【发布时间】:2021-08-12 19:46:25
【问题描述】:
如何在Styled-Component 中指定传递的参数是font-size 类型?
这是我在 TypeScript 中的代码:
export const StyledOldPrice = styled.span<{ fontSize: <HERE> }>`
font-weight: 400;
font-size: ${({ fontSize }) => (fontSize ? fontSize : "smaller")};
align-self: flex-end;
margin-bottom: 5%;
color: #656b6f;
`;
在使用样式时获取 IntelliSense,例如larger、x-small、smaller ...等
<StyledOldPrice fontSize={...} />
【问题讨论】:
标签: css typescript types styled-components