-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Fluid typography: add font size constraints #44957
Copy link
Copy link
Closed
Labels
[Feature] TypographyFont and typography-related issues and PRsFont and typography-related issues and PRs[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).Changes that impact accessibility and need corresponding review (e.g. markup changes).[Priority] HighUsed to indicate top priority items that need quick attentionUsed to indicate top priority items that need quick attention[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Metadata
Metadata
Assignees
Labels
[Feature] TypographyFont and typography-related issues and PRsFont and typography-related issues and PRs[Focus] Accessibility (a11y)Changes that impact accessibility and need corresponding review (e.g. markup changes).Changes that impact accessibility and need corresponding review (e.g. markup changes).[Priority] HighUsed to indicate top priority items that need quick attentionUsed to indicate top priority items that need quick attention[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended
Type
Fields
Give feedbackNo fields configured for issues without a type.
Parent issue:
What problem does this address?
Where fluid typography is enabled, minimum and maximum font sizes in presets can be calculated according to defined
minandmaxvalues, e.g.,{ "size": "2rem", "fluid": { "min": "2rem", "max": "2.5rem" }, "slug": "medium", "name": "Medium" },For the above preset, the font size, regardless of the viewport, will not be larger than 2.5rem and it will not be smaller than 2rem.
Where min and max values are not supplied, either in theme.json font size presets or as a custom font size in styles, the min and max values are calculated from the size itself, e.g.,
minFontSize * DEFAULT_MINIMUM_FONT_SIZE_FACTOR.Where the size is itself very large or very small, this could lead to readability issues in certain viewports.
2022-10-14.12.49.49.mp4
The use of
emfor example might also cause issues if the relative parent's font size is set very small.What is your proposed solution?
Add default minimum (and maximum?) font size limits so that text does not become smaller than
n1or bigger thann2.Proposed minimum font size is
14px/0.875rem/0.875em.The default limits can be configurable to allow themers more control and added in conjunction with:
❗ What do we do with font sizes < 14px?
Users may define font-sizes that are smaller than
14px. IThe user-defined font size could be the minimum in a clamped value. For example if a user defines9pxfor a block, then the minimum font size for that block will be9pxand a clamped value will be generated.OR
Where users define font-sizes that are smaller than 14px in the editor or theme.json, and there is no specified minimum the value is not clamped (no fluidity).
cc @jasmussen @jffng