Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use styled-system properties inside of styled component definition with Emotion (not default props) #1920

Open
garrettg123 opened this issue Apr 5, 2021 · 0 comments
Labels

Comments

@garrettg123
Copy link

How can one use, for example, the fontSize property, while creating a styled component?

In the following case, it's possible to set the font size and color using the defaultProps. Is there a way to set them inside of the styled.label definition while still being able to add custom css (like display: block below)?

import styled from '@emotion/styled'
import { ThemeType } from './theme'
import { color, ColorProps, fontSize, FontSizeProps } from 'styled-system'

type PropsType = FontSizeProps<ThemeType> & ColorProps<ThemeType>
const Label = styled.label<PropsType>`
  display: block;

  ${fontSize}
  ${color}
`

Label.defaultProps = {
  fontSize: 0,
  color: 'text.default',
}

export default Label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant