Skip to content

feat(content): add recipe and tokens#31095

Open
thetaPC wants to merge 18 commits intoionic-modularfrom
FW-6896
Open

feat(content): add recipe and tokens#31095
thetaPC wants to merge 18 commits intoionic-modularfrom
FW-6896

Conversation

@thetaPC
Copy link
Copy Markdown
Contributor

@thetaPC thetaPC commented Apr 24, 2026

Issue number: resolves internal


What is the current behavior?

ion-content does not fragment styles based on themes. All 3 themes share one style. However, it's not configured to the Modular Ionic.

What is the new behavior?

  • Defined TypeScript Interface: Renamed content-interface.ts to content.interfaces.ts and added IonContentRecipe type.
  • Defined Theme Defaults: Added per-theme token defaults in ios, md, and ionic theme files.
  • Internal Variable Prefix: Renamed --offset-top / --offset-bottom to --internal-offset-top / --internal-offset-bottom to clearly separate them from the public CSS API.
  • CSS Logical Properties for RTL: Replaced physical-property RTL selectors on .transition-effect and .transition-shadow with the position-horizontal mixin.
  • Removed dead property: Dropped -webkit-overflow-scrolling: touch from styles as this property has been a no-op since iOS 13.
  • Updated Tests: Added unit specs for transitionShadow (present in ios mode, absent in md mode) and the getScrollElement() / getBackgroundElement() element ref methods.
  • New utility: Replaced inline new Promise((resolve) => componentOnReady(...)) patterns with a shared waitForComponent helper, reducing boilerplate and improving type safety.

Does this introduce a breaking change?

  • Yes
  • No

This PR introduces breaking changes to how ion-content is styled.

Migration Path:

  1. CSS Variable Replacements: --background, --color, and --padding-* have been removed. Use the new token structure instead:
--background -> IonContent.background
--color -> IonContent.color
--padding-top -> IonContent.padding.top
--padding-end -> IonContent.padding.end
--padding-bottom -> IonContent.padding.bottom
--padding-start -> IonContent.padding.start

If per-component customization is needed, the CSS variables can be used directly.

--background -> --ion-content-background
--color -> --ion-content-color
--padding-top -> --ion-content-padding-top
--padding-end -> --ion-content-padding-end
--padding-bottom -> --ion-content-padding-bottom
--padding-start -> --ion-content-padding-start
  1. Theme classes: Remove any instances that target the theme classes: ion-content.md, ion-content.ios.

Other information

Previews:

The framework (Angular, React, Vue) test apps are not being styled correctly anymore because the new tokens are not being passed to them. This is expected until we can export the tokens as mentioned in the design doc. The functionality in those test apps are still working.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 24, 2026

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

Project Deployment Actions Updated (UTC)
ionic-framework Ready Ready Preview, Comment May 5, 2026 1:40pm

Request Review

flex-shrink: 2;
overscroll-behavior-y: contain;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
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.

-webkit-overflow-scrolling has become obsolete since iOS 13.

contain: size style;
}

:host(.ion-color) .inner-scroll {
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.

There seems to be a lot deleted, but they were just moved around in the file.

@Method()
async getBackgroundElement(): Promise<HTMLElement> {
if (!this.backgroundContentEl) {
await new Promise((resolve) => componentOnReady(this.el, resolve));
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.

Created a util for this since a lot of components are using the same code

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.

This change was because I synced the padding between themes to be consistent. ionic wasn't using padding-* on ion-content.

@@ -32,7 +44,7 @@
</ion-toolbar>
</ion-header>

<ion-content class="ion-padding-space-400" id="content" no-bounce>
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.

Removed the class because it wasn't set anywhere.

github.com:ionic-team/ionic-framework into FW-6896 #
Please enter a commit message to explain why this merge
is necessary, # especially if it merges an updated
upstream into a topic branch. # # Lines starting with '#'
will be ignored, and an empty message aborts # the
commit.
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 goal is to delete this file but that won't be until we can consolidate everything into one base. In the mean time, we should make updates so screenshots don't fail.

</ion-header>

<ion-content class="ion-padding ion-text-center" id="content" no-bounce>
<ion-content class="ion-text-center" id="content" no-bounce>
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.

Added the padding through the config since I already had to pass the background value there. Figured that I would keep it all in one place by adding the padding.

background: yellow;
}

#content {
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 values are being passed for this specific instance only. The other content components are using the values provided by scripts.js.

* @prop --padding-start: Left padding if direction is left-to-right, and right padding if direction is right-to-left of the content
* @prop --ion-content-font-family: Font family of the content
*
* @prop --keyboard-offset: Keyboard offset of the content
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.

I removed the comments for the internal variables.

transform: translateZ(0);
}

// Content: iOS Mode Transition
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 design doc did not account for animations based on mode. Should we be aiming to convert them to be based on themes? If so, then we can allow devs to customize the certain parts of the animations. In this instance, they could provide their preferred background color during the transition.
If we do decide to convert, then a ticket should be made and a TODO should be added here.

* The transition shadow effect is only animated by the iOS transition
* builder, so these elements are only rendered in iOS mode.
*/
const transitionShadow = mode === 'ios';
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.

As mentioned in the comment, this is only available in the ios mode as shown in the ios.transition.ts file.

...customTheme.palette,
},
};
theme = deepMerge(theme, customTheme);
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.

This change mimics exactly how we are loading themes in the theme.ts file.

Comment on lines +49 to +52
$padding-top: var(--padding-top, var(--ion-content-padding-top, 0px));
$padding-end: var(--padding-end, var(--ion-content-padding-end, 0px));
$padding-bottom: var(--padding-bottom, var(--ion-content-padding-bottom, 0px));
$padding-start: var(--padding-start, var(--ion-content-padding-start, 0px));
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.

In order for the padding classes (.ion-padding) to still be functional, we should be incorporating them as the first check.

:host(.ion-color) .inner-scroll {
background: color.current-color(base);
color: color.current-color(contrast);
}
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.

I didn't make this customizable because all themes are using the same styles. If the community requests it, then we can update the recipe to include it.

}

.transition-shadow {
@include mixins.position-horizontal(null, 0);
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.

We can now use this mixin instead of having to use left/right!

@thetaPC thetaPC marked this pull request as ready for review May 5, 2026 15:37
@thetaPC thetaPC requested a review from a team as a code owner May 5, 2026 15:37
@thetaPC thetaPC requested a review from gnbm May 5, 2026 15:37
@thetaPC thetaPC marked this pull request as draft May 5, 2026 16:58

:host(.ion-color) .inner-scroll {
background: color.current-color(base);
color: color.current-color(contrast);
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.

I was going to switch this to use foreground as stated in the ticket but that lead to unwanted changes like:

Image

The text color is not readable in some components. Others, it's too light and I question if it would pass accessibility.

Image

We should look into the foreground values again.

@thetaPC thetaPC marked this pull request as ready for review May 5, 2026 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

package: angular @ionic/angular package package: core @ionic/core package

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant