Skip to content

Commit 65dd983

Browse files
fix(web): composer control labels line up with their icons
On 1x displays and zoomed windows the font's ascent and descent round unevenly, so centering the label's line box left the text riding a pixel or two above the icons. Trim labels to cap height and alphabetic baseline so flex centering lines the caps up with the icons. Padding keeps descenders clear of the truncating model label. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 8f75697 commit 65dd983

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎apps/web/src/components/chat/ComposerControl.tsx‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@ export type ComposerControlSize = "sm" | "xs";
1313
* The composer toolbar's control look. `sm` is the expanded toolbar; `xs` is the dimmer resting
1414
* strip. `aria-pressed` marks a toggle that is on (plan mode). This is an app control, not a
1515
* restyled Button, so it owns its classes.
16+
*
17+
* Labels trim to cap height so they center on the icons. Centering the full line box leaves the
18+
* text riding high wherever the font's ascent and descent round unevenly (1x displays, zoom).
19+
* The padding keeps descenders clear of the truncating label's clip.
1620
*/
1721
function composerControlClassName(size: ComposerControlSize, className?: string) {
1822
return cn(
1923
"relative inline-flex shrink-0 cursor-pointer items-center justify-center whitespace-nowrap rounded-(--control-radius) border border-transparent text-base outline-none hover:bg-accent data-pressed:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background disabled:pointer-events-none disabled:opacity-64 data-disabled:pointer-events-none data-disabled:opacity-64 pointer-coarse:after:absolute pointer-coarse:after:size-full pointer-coarse:after:min-h-11 pointer-coarse:after:min-w-11 [&:active:not([aria-haspopup])]:scale-[0.97] [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:-mx-0.5 [&_svg[data-composer-control-icon]]:mx-0",
24+
"[&_:is([data-composer-control-label],[data-chat-provider-model-picker-label])]:[text-box:trim-both_cap_alphabetic] supports-[text-box:trim-both_cap_alphabetic]:[&_:is([data-composer-control-label],[data-chat-provider-model-picker-label])]:py-1.5",
2025
size === "xs"
2126
? "h-7 gap-1 px-1.75 font-normal text-muted-foreground/70 text-sm hover:text-foreground/80 sm:h-6 sm:text-xs [&_svg:not([class*='size-'])]:size-4 sm:[&_svg:not([class*='size-'])]:size-3.5 [&_svg[data-composer-control-chevron]]:ms-0 [&_svg[data-composer-control-chevron]]:-me-1"
2227
: "h-7 gap-1.5 px-2.5 font-medium text-secondary-label [&_svg:not([class*='text-'])]:text-muted-foreground hover:text-foreground sm:text-sm [&_svg:not([class*='size-'])]:size-4.5 sm:[&_svg:not([class*='size-'])]:size-4",

0 commit comments

Comments
 (0)