Skip to content

fix(input): support floating labels with slotted content - #31309

Draft
brandyscarney wants to merge 15 commits into
major-9.0from
FW-6471-input
Draft

fix(input): support floating labels with slotted content#31309
brandyscarney wants to merge 15 commits into
major-9.0from
FW-6471-input

Conversation

@brandyscarney

@brandyscarney brandyscarney commented Jul 30, 2026

Copy link
Copy Markdown
Member

Issue number: resolves #29449 resolves #28665


What is the current behavior?

Inputs with a floating label and a start or end slot always displayed the label in the floated state, regardless of whether the input contained a value:

without value with value
without value with value

What is the new behavior?

  • The floating label now behaves consistently regardless of whether start or end slots are present:
    • It overlays the input when the field is empty.
    • It floats when the input is focused or contains a value.
  • The height of inputs with start or end slots has been reduced to match the md specification.
  • Start slot content is now always positioned to the left of both the label and the input.
  • The clear button is now vertically centered within the entire input container, rather than only the input element.
  • The md clear button icon has been updated from closeSharp to closeCircleSharp.
  • Additional screenshot tests have been added to verify these behavior and layout changes.
  • A follow-up ticket has been created to address the remaining UI differences between our leading/trailing content implementation and the md specification.

Does this introduce a breaking change?

  • Yes
  • No

Due to the structural changes required to support the updated layout, and because Input is a scoped component, this change has the potential to introduce breaking changes for developers who rely on the component's internal DOM structure or apply custom styling to internal elements. While the public API has not changed, selectors or style overrides targeting the previous markup may need to be updated.

Additionally, the default clear button icon for md has changed from closeSharp to closeCircleSharp. Developers who prefer the previous appearance can restore it by setting clearInputIcon to closeSharp.

Other information

Preview

@vercel

vercel Bot commented Jul 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview Jul 31, 2026 5:18pm

Request Review

@github-actions github-actions Bot added the package: core @ionic/core package label Jul 30, 2026

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.

I renamed these screenshots from input-slots to input-slot to match the folder name.


configs().forEach(({ title, screenshot, config }) => {
test.describe(title('input: start and end slots (visual checks)'), () => {
test.describe(title('input: slot'), () => {

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 was updated to match the folder name, following how we title other tests.

import type { SlotMutationController } from '@utils/slot-mutation-controller';
import { createColorClasses, hostContext } from '@utils/theme';
import { closeCircle, closeSharp } from 'ionicons/icons';
import { closeCircle, closeCircleSharp } from 'ionicons/icons';

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.

I updated the icon for Material Design per the spec:

Image

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 the correct height and label position for Material Design filled inputs. See: https://m2.material.io/components/text-fields

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 1px shift was caused by the removal of this rule:

/**
* Ensures the input does not
* overlap the label.
*/
:host(.input-label-placement-stacked) input,
:host(.input-label-placement-floating) input {
@include margin(1px, 0, 0, 0);
}

However, this is actually more aligned than before:

Image

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 1px shift was caused by the removal of this rule:

/**
* Ensures the input does not
* overlap the label.
*/
:host(.input-label-placement-stacked) input,
:host(.input-label-placement-floating) input {
@include margin(1px, 0, 0, 0);
}

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 1px shift was caused by the removal of this rule:

/**
* Ensures the input does not
* overlap the label.
*/
:host(.input-label-placement-stacked) input,
:host(.input-label-placement-floating) input {
@include margin(1px, 0, 0, 0);
}

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 1px shift was caused by the removal of this rule:

/**
* Ensures the input does not
* overlap the label.
*/
:host(.input-label-placement-stacked) input,
:host(.input-label-placement-floating) input {
@include margin(1px, 0, 0, 0);
}

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.

I updated the icon for Material Design per the spec:

Image

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.

The clear input button was updated to be vertically centered based on the entire input container. This aligns with how md treats any trailing icon/button:

Image

@brandyscarney brandyscarney changed the title fix(input): float label when start and end slot exist fix(input): support floating labels with slotted content Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants