Skip to content

Commit 07e330d

Browse files
committed
Allow default letterSpacing in fontSize config
Extend the configuration syntax to allow specifying letterSpacing alongside lineHeight in the fontSize config. The syntax looks like ``` module.exports = { theme: { // ... fontSize: { sm: ['14px', { lineHeight: '20px', letterSpacing: '0.01em' }], // ... } } } ``` Also retains backwards compatibility with array syntax of 1.3
1 parent 2b0b306 commit 07e330d

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/plugins/fontSize.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ export default function() {
44
return function({ addUtilities, e, theme, variants }) {
55
const utilities = _.fromPairs(
66
_.map(theme('fontSize'), (value, modifier) => {
7-
const [fontSize, lineHeight] = Array.isArray(value) ? value : [value]
7+
const [fontSize, options] = Array.isArray(value) ? value : [value]
8+
// Tailwind 1.3+ syntax allowed line height to be specified in the array like
9+
// ['16px', '24px'], so we can get it from there as well as from object syntax
10+
const lineHeight = options instanceof Object ? options.lineHeight : options
11+
const letterSpacing = options && options.letterSpacing
812

913
return [
1014
`.${e(`text-${modifier}`)}`,
@@ -15,6 +19,11 @@ export default function() {
1519
: {
1620
'line-height': lineHeight,
1721
}),
22+
...(letterSpacing === undefined
23+
? {}
24+
: {
25+
'letter-spacing': letterSpacing,
26+
}),
1827
},
1928
]
2029
})

0 commit comments

Comments
 (0)