Skip to content

Apply consistent font sizes and spacing in checkout (shipping and billing blocks) #59754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

straku
Copy link
Contributor

@straku straku commented Jul 17, 2025

Submission Review Guidelines:

Changes proposed in this Pull Request

Closes #59737

Continuation of work tracked in #59787 ("long" lived branch synced with trunk)
Intro post: pfHfG4-1iC-p2
Designs: fpl1YUEIW7suBFO09qymA2-fi-1212_50897

Covers shipping and billing blocks; they include a bunch of components used throughout checkout:

  • TextInput (powers all of our form fields)
  • Checkbox
  • Select (powers country selector)

Screenshots or screen recordings

Used the Twenty Twenty Four theme for the screenshots. Notice that in all cases the "After" screenshot has a lower height.

Address card

Before After
Screenshot 2025-07-23 at 13 25 08 Screenshot 2025-07-23 at 13 23 21

Shipping/billing section

Before After
Screenshot 2025-07-23 at 13 25 31 Screenshot 2025-07-23 at 13 23 44

All expanded

Before After
Screenshot 2025-07-23 at 13 25 48 Screenshot 2025-07-23 at 13 24 02

Mobile

Font size is increased on mobile to 16px to accommodate for mobile Safari auto-zooming on inputs with font size smaller than 16px.

Before After
Screenshot 2025-07-23 at 13 26 43 Screenshot 2025-07-23 at 13 27 11

How to test the changes in this Pull Request:

  1. Add some products to your cart
  2. Go to checkout
  3. Verify whether it matches the expectation described in this PR (you can cross-check with Figma too), try covering all possible states for these blocks:
    • test with address card (provide address and then refresh the page to see card instead of full form)
    • test with different shipping/billing address (to have two forms and cards)
    • test with additional address field (apartment, etc.)
  4. Verify that the animation for the label input (when you focus on the input it transitions above the editable area) works correctly (it's positioned absolutely, so changes to sizing require new positioning)
  5. If you can, test on the mobile Safari browser (real device or emulator), we're looking for verification that you don't observe browser zooming on inputs when you focus them

Note

If you want to quikcly spot which components were adjusted within this PR, you can go to global styles of the site and vastly increase the general size of the text in typography settings (Global Styles -> Typography -> Text -> Size -> XXL). Texts that will stay small after the change will be the one modified here, the rest is coming in follow-up PRs.

Testing that has already taken place:

The above.

Changelog entry

  • Automatically create a changelog entry from the details below.
  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Details

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Changelog Entry Comment

Comment

Targeting a different branch than trunk. The final PR will include changelog.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jul 17, 2025
@@ -85,7 +85,6 @@ export const CheckboxControl = forwardRef<
<svg
className="wc-block-components-checkbox__mark"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noticed it while doing style changes to the component. For inline SVGs in React this attribute is not needed.

Comment on lines -129 to -131
&:only-child {
margin-top: 1.5em;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went through all usages of the component; it is being displayed on its own only in a few places, and in all of them some additional styles are applied modifying the base margin.

It is also a safer default; the parent should be controlling the space around this component, not the component itself.

Base automatically changed from wooplug-4908-apply-consistent-font-sizes-and-spacing-in-checkout to straku/optimized-checkout-typography-and-spacing July 18, 2025 14:53
@straku straku force-pushed the straku/optimized-checkout-typography-and-spacing branch from ed937f2 to 109fba0 Compare July 18, 2025 14:56
@straku straku force-pushed the wooplug-5059-apply-consistent-font-sizes-and-spacing-in-checkout-shipping branch from b9b2d69 to 012b561 Compare July 23, 2025 09:30
top: 1px + $gap-smaller;
left: 1px + $gap-small;

color: $universal-body-low-emphasis;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aligned color with what we use for text input component

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a tiny refactoring of the component

@@ -79,20 +71,59 @@
}
}

input[type="number"] {
appearance: textfield;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from moving a bit lower in the file I've added appearance here. Commenting as it might be hard to spot in the diff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scoped these styles properly; they were messing up checkboxes globally. A different question is why they were loaded on checkout, but I don't have the answer yet.

@straku straku marked this pull request as ready for review July 23, 2025 11:51
@straku straku requested a review from a team as a code owner July 23, 2025 11:51
@straku straku requested review from ralucaStan and removed request for a team July 23, 2025 11:51
@woocommercebot woocommercebot requested a review from a team July 23, 2025 11:51
Copy link
Contributor

github-actions bot commented Jul 23, 2025

Testing Guidelines

Hi @ralucaStan ,

Apart from reviewing the code changes, please make sure to review the testing instructions (Guide) and verify that relevant tests (E2E, Unit, Integration, etc.) have been added or updated as needed.

Reminder: PR reviewers are required to document testing performed. This includes:

  • 🖼️ Screenshots or screen recordings.
  • 📝 List of functionality tested / steps followed.
  • 🌐 Site details (environment attributes such as hosting type, plugins, theme, store size, store age, and relevant settings).
  • 🔍 Any analysis performed, such as assessing potential impacts on environment attributes and other plugins, conducting performance profiling, or using LLM/AI-based analysis.

⚠️ Within the testing details you provide, please ensure that no sensitive information (such as API keys, passwords, user data, etc.) is included in this public issue.

Copy link
Contributor

github-actions bot commented Jul 23, 2025

Size Change: -61 B (0%)

Total Size: 5.91 MB

compressed-size-action

Copy link
Contributor

github-actions bot commented Jul 23, 2025

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

@ralucaStan

This comment was marked as resolved.

Copy link
Contributor

@ralucaStan ralucaStan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tested this following the testing steps; Also tested on mobile Safari.

I found some visual bugs so I am requesting some changes. Outside of what I commented, I didn't find anything else.

@@ -1,25 +1,28 @@
.wc-block-components-form .wc-block-components-text-input,
.wc-block-components-text-input {
position: relative;
margin-top: $gap;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure where this is coming from, but the Text inputs now have a content jump when I focus them.

Screen.Recording.2025-07-23.at.15.36.32.mov

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because I removed explicit height for both text-input and select components. Without it height is increased by 1px in the focused state because of the decision to use different border width there. There are more clever solutions for this, but I don't think this is the best PR to explore them.

I've brought back the height, this time with a pretty lengthy comment explaining why it's needed.

pointer-events: none;

.has-dark-controls & {
fill: $input-text-dark;
}
}

> span,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you remember why this was needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously the height of the checkbox itself was not aligned with the height of the label, so there was a need for vertical alignment. Now, both the checkbox and the label have a height of 20px, so we don't need to do anything to get perfect vertical alignment.

@straku straku requested a review from ralucaStan July 24, 2025 21:46
@straku straku force-pushed the straku/optimized-checkout-typography-and-spacing branch from a2d03c9 to 62d3f4b Compare July 25, 2025 09:41
@straku straku force-pushed the wooplug-5059-apply-consistent-font-sizes-and-spacing-in-checkout-shipping branch from 579b69e to 7ce46ee Compare July 25, 2025 09:42
Copy link
Contributor

@ralucaStan ralucaStan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can no longer replicate the bugs I mentioned.

Things work as expected.
I only wanted to mention this behaviour that is also on trunk: on input fields with value, when focusing, the content moves a bit horizontally.
If you'd have a quick fix for that it would be great to fix it as well in a followup PR.

I'm approving

@straku
Copy link
Contributor Author

straku commented Jul 25, 2025

on input fields with value, when focusing, the content moves a bit horizontally

I tried tracking this down, unsuccessfully yet. I will create a ticket in Linear within the project to take another look. Thanks for your attention to detail.

@straku straku merged commit 0343ce3 into straku/optimized-checkout-typography-and-spacing Jul 25, 2025
33 checks passed
@straku straku deleted the wooplug-5059-apply-consistent-font-sizes-and-spacing-in-checkout-shipping branch July 25, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: woocommerce Issues related to the WooCommerce Core plugin.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants