Skip to content

[Icon]: Icon size input is ignored inside tedi-button and tedi-link #435

@ly-tempel-bitweb

Description

@ly-tempel-bitweb

Problem

IconComponent's [size] input is documented as the way to control icon size:

<tedi-icon name="settings" [size]="18" />

But it has no visible effect when the icon is rendered inside <button tedi-button>
or any host carrying the .tedi-link class. Both component stylesheets define a
tedi-icon { font-size: ... } rule that out-specificities the icon's own size class:

Selector Specificity
.tedi-icon--size-18 (icon's own size class) (0, 1, 0)
.tedi-button tedi-icon (button override, font-size: inherit) (0, 1, 1)
.tedi-link tedi-icon (link override, font-size: 16px) (0, 1, 1)

So the icon's size class is always overridden by the host's rule. [size] becomes
a no-op in two of the most common contexts where icons appear.

Why this matters

We've already accumulated workarounds across the header subcomponents:

  • header-language.component.scss and header-role.component.scss rely on the
    icon class being smaller than the host (works only by coincidence — they don't
    set [size]).
  • header-profile.component.html uses inline style="font-size: 18px" on three
    separate icons because [size]="18" doesn't work.
  • header-logout.component.scss uses font-size: var(--icon-05) !important on
    mobile to defeat the link override.

Every new component that mixes icons with buttons/links runs into the same trap
and adds another workaround. The bug propagates.

Reproduction

<button tedi-button>
  <tedi-icon name="settings" [size]="18" />
</button>

Inspect the icon → font-size: var(--button-text-size-default) (inherited from
button) instead of var(--icon-03) from the size class. The tedi-icon--size-18
class is on the element but its rule is overridden.

Same with <a tedi-link><tedi-icon [size]="18" /></a> — icon renders at 16px.

Solution

[size] should set the icon size in any context, matching the documented
behavior and matching how the React equivalent of this design system works
(React's button/link don't override icon font-size at all).

Two coordinated changes:

  1. button.component.scss — drop tedi-icon { font-size: inherit } from
    .tedi-button. Keep color: inherit (color inheritance isn't the problem).
  2. link.component.scss — drop tedi-icon { font-size: 16px } from
    .tedi-link. Keep margins, line-height, color.

IconComponent's default size of 24 is left unchanged. Icons without an
explicit [size] will render at the default 24px in all contexts. Consumers
that previously relied on the button/link override to size their icons (i.e.
icons without [size] set) will need to add an explicit [size] to match
their previous rendered size.

Risks

  • tedi-link--small: icons inside small-variant links used to be pinned to
    16px by the override; without [size] set they'll now render at the icon's
    default 24px. Visual regression candidate — needs Storybook scan of
    small-link stories, and small-link usages may need explicit [size]="16".
  • Icons in buttons/links without [size]: previously inherited the host's
    font-size (e.g. var(--button-text-size-default) inside a button); will now
    render at the default 24px. Any consumers that relied on inheritance for
    sizing will need an explicit [size] to match their previous rendered size.

Examples and information

Workarounds to remove after the fix:

  • Inline style="font-size: …" on icons in header-profile.component.html.
  • font-size: … !important declarations in
    header-logout.component.scss (--mobile block).
  • Any future "make [size] work" patches.

Metadata

Metadata

Assignees

Labels

tedi-readyTEDI-Ready component issue

Type

No fields configured for Bug.

Projects

Status

Waiting for feedback

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions