Rebass: Is there any way to give default fontfamily?

Created on 24 Oct 2018  Â·  3Comments  Â·  Source: rebassjs/rebass

Is there any way to give default fontfamily somewhere like theme?

Thanks

Most helpful comment

@mrcoles Fragments don't render anything, so yeah, it'd have to be a <div> or other element – <div> is fine in this case since its only purpose is for styling and doesn't need to specify anything about the semantics of the content.

// example
const Root = styled('div')(props => ({
  fontFamily: props.theme.fonts.body,
  lineHeight: props.theme.lineHeights.body,
}))

All 3 comments

I tend to add a typography styled component to the root of an app since those CSS properties use inheritance. You can use styled-system to pick up fontFamily values from a theme if needed

Is there a quick example of what this looks like? Would the component add an extra dom element or can you style a react fragment?

@mrcoles Fragments don't render anything, so yeah, it'd have to be a <div> or other element – <div> is fine in this case since its only purpose is for styling and doesn't need to specify anything about the semantics of the content.

// example
const Root = styled('div')(props => ({
  fontFamily: props.theme.fonts.body,
  lineHeight: props.theme.lineHeights.body,
}))
Was this page helpful?
0 / 5 - 0 ratings

Related issues

coreybruyere picture coreybruyere  Â·  5Comments

contra picture contra  Â·  5Comments

jamesknelson picture jamesknelson  Â·  4Comments

mrcoles picture mrcoles  Â·  4Comments

steida picture steida  Â·  4Comments