Skip to content

feat(content): add recipe and tokens#31095

Merged
thetaPC merged 36 commits into
ionic-modularfrom
FW-6896
May 26, 2026
Merged

feat(content): add recipe and tokens#31095
thetaPC merged 36 commits into
ionic-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.
  • Split default vs. semantic tokens: Nested background/color under default and added a semantic.default group.

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 and --color have been removed. Use the new token structure:
--background -> IonContent.default.background
--color -> IonContent.default.color

--padding-* is still supported. .ion-padding, .ion-padding-* classes in css/padding.scss set --padding-* directly on the host. ion-content continues to honor those values (falling back to the new token when unset). Existing usage of the utility classes and direct --padding-* overrides will keep working.

New code is encouraged to use the token-based API instead:

--padding-top -> IonContent.padding.top
--padding-end -> IonContent.padding.end
--padding-bottom -> IonContent.padding.bottom
--padding-start -> IonContent.padding.start

Note: core/api.txt only lists the new --ion-content-padding-* variables. The --padding-* overrides remain functional but are no longer part of the documented public API.

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. Internal-only variables (no replacement): The following CSS variables were previously documented @props on ion-content and have been renamed to the --internal-* namespace, removing them from the public API:
--keyboard-offset -> --internal-keyboard-offset
--offset-top      -> --internal-offset-top
--offset-bottom   -> --internal-offset-bottom

These are managed by ion-content itself (keyboard avoidance and header/footer offsets) and were never intended for consumer override. There is no replacement - any code that was setting them directly should be removed.

  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 26, 2026 5:10pm

Request Review

@@ -143,7 +143,6 @@
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
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

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

Looking good! Minor changes requested.

Comment thread core/src/components/content/content.scss
Comment thread core/src/components/list-header/test/basic/index.html Outdated
Comment thread BREAKING.md
Comment thread core/src/utils/helpers.ts Outdated
Comment thread core/src/components/content/content.scss Outdated
Comment thread core/src/components/content/content.scss
Comment thread core/src/components/content/content.scss Outdated
Comment thread core/src/components/content/content.scss Outdated

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

The foreground color should only be used when it's a text-only component. So if setting color on the content changes its text but not its background. You can look at ion-text as an example of a text-only component that uses color. Since we are changing the background on this component, contrast is the correct text value.

transform: translateZ(0);
}

// Content: iOS Mode Transition
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.

Maybe we should add this on to FW-7295?

Copy link
Copy Markdown
Member

@brandyscarney brandyscarney left a comment

Choose a reason for hiding this comment

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

Left some non-blocking comments. 👍

Comment thread BREAKING.md Outdated
color?: string;
};

semantic: {
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.

Should any component that supports semantic color also support hue?

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.

Discussing this offline. If work is needed, then we will add it through another ticket.

@thetaPC thetaPC merged commit 777274a into ionic-modular May 26, 2026
49 checks passed
@thetaPC thetaPC deleted the FW-6896 branch May 26, 2026 17:21
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.

3 participants