button: Keep the focus line off text and legible on fills - #3300
Merged
Merged
Conversation
Text and Link buttons have no padding, so a line on their edge sat on the label; draw it 2px outside instead. On filled variants a `ring` line on the edge barely showed against dark fills; draw it 2px inside in the button's foreground at 60%, which the theme keeps legible against the fill. Ghost keeps the edge line, bordered variants keep the tinted border. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #3299 (#3298). When
Theme::focus_ringis off, #3299 draws a 1pxringline on a borderless button's edge. That has two visual problems:ring-coloured line on the edge barely shows against dark fills. In the default light theme it is neutral-400 on neutral-900.Change
Each borderless button now picks where its focus line goes, through a crate-private
FocusLinepassed tostyled::focus_style:ringring.outline()ringringtoken is tuned for the page background, not for a primary fill.ringline? It is still low-contrast on fills.focus_ring = falseexists to avoid: containers clip it.focus_ring = true, bordered variants, and other callers offocus_ring_stylebehave as before.Tests
crates/kit/tests/rendering.rs. These run on the main thread (harness = false, Metal), with Ghost / Text / Link / Primary buttons andfocus_ring = false.focus_lines_stay_off_content_and_contrast_with_fillsruns in light and dark. Focus moves with Tab through Root. For each button:ring-coloured pixels on the top edge.ring-coloured pixels 2px above the edge.clicking_a_button_draws_no_focus_line: clicking a hovered button leaves focus empty and the capture identical to the hovered one.These tests fail on
origin/mainbefore #3299 atghost, and on #3299 alone attext(288 device pixels over the label).