responsive-capsize
v2.0.1
Published
Generate Capsize text styles for multiple breakpoints using responsive arrays
Maintainers
Readme
Responsive Capsize
Responsive Capsize generates Capsize text styles for multiple breakpoints using responsive arrays.
Install
npm install responsive-capsizeUsage
Use the Capsize website to find the fontMetrics values for the specified font.
Responsive Capsize accepts responsive arrays for the following input values:
capHeightorfontSizefor defining the size of textlineGaporleadingfor specifying line height. If you pass neither, the text will follow the default spacing of the specified font eg.line-height: normal
See the Capsize documentation for further information.
import responsiveCapsize from 'responsive-capsize'
const fontMetrics = {
capHeight: 1456,
ascent: 1900,
descent: -500,
lineGap: 0,
unitsPerEm: 2048
}
const capsizedTextStyles = responsiveCapsize({
fontMetrics,
capHeight: [24, 48],
lineGap: [12, 24]
})Examples
The output styles can be used in the following ways.
Included in a Theme UI styles object:
export default {
styles: {
h1: {
fontFamily: 'heading',
fontWeight: 'heading',
...capsizedTextStyles
}
}
}Added to an element using Theme UI's sx prop:
export default props => (
<h1
sx={{
...capsizedTextStyles
}}
>
Responsive Heading
</h1>
)Added to an element using Styled System's css prop:
export default props =>
<h1
css={css({
...capsizedTextStyles
}}
>
Responsive Heading
</h1>
)