Skip to content

UI: Update components to use Text component in place of ad hoc styles #76929

Closed

Description

@aduth

What problem does this address?

Related to: #64340 (discussion starting at #64340 (comment))

The Text component added in #75870 provides a convenient abstraction for adopting design system typographical pairings, and should be the preferred way to style typography in UI components.

What is your proposed solution?

Update existing usage of typography styles to adopt the Text component instead:

This list is compiled based on existing usage of typography tokens in component stylesheets. While there's a long tail of components which could be updated to use the Text component, as well as usage of @wordpress/component's Text component, it's not considered part of the scope of this issue.

Additional candidates to consider, though unclear if they should use Text component because their typographical styling is limited and it may incur additional DOM nesting complications:

Activity

  1. added
    [Type] TaskIssues or PRs that have been broken down into an individual action to take
    Design SystemIssues related to the system of combining components according to best practices.
    on Mar 31, 2026
  2. ciampo commented on Mar 31, 2026

    @ciampo
    Contributor

    Maybe Dialog.Title ?

  3. aduth commented on Mar 31, 2026

    @aduth
    MemberAuthor

    Maybe Dialog.Title ?

    Yeah, I think that's another likely candidate. There are some complications, but I'll add it to the list in my morning.

    Edit: Updated original comment.

  4. kushagra-goyal-14 commented on Apr 20, 2026

    @kushagra-goyal-14
    Contributor

    Hi @aduth
    I started to look into field utility styles, while Field.Description had (clean body-sm match). But for Field.Label it seems that the default label uses font-size-xs + font-weight-medium + uppercase + font-family-body, which is closest to heading-sm except for the font-family. The is-plain variant is closest to body-md except for the font-weight.

    Is the preference to map variant prop values to Text variants (accepting small discrepancies), or hold off on label until variants align more cleanly? Not blocking anything — just want to avoid inventing a pattern if one's being discussed.

  5. ciampo commented on Apr 21, 2026

    @ciampo
    Contributor

    I think ideally we should use only existing Text variants — let's check with @jameskoster if we can, and which variants should be used.

  6. jameskoster commented on Apr 23, 2026

    @jameskoster
    Contributor

    Adding a variant for labels doesn't seem very practical given it only really use one use case. Do we need to use Text for labels? Curious if it'd be simpler to just use the relevant tokens directly.

  7. ciampo commented on Apr 23, 2026

    @ciampo
    Contributor

    We can definitely use the relevant tokens direclty, although I feel like it defeats the purpose of having the Text component? I assumed Text would document and expose all of the "official" typography presets

  8. kushagra-goyal-14 commented on Apr 23, 2026

    @kushagra-goyal-14
    Contributor

    @ciampo @jameskoster Please correct me if I’m wrong, but I have a small suggestion: Could we try a hybrid approach using the @layer overrides? Since heading-sm and body-md match most of our needs, a targeted override in wp-ui-compositions (similar to the Notice.ActionLink pattern) - #77332 (comment) might fix the remaining mismatches while still leveraging the existing Text variants.

  9. ciampo commented on Apr 24, 2026

    @ciampo
    Contributor

    @kushagra-goyal-14 this is less about technicality (there are definitely ways to achieve that typography style) and more about the rules behind it.

    My point of view is that if we use a certain typography preset, that preset should be documented and available through Text. Otherwise, we're just creating custom presets, inconsistency, and fragmentation.

  10. jameskoster commented on Apr 27, 2026

    @jameskoster
    Contributor

    My feelings aren't strong. I see both sides of the argument. My questioning of the variant is due to what I perceive to be limited use (basically just Form.Field.Label), and concerns about misuse by consumers—we wouldn't want random label styling applied to non-label elements in the UI. If the name was abstracted maybe that would be better, but I'm not sure there's a good one...

    If y'all feel the variant is the right approach then I definitely won't object!

  11. ciampo commented on Apr 27, 2026

    @ciampo
    Contributor

    My feelings aren't strong. I see both sides of the argument. My questioning of the variant is due to what I perceive to be limited use (basically just Form.Field.Label), and concerns about misuse by consumers—we wouldn't want random label styling applied to non-label elements in the UI. If the name was abstracted maybe that would be better, but I'm not sure there's a good one...

    If y'all feel the variant is the right approach then I definitely won't object!

    Maybe we could start with a text variant that is accessible only from within the UI package? @aduth @mirka what do you think?

  12. mirka commented on Apr 27, 2026

    @mirka
    Member

    My questioning of the variant is due to what I perceive to be limited use (basically just Form.Field.Label), and concerns about misuse by consumers

    I also lean towards this. I think it would be fine to keep the Field.Label styles as is (don't replace with Text), until we have a use case for label-like text styling outside of the UI package where Field.Label can't be used for some reason.

  13. ciampo commented on Apr 27, 2026

    @ciampo
    Contributor

    Sure, if y'all feel like applying styles directly, let's go for that option.

  14. aduth commented on Aug 10, 2026

    @aduth
    MemberAuthor

    Updating this today, the only remaining item was the field utility styling. Per previous comments, that's not something being considered for now, so let's consider this complete.

    I've updated the original comment with links to pull requests that completed the replacements.

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

    Design SystemIssues related to the system of combining components according to best practices.[Package] Admin UI/packages/admin-ui[Package] UI/packages/ui[Type] TaskIssues or PRs that have been broken down into an individual action to take

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions