Skip to content

fix(item): stop ios lines from disappearing - #31800

Open
thetaPC wants to merge 32 commits into
FW-7047-device-scale-factorfrom
FW-7047
Open

thetaPC wants to merge 32 commits into
FW-7047-device-scale-factorfrom
FW-7047

Conversation

@thetaPC

@thetaPC thetaPC commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Issue number: resolves #30772


What is the current behavior?

On iOS, WebKit skips borders thinner than one CSS pixel at some positions on the page, so the 0.55px line between items disappears while scrolling.

What is the new behavior?

  • Adds a hairline mixin that draws a line as a filled box along a top or bottom edge instead of a border. Without a thickness, it is one screen pixel thick at 1x, 2x and 3x.
  • Adds a mediaQuery recipe key: values under mediaQuery.min.resolution set the same variable inside a media query. A value a custom theme sets replaces the base theme's media query values for that key, so it applies on every screen.
  • Test pages merge a custom theme with the same rule as apps, so a page that sets a custom value gets it on every screen too.
  • ion-divider draws its line with the mixin, and the ios theme sets it to one screen pixel at each density.
  • ion-item draws its full and inset lines with the mixin in every theme, as the line and inner-line parts. Lines sit on the item's bottom edge instead of below it. The ios theme sets them to one screen pixel at each density.
  • The ios accordion draws the line above a header that follows an expanded accordion. It uses the shade of the header item's color when it has one.
  • Adds an item hairlines test page that reproduces the missing lines.

Does this introduce a breaking change?

  • Yes
  • No

In every theme:

  • --border-width and --inner-border-width no longer draw the lines between items. Use lines="none" to hide a line, or style it with ion-item::part(line) (full width) or ion-item::part(inner-line) (inset). --border-color still sets the line color.
  • Lines no longer take up space inside the item. An item with a line is 1px shorter in the md and ionic themes, and half a pixel shorter on most iOS devices in the ios theme. If the item's min-height sets its height, the height stays the same and the content moves down by half that amount.

In the ios theme:

  • --border-color on an accordion's header item no longer changes the line above it.

Other information

Known gaps

  • If an app merges its own values into the ios tokens instead of using Ionic's theme config, the ios 2x and 3x thickness values still apply, so a custom thickness only shows on 1x screens.
  • Other components with 0.55px borders (header, footer, tab bar, alert, datetime, form controls, split pane) move to the mixin in their own migrations.

How to test

Lines draw one screen pixel thick, with none missing, in Safari on the iOS 17.5 and 26.2 simulators at every position the hairlines page reaches.

Lines look lighter than before in desktop browsers and in Chrome's device toolbar. Those drew the old 0.55px border two screen pixels thick, and the new line is one screen pixel, which is what iPhones always drew.

Check Before After What to look for
Missing lines Copy the hairlines page to core/src/components/item/test/hairlines/index.html on next and run npm start Hairlines Open in Safari on an iPhone or the iOS simulator. Tap Shift a few times. Before, some lines disappear. After, every line stays visible.
Item lines Lines Lines Full, inset and no lines match each label. Colored items draw a darker shade of their color.
Content over a line Basic Basic The PIN item's red line stops at "Must enter 7 digits".
Accordion Basic Basic A line separates Mini Golf from Dining, dark yellow in the colored groups. Expand Exercise: no line above it.

Recipe values under mediaQuery.min.resolution set the same variable inside a media query. A value a custom theme sets replaces the base theme's media query values for that key, so it applies on every screen.
The line is a filled box instead of a border, since WebKit skips borders thinner than one CSS pixel at some positions. The ios theme sets the thickness per screen density.
@thetaPC
thetaPC added this pull request to stack #31795 November 20, 2026 19:15
@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
ionic-framework Ready Ready Preview Nov 25, 2026 7:15pm UTC

Request Review

# Conflicts:
#	core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Chrome-linux.png
#	core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Firefox-linux.png
#	core/src/components/chip/test/basic/chip.e2e.ts-snapshots/chip-descender-ios-ltr-Mobile-Safari-linux.png
@thetaPC
thetaPC removed this pull request from stack #31795 November 24, 2026 19:13
@thetaPC
thetaPC changed the base branch from FW-6848 to FW-7047-device-scale-factor November 24, 2026 19:18

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The open item's shadow from #31731 was already being drawn but was too faint to fail the old snapshot. This PR's half-pixel label move pushed the image over the threshold, so the regenerated snapshot now shows it too.

@thetaPC
thetaPC marked this pull request as ready for review November 25, 2026 01:16
@thetaPC
thetaPC requested a review from a team as a code owner November 25, 2026 01:16

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

Looks good to me, great work! Left a few comments, mostly docs wording. The accordion lines one is the one I'd most like to see changed.

Comment thread core/src/css/core.scss Outdated
@@ -332,8 +332,8 @@ ion-accordion-group.accordion-group-expand-inset > ion-accordion:last-of-type {
border-bottom-right-radius: 8px;
}

ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"] {
--border-width: 0px;
ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"]::part(line) {

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.

Suggested change
ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"]::part(line) {
ion-accordion-group > ion-accordion:last-of-type ion-item[slot="header"]::part(line),
ion-accordion.accordion-expanding > ion-item[slot="header"]::part(line),
ion-accordion.accordion-expanded > ion-item[slot="header"]::part(line) {

I think we can drop headerLineHidden and updateHeaderLine and hide the line here, since the host already gets accordion-expanding and accordion-expanded. Setting lines on the item shows up in the app, so an open accordion's header reads item.lines === 'none' even though nothing set it, and if the app sets lines="inset" while it's open, collapsing puts it back to 'full'. With this selector and the lines bullet dropped from BREAKING.md, the accordion screenshots come out identical and lines is never touched.

The line color has a similar problem, since updateNextLineColor only runs in componentDidLoad. If the header item's color changes later, the line above the next header keeps the old shade, where before it was the item's own border and followed color.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 9d8d03e with your selector, and the lines bullet is gone from BREAKING.md. For the color, 9f1826f watches the header item's color attribute with a MutationObserver, so the line follows it when it changes or is removed, and adds a test for both. I kept the line in the accordion rather than drawing it from core.scss, so the observer is what keeps it in sync.


color: var(--border-color);

// Painted like a border: above the native element's background,

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.

Was it intentional for the lines to sit under the state overlay? With both at z-index: -1, the ::after overlay comes later and paints over them. On ios the line goes from #c8c7cc to about rgb(175, 174, 179) while pressed and rgb(170, 169, 173) when focused, and in the ionic theme on an md touch device the pressed line takes on the fill color, though they're close enough that it's hard to notice. The ionic focus ring covers the line row now too.

Native iOS hides the separator on highlight anyway, so I don't think this is a big deal, but the "Painted like a border" comment isn't accurate anymore. If you do want the lines on top, z-index: -2 on the ::after works, as long as the ionic focus ring's ::after stays at -1 so it keeps its bottom row.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not intentional. 415ba6c moves the state overlay to z-index: -2 so the lines paint above it again, keeps the ionic focus ring at -1 so it keeps its bottom edge, and updates the comment. The pressed and focused snapshots are regenerating.

Comment thread BREAKING.md Outdated

<h4 id="version-10x-item">Item</h4>

The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them. `--border-color` still sets their color.

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.

Suggested change
The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them. `--border-color` still sets their color.
The lines between items are drawn with an element instead of a border, so `--border-width` and `--inner-border-width` no longer show, hide or resize them, and `--border-style` no longer changes their style. `--border-color` still sets their color.
`--border-width` and `--inner-border-width` still draw a border on the item, so an app that set them to thicken a line now gets that border on top of the line. Remove those overrides and style the `line` or `inner-line` part instead.

Since --border-width and --inner-border-width still set border-width on the item, an app with --border-width: 0 0 2px 0 now gets a 2px border with the new line on top of it. And --border-style: dashed comes out solid because the lines are gradient fills now. The @prop docs for those vars still describe the lines too, so I think they need the same update.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in f2a42b7. The @prop docs for --border-width, --inner-border-width and --border-style now say they don't apply to the lines too.

Comment thread docs/themes/recipes.md Outdated

- **The key isn't part of the variable name**, unlike a state. The stylesheet reads one variable, `--ion-divider-thickness`, on every screen.
- **List values from smallest to largest.** When several queries match, the last one wins.
- **An app's value applies on every screen.** A custom theme that sets `IonDivider.thickness` drops the theme's `mediaQuery` values for `thickness`. To change the value per screen, the custom theme sets its own `mediaQuery`.

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.

Suggested change
- **An app's value applies on every screen.** A custom theme that sets `IonDivider.thickness` drops the theme's `mediaQuery` values for `thickness`. To change the value per screen, the custom theme sets its own `mediaQuery`.
- **A value under the custom theme's `ios` or `md` key applies on every screen.** Setting `IonDivider.thickness` there drops the theme's `mediaQuery` values for `thickness`. A value merged straight into the theme's tokens, like `deepMerge(iosTheme, { components: { IonDivider: { thickness: '2px' } } })`, keeps them, so it only applies on 1x screens. To change the value on every screen or per screen, set `mediaQuery` alongside it.

I think this only holds under the custom theme's ios or md key. The app merges its custom theme over the base tokens, which have no IonDivider, so an app that does deepMerge(iosTheme, ...) with a 2px thickness still gets 0.5px and 0.3334px on 2x and 3x screens and only sees 2px at 1x. The JSDoc on IonMediaQuery and IonDividerRecipe.mediaQuery says the same thing, so I'd scope those too.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in 25d5d56. I called it the "per-mode" ios or md key so it doesn't read as the md theme, and scoped the IonMediaQuery and IonDividerRecipe.mediaQuery JSDoc the same way.

Comment thread core/src/themes/themes.interfaces.ts Outdated
* for that key, so it applies on every screen.
*/
export type IonMediaQuery<T> = {
/** Applies when the screen is at least the given value. When several match, the largest wins. */

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.

Suggested change
/** Applies when the screen is at least the given value. When several match, the largest wins. */
/**
* Applies when the screen is at least the given value. When several match,
* the last key wins, so list values from smallest to largest.
*/

There's no sort in getMediaQueries, so the last key wins, which matches what the theme.ts JSDoc and the recipes doc say. A theme that lists 3dppx before 2dppx gets 0.5px on a 3x screen. Sorting min ascending would also work if you'd rather keep "the largest wins", but then it'd need a spec. Up to you!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in afb4309. I kept "the last key wins" rather than adding a sort.

Comment on lines +69 to +72
/**
* `shift` and `scroll` set the starting shift and scroll offset, in pixels,
* so an automated check can screenshot the lines at exact positions.
*/

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.

Suggested change
/**
* `shift` and `scroll` set the starting shift and scroll offset, in pixels,
* so an automated check can screenshot the lines at exact positions.
*/
/**
* `shift` and `scroll` set the starting shift and scroll offset, in pixels,
* so a link can open the page with the lines at exact positions.
*/

Nothing loads this page or passes shift or scroll, so I think this points at a check that doesn't exist? I'm not asking for an e2e, since this doesn't reproduce in Playwright anyway, just the reword.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done in fde55ee.

thetaPC and others added 8 commits November 25, 2026 10:54
Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
…lements

Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
…de key

Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>
Co-authored-by: Shane <561207+ShaneK@users.noreply.github.com>

This branch was successfully deployed

1 active deployment
Preview — 9eba50d0 Deployed Nov 25, 2026 by vercel[bot]
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.

3 participants