Hello @charlie67p
The size value in your example (most certainly) acts as the fallback value when fluid typography cannot be calculated or when the viewport is at the exact breakpoint where min = max.
However, in your specific example, you wont see any difference when changing size because you’ve explicitly defined both min and max values in the fluid object. When both are present, WordPress uses those values to generate the clamp() function and ignores the size value for the fluid calculation.
“size” only matters when using fluid as true without specifying a min and/or max. WordPress will then calculate min/max values based on the “size” using default fluid typographic scale.
I think this should be useful for your question – https://developer.ww.wp.xz.cn/block-editor/how-to-guides/themes/global-settings-and-styles/#typography
Hope this clarifies things!
Hi @lucianwpwhite , thanks for your answer,
”when fluid typography cannot be calculated”
>> does it means : when the browser is too old to calculate/understand clamp Css ?
“size only matters when using fluid as true without specifying a min and/or max”
>> so in this case, as I specify the min and the max, why should I keep the line “size:1rem” ? I mean if it’s useless, the following should work…
"typography": {
"fluid": true,
"fontSizes": [
{
"fluid": {
"min": "1rem",
"max": "2rem"
},
"slug": "test1",
"name": "test1"
}
]
}
I am not sure to fully understand how it works.
-
This reply was modified 2 months, 4 weeks ago by
charlie67p.
@charlie67p Yep, exactly – older browsers that don’t support CSS clamp() would fall back to the size value..
About omitting the size field: technically your code without size might work, but WordPress’s theme.json expects that field to be there. Omitting it could cause validation warnings or unexpected behavior in the block editor
Just keep the size field and set it to your max value. this ensures fallback support and “keeps WordPress happy”.
{
"size": "2rem",
"fluid": {
"min": "1rem",
"max": "2rem"
},
"slug": "test1",
"name": "test1"
}
ah, now it sounds clear to me ! Thanks @lucianwpwhite