ui: an icon button is the same height as the button beside it

The Details/Open pair on every archive card came out 36px beside 28px.

Mantine gives ActionIcon a size scale unrelated to Button's, and defaults
the two differently:

    size        xs    sm    md    lg    xl   default
    Button      30    36    42    50    60   sm (36)
    ActionIcon  18    22    28    34    44   md (28)

So the two never matched, at any size, and every toolbar mixing them was
ragged -- the archive card is just where it shows most.

Mantine already ships the aligned scale as `--ai-size-input-*`, for an
ActionIcon standing beside an Input; those five values are identical to
`--button-height-*`.  ui.css points one at the other, which fixes every
size at once including ones no call site uses yet, and IconButton now
defaults to `sm` like Button.

Both halves are needed and both are proven so: dropping just the `sm`
remap reddens the default and `sm` cases while xs/md/lg/xl stay green;
reverting just the default reddens the default case alone, at 42 vs 36 --
the mismatch inverted rather than fixed.

A further test pins the direction.  The pair could also be squared up by
cutting the labelled button down to 28px, which would be the wrong fix.

Gallery gains a row of Button/IconButton pairs at all five sizes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Roland 2026-08-02 11:16:33 -06:00
parent 687b41bf20
commit bfb2e71d02
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
4 changed files with 101 additions and 4 deletions

View file

@ -101,9 +101,16 @@ export interface IconButtonProps extends Omit<ActionIconProps, 'children'> {
component?: any;
}
/** A square, icon-only button. */
/**
* A square, icon-only button, exactly as tall as a labelled `Button` beside it.
*
* The height needs BOTH halves of the fix. ui.css aligns ActionIcon's size scale with
* Button's, and this default aligns the starting point: Mantine defaults ActionIcon to `md`
* where it defaults Button to `sm`, so leaving it alone would trade a 28-vs-36 mismatch for
* a 42-vs-36 one.
*/
export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>((
{role, icon, label, className, ...props}, ref
{role, icon, label, className, size = 'sm', ...props}, ref
) => {
const fromRole = role ? roleProps[role] : undefined;
return <ActionIcon
@ -116,7 +123,7 @@ export const IconButton = forwardRef<HTMLButtonElement, IconButtonProps>((
variant={props.variant ?? fromRole?.variant ?? 'default'}
className={[fromRole?.className, className].filter(Boolean).join(' ') || undefined}
{...props}
size={resolveSize(props.size)}
size={resolveSize(size)}
>
{renderIcon(icon)}
</ActionIcon>