tailwind.config.jsのtheme
元々用意されているkey (e.g. backgroundColor)に対して、内容を変更できる
新しいkey名を導入できるわけではない
例えば、よく使う色や余白を用意するとかができる
どういうkeyが存在するかや、defualtの内容がどうなっているかを知っている必要がある
defaultの内容は default themeに書かれている
docs
default theme
用意されているkeyの種類
theme.screens
theme.colors
theme.spacing
tailwind CSSのcorePluginsで指定できるkey全て
例えば、fontFamilyとか
https://tailwindcss.com/docs/theme#core-plugins
もともと用意されているkeyに対して、ルールの内容を上書きする感じねmrsekut.icon
screensとcolorsとspacingの3つだけ特権的な場所にある
これら3つはtailwind CSSのcorePluginsには含まれていない
ここの構造を知っていないといけないmrsekut.icon
custmizeとしては2パターン
Tailwind CSSの特定のルールの内容を全て上書きする
Tailwind CSSの元のルールも残しながら、新しい値を追加する
↑いずれも、backgroundSizeみたいなkeyの部分は既存のものを使っている
keyは既存のままで、内容のみを書き換える
#WIP
『WEB+DB PRESS Vol.133』 p.70~
他の値を参照したルールを書ける
https://tailwindcss.com/docs/theme#referencing-other-values
関数ぽくかけばいい
code:js
module.exports = {
theme: {
spacing: {
// ...
},
backgroundSize: ({ theme }) => ({
auto: 'auto',
cover: 'cover',
contain: 'contain',
...theme('spacing')
})
}
}
default themeの参照できる
https://tailwindcss.com/docs/theme#referencing-the-default-theme
code:js
const defaultTheme = require('tailwindcss/defaultTheme')
module.exports = {
theme: {
extend: {
fontFamily: {
sans: [
'Lato',
...defaultTheme.fontFamily.sans,
]
}
}
}
}