Skip to content

feat(icon): add font icon support to ion-icon - #1499

Open
brandyscarney wants to merge 34 commits into
mainfrom
FW-7618
Open

feat(icon): add font icon support to ion-icon#1499
brandyscarney wants to merge 34 commits into
mainfrom
FW-7618

Conversation

@brandyscarney

@brandyscarney brandyscarney commented Jul 22, 2026

Copy link
Copy Markdown
Member

Description

Adds support for slotted content in the ion-icon component, enabling developers to use custom icons via any content type: font icons, SVGs, or other icon components.

Change Type

  • Fix
  • Feature
  • Refactor
  • Breaking Change
  • Documentation
  • Other (CI, chores, etc.)

Rationale / Problems Fixed

Provides flexibility for developers who want to use custom icon implementations alongside SVG icons. The slotted content support allows the ion-icon component to wrap and style various icon formats (font icons, custom SVGs, icon components) with a unified interface, while developers benefit from all of the ionic framework component styling applied to ion-icon.

Implementation Details

  • Added <slot></slot> support to the ion-icon component JSX to accept slotted content
  • Updated CSS to support flexbox layout for slotted content alignment
  • Changed contain: strict to contain: layout style to allow better integration with slotted content
  • Added ::slotted(*) styles to inherit font size from the host element for proper sizing
  • Added visual regression tests for slotted content

Example Usage

<!-- Font icons -->
<ion-icon>
  <i class="fa fa-home"></i>
</ion-icon>

<!-- Slotted SVGs -->
<ion-icon>
  <svg>...</svg>
</ion-icon>

<!-- Other icon components -->
<ion-icon>
  <custom-icon></custom-icon>
</ion-icon>

Dev Build

8.0.14-dev.11784821417.1c794397


.icon-inner,
.icon-inner {
display: flex;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We need flex here for the font icons, otherwise they are shifted to the right and down. Since developers can't override this, we could expose this as a part if it's an issue.

Comment thread jest.setup.js

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is required to test the ternary in icon.tsx with svg rendering.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This looks like a lot of changes but I just added describe blocks around the existing tests and added a new one. This is the diff without the describe blocks: https://www.diffchecker.com/o2DUQGp1/

@brandyscarney
brandyscarney marked this pull request as ready for review July 23, 2026 18:09
@ShaneK
ShaneK requested a review from Copilot July 24, 2026 13:35

This comment was marked as off-topic.

@ShaneK ShaneK 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.

Looking good! Just a thing I noticed, but I could be off base here

Comment thread src/components/icon/test/a11y/index.html Outdated
@brandyscarney
brandyscarney requested a review from ShaneK July 24, 2026 16:31

@ShaneK ShaneK 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.

LGTM!

@thetaPC thetaPC 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.

LGTM, just minor question

const page = await newSpecPage({
components: [Icon],
html: `<ion-icon name="chevron-forward" aria-label="custom label"></ion-icon>`,
describe('slotted content', () => {

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.

Should we also have a test for size? Since we check for color and custom styles.

Base automatically changed from chore/ionicons-align-build-tests to main July 28, 2026 18:18
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.

5 participants