Skip to content

Add relative units for font size option #23323

Closed

Description

@iamtakashi

The custom font size option is really useful, but the lack of relative units has been a problem to make patterns work well in both large and small screens.

It'd be great if we could have some the relative units, just like the cover block height control.

Screenshot 2020-06-19 at 18 39 24

With the vw unit, this sort of type treatment would be possible, I think.

Screenshot 2020-06-19 at 18 41 34

I've seen this topic has come up before, and I'll apologise if there is a better thread to discuss this. If there is please point me at there.

Activity

  1. added
    [Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.
    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json
    on Jun 19, 2020
  2. aristath commented on Aug 11, 2020

    @aristath
    Member

    Expanding on this one, it would be useful to just have a freeform option.
    Values don't necessarily need to be 10px, 2em, 3vw etc... Some cases require more elaborate values.
    Maybe I want to use calc(14px + 0.5vw) and have responsive typography. Or maybe I just want to use clamp(). Or even just use a css-variable and type var(--base-font-size).

    Forcing users to pick a numeric value and a unit will cover a lot of cases, but not all. It will still limit things and prevent valid use-cases that make sense.

  3. jorgefilipecosta commented on Oct 1, 2020

    @jorgefilipecosta
    Member

    I agree with what is being said here. Ideally, the font size picker component would be expanded to support string values.
    When it can parse things like "1em" it would render relevant pickers with the correct units. If it can not parse because it is a complex value like calc(14px + 0.5vw) it would show a simple input field with the string.

    The same would happen for all controls where we accept value/units or more complex CSS.

  4. moved this to Not Started in Design Tools Projecton Nov 2, 2021
  5. mtias commented on May 23, 2022

    @mtias
    Member

    This is supported now.

  6. Repository owner moved this from ⏱ Not Started to ✅ Done in Design Tools Projecton May 23, 2022
  7. iamtakashi commented on May 26, 2022

    @iamtakashi
    Author

    This is supported now.

    @mtias I can see px, em, and rem units available now, but vw and vh aren't yet available. Am I missing something?

    Screenshot 2022-05-26 at 18 03 47

    It depends on #24480, but if that will take more time, I think it's worth considering adding vw and vh as well. What do you think?

  8. reopened this on May 26, 2022
  9. mtias commented on May 26, 2022

    @mtias
    Member

    Ah, sorry, I misread :)

  10. iamtakashi commented on May 26, 2022

    @iamtakashi
    Author

    That's ok. Thanks for reopening!

  11. flabernardez commented on Mar 20, 2024

    @flabernardez

    This option will be added soon?

    I really need vw vh and calc or var options to fonts size 😄

  12. carolinan commented on Apr 10, 2024

    @carolinan
    Contributor

    @iamtakashi @flabernardez @beafialho @WordPress/block-themers @WordPress/outreach
    Would having vw and vh units in the custom font size picker* be useful even if it is not combined with clamp()?

    (*The control in the Typography panel where you select a completely custom font size instead of using a preset)

  13. iamtakashi commented on Apr 11, 2024

    @iamtakashi
    Author

    Would having vw and vh units in the custom font size picker* be useful even if it is not combined with clamp()?

    It can be useful. Here's a recent example of using the vw unit for this theme: https://surrealist.mystagingwebsite.com/. I see this kind of design treatment, a single word spanning the screen, more often in the wild lately. When the editor recognises the unit, the user can adjust the size easily depending on their content.

    However, while working on the theme, I realised that the editor already recognises the vw unit if it's first added in the code editor. I was pleasantly surprised!

    <!-- wp:site-title {"textAlign":"center","isLink":false,"style":{"typography":{"fontSize":"20vw"}}} /-->

    CleanShot 2024-04-11 at 10 36 43@2x

  14. youknowriad commented on Aug 25, 2026

    @youknowriad
    Contributor

    Closing as this seems solved already.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.json[Block] ParagraphAffects the Paragraph Block[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions