Skip to content

feat(Button): add high contrast to plain/link hover+clicked - #7734

Merged
mcoker merged 9 commits into
patternfly:high-contrast-q3from
kmcfaul:button-high-contrast
Aug 20, 2025
Merged

mcoker merged 9 commits into
patternfly:high-contrast-q3from
kmcfaul:button-high-contrast

Conversation

@kmcfaul

@kmcfaul kmcfaul commented Aug 6, 2025 •

Copy link
Copy Markdown
Contributor

Closes #7591
Closes #7614
Closes #7742

@kmcfaul kmcfaul linked an issue Aug 6, 2025 that may be closed by this pull request
@patternfly-build

patternfly-build commented Aug 6, 2025 •

Copy link
Copy Markdown
Collaborator

@kmcfaul

kmcfaul commented Aug 7, 2025

Copy link
Copy Markdown
Contributor Author

Should the other variants of button have a thicker border for the clicked state? I'm noticing that the border becomes thicker for the clicked state in the figma, but this pattern doesn't apply to the other variants which already had a border (hover = clicked border width).

@kmcfaul

kmcfaul commented Aug 7, 2025 •

Copy link
Copy Markdown
Contributor Author

The figma file for button is also a little confusing on the CTA button. I've applied the styling to the link CTA but its design is more squared than the rounded like the Figma shows.

@kmcfaul
kmcfaul force-pushed the button-high-contrast branch from e91e43f to 2f22545 Compare August 14, 2025 21:47

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice! LGTM, though it looks like this has exposed a performance issue with the border and background animations. Here is an issue to follow up on it - #7743

@mcoker

mcoker commented Aug 15, 2025

Copy link
Copy Markdown
Contributor

@lboehling looks like the update to the plain/no-padding button may have caused an issue with the label close button. That button has custom padding already, but it pushes the border outside of the label. If I get rid of the custom padding and just use the new fake padding we added to plain/no-padding, it goes from this:

Screenshot 2025-08-15 at 9 19 46 AM

to this

Screenshot 2025-08-15 at 9 22 38 AM

WDYT?

Also I looked up everywhere we use the plain/no-padding button in our components and those spots look ok, you can verify in this PR. For reference, they're:

  • form label help button
  • table column header help button
  • inline clipboard copy buton

@mcoker

mcoker commented Aug 15, 2025

Copy link
Copy Markdown
Contributor

@kmcfaul in chatting with @lboehling, we decided to remove the border from the button's inline links. The main issue there is that those present like normal links - so if we draw a border around them, it follows that we would draw a border around regular links, too. However, regular links (and the button's "span" inline link) can wrap to multiple lines, then the border breaks. There is already enough contrast and distinction with links that they don't need the border, so we can get rid of the border we added to inline links.

@lboehling

Copy link
Copy Markdown

@lboehling looks like the update to the plain/no-padding button may have caused an issue with the label close button. That button has custom padding already, but it pushes the border outside of the label. If I get rid of the custom padding and just use the new fake padding we added to plain/no-padding, it goes from this:

Screenshot 2025-08-15 at 9 19 46 AM to this Screenshot 2025-08-15 at 9 22 38 AM WDYT?

Also I looked up everywhere we use the plain/no-padding button in our components and those spots look ok, you can verify in this PR. For reference, they're:

  • form label help button
  • table column header help button
  • inline clipboard copy buton

+1 to getting rid of the custom padding. i think that your update looks good. When i went to toggle off the custom padding, it did start to look like the "x" close icon was butting up too closely with the label text. Is there anyway to keep a little gap between the text and the label, and use the updated no-padding padding? You can see the difference below (First 2 with inline start custom padding turned off, Second 2 with it left on). note - im not suggesting we keep the inline custom padding for the close action since it off centers the border, but if there was a way to add in that spacing between the close action and text again that would be 💯.

Screenshot 2025-08-15 at 10 36 46 AM Screenshot 2025-08-15 at 10 36 52 AM Screenshot 2025-08-15 at 10 35 48 AM Screenshot 2025-08-15 at 10 35 56 AM

The other examples look good! Thanks @mcoker & @kmcfaul

@mcoker

mcoker commented Aug 15, 2025

Copy link
Copy Markdown
Contributor

Chatted about the label close spacing and decided to 1) remove the custom padding as design suggested, and 2) add back the space that was lost from the padding being removed on the left and right sides of the icon. Just glancing at it, I think that update would look like:

  • Set all of these padding/margin variables to "0", and leave a comment to remove them in a breaking change. Usually that looks like // TODO - remove in breaking change
    --#{$label}__actions--c-button--MarginBlockStart: calc(var(--#{$label}__actions--c-button--PaddingBlockStart) * -1);
    --#{$label}__actions--c-button--MarginBlockEnd: calc(var(--#{$label}__actions--c-button--PaddingBlockEnd) * -1);
    --#{$label}__actions--c-button--PaddingBlockStart: var(--pf-t--global--spacer--xs);
    --#{$label}__actions--c-button--PaddingInlineEnd: var(--pf-t--global--spacer--xs);
    --#{$label}__actions--c-button--PaddingBlockEnd: var(--pf-t--global--spacer--xs);
    --#{$label}__actions--c-button--PaddingInlineStart: var(--pf-t--global--spacer--xs);
  • Add a gap between the label text and actions via a gap on .pf-v6-c-label, and use --pf-t--global--spacer--gap--text-to-element--compact as the spacer.
  • I think you can add back the space to the right of the close icon by setting this negative right margin to "0" and leave a TODO comment to remove it, too
    --#{$label}__actions--MarginInlineEnd: calc(var(--#{$label}__actions--c-button--PaddingInlineEnd) * -1);

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a couple of small changes. And chatted with design about the border overflowing compact labels and we landed on using a custom inset for plain/no-padding actions in compact labels by removing the top and bottom inset.

You could do it a bunch of ways, but I would probably(?) put it in this spot, you could do something like this. Update from:

  .#{$button} {
    --#{$button}--FontSize: var(--#{$label}__actions--c-button--FontSize);

to

  .#{$button} {
    @at-root .#{$label}.pf-m-compact & {
      --#{$button}--m-plain--m-no-padding--after--Inset: 0 calc(#{pf-size-prem(2px) * -1)
    }

    --#{$button}--FontSize: var(--#{$label}__actions--c-button--FontSize);

That should compile to

.pf-v6-c-label.pf-m-compact .pf-v6-c-label__actions .pf-v6-c-button {
  --pf-v6-c-button--m-plain--m-no-padding--after--Inset: 0 -2px; 
}

Comment thread src/patternfly/components/Button/button.scss Outdated
Comment thread src/patternfly/components/Button/button.scss Outdated

@srambach srambach left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just curious if we need the link and plain clicked and hover border color variables? Are they here for completeness?

@kmcfaul kmcfaul linked an issue Aug 19, 2025 that may be closed by this pull request
@mcoker

mcoker commented Aug 20, 2025

Copy link
Copy Markdown
Contributor

@lboehling can you take a look at this PR? Specifically it changes:

  • Adds border to link and plain buttons in HC
    • Excludes inline link
  • Adds the fake padding to the "no padding" button variation
  • Removes the custom padding/margin we had on the close icons in labels in lieu of the new fake padding
  • Adds a small gap between the label text + actions
  • Adjusts the fake padding on compact labels to remove the top/bottom padding so the button border fits within the label

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks awesome to me! Just one last request on the var names for the insets, we typically use the word "offset" when we move a border/outline from some relative position, and we can replace after with border which is easier to read and lets us update the structure down the road (border could go on the ::before element) and the var name shouldn't need to be updated.

Comment thread src/patternfly/components/Button/button.scss Outdated

@mcoker mcoker left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🚀

@lboehling lboehling left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

lgtm! the only thing i'm noticing is that the animation seems really slow when the plain button border fades in, but maybe we can consider that in the follow up @mcoker opened!

@mcoker
mcoker merged commit 51f7862 into patternfly:high-contrast-q3 Aug 20, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Button - increase no-padding variations clickable area High contrast borders - Button

5 participants