Issue number: Internal --------- <!-- Please do not submit updates to dependencies unless it fixes an issue. --> <!-- Please try to limit your pull request to one type (bugfix, feature, etc). Submit multiple pull requests if needed. --> ## What is the current behavior? <!-- Please describe the current behavior that you are modifying. --> Toast does not support the dynamic type feature in iOS. _A brief history on Ionic's toast..._ The toast component is influenced based on Material Design's [Snackbar](https://m2.material.io/components/snackbars) component. iOS does not include a toast component in their Human Interface Guidelines. Ionic's implementation is a hybrid of a "close enough" design for iOS that somewhat resembles iOS notifications. Taking this into account, the new behavior specified below is very much a best guess of reasonable defaults to provide an appropriate user experience for a user that is displayed a toast while using the dynamic type feature in iOS. ## What is the new behavior? <!-- Please describe the behavior or changes that are being added by this PR. --> - The toast content (header and message) content will scale to a maximum of 310% of its base size of 14px. - Note: Header is not a valid aspect of MD Snackbar. This is an area where the iOS notification style has bled into public API. We scale both the header and message text to be consistent, but developers should be cautious with how much content they are rendering. MD recommends a maximum of 2 lines of text for mobile, this would include both the header and message text[^1]. - The toast button will scale based on the same sizing rules as the back button does for dynamic type. The action is important to scale for visibility, but the content of the toast is the primary content that should be scaled to the maximum size allocated. - On iOS, the toast container has a maximum height of 478px. This value is taken from scaling the notification UI in iOS to 310% and capturing the height of the largest allowed notification[^2]. Developers that display too much text will have the contents overflow (visibly hidden). This is intentional to prevent the toast from covering the entire application UI and to enforce developers limit their text. Developers can continue to override this value through the `--max-height` CSS variable. - The fixed height requirement for toast has been removed. On iOS, the toast container can expand up to the max height (defaults to `478px`). On MD, the container will expand and overflow the viewport. Once again, developers _should_ follow best practices of limiting their message to 1-2 lines of text. https://github.com/ionic-team/ionic-framework/assets/13732623/d19e93c9-55c3-4b35-85af-3be9d98e008d ## Does this introduce a breaking change? - [ ] Yes - [x] No <!-- If this introduces a breaking change, please describe the impact and migration path for existing applications below. --> ## Other information <!-- Any other information that is important to this PR such as screenshots of how the component looks before and after the change. --> I attempted to enforce the line requirements to have the header and message text overflow, but line-clamp is not consistently implemented across browsers and Safari does not render an ellipsis when the content overflows. For this reason, I do not believe clamping the text to a fixed number of lines is viable at this time. [^1]: Reference to Material Design 2 Snackbar spec: https://m2.material.io/components/snackbars#specs [^2]: Reference image for iOS notifications scaled to 310%: https://github.com/ionic-team/ionic-framework/assets/13732623/e2420340-8046-4a56-81c8-9e2ee1c1399b --------- Co-authored-by: ionitron <hi@ionicframework.com>
@ionic/core
Ionic is an open source App Development Framework that makes it easy to build top quality Native and Progressive Web Apps with web technologies.
The Ionic Core package contains the Web Components that make up the reusable UI building blocks of Ionic Framework. These components are designed to be used in traditional frontend view libraries/frameworks (such as Stencil, React, Angular, or Vue), or on their own through traditional JavaScript in the browser.
Features
- Tiny, highly optimized components built with Stencil
- Styling for both iOS and Material Design
- No build or compiling required
- Simply add the static files to any project
- Lazy-loaded components without configuration
- Asynchronous rendering
- Theming through CSS Variables
How to use
Vanilla HTML
Easiest way to start using Ionic Core is by adding a script tag to the CDN:
<script type="module" src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.esm.js"></script>
<script nomodule src="https://cdn.jsdelivr.net/npm/@ionic/core/dist/ionic/ionic.js"></script>
<link href="https://cdn.jsdelivr.net/npm/@ionic/core/css/ionic.bundle.css" rel="stylesheet">
Any Ionic component added to the webpage will automatically load. This includes writing the component tag directly in HTML, or using JavaScript such as document.createElement('ion-toggle').
Additionally, within this package is a dist/ionic.js file and accompanying dist/ionic/ directory. These are the same files which are used by the CDN, and they're available in this package so they can be apart of an app's local development.
Framework Bindings
The @ionic/core package can be used in simple HTML, or by vanilla JavaScript without any framework at all. Ionic also has packages that make it easier to integrate Ionic into a framework's traditional ecosystem and patterns. (However, at the lowest-level framework bindings are still just using Ionic Core and Web Components).
Custom Elements Build
In addition to the default, self lazy-loading components built by Stencil, this package also comes with each component exported as a stand-alone custom element within @ionic/core/components. Each component extends HTMLElement, and does not lazy-load itself. Instead, this package is useful for projects already using a bundler such as Webpack or Rollup. While all components are available to be imported, the custom elements build also ensures bundlers only import what's used, and tree-shakes any unused components.
Below is an example of importing ion-badge, and initializing Ionic so it is able to correctly load the "mode", such as Material Design or iOS. Additionally, the initialize({...}) function can receive the Ionic config.
import { defineCustomElement } from "@ionic/core/components/ion-badge.js";
import { initialize } from "@ionic/core/components";
// Initializes the Ionic config and `mode` behavior
initialize();
// Defines the `ion-badge` web component
defineCustomElement();
Notice how we import from @ionic/core/components as opposed to @ionic/core. This helps bundlers pull in only the code that is needed.
The defineCustomElement function will automatically define the component as well as any child components that may be required.
For example, if you wanted to use ion-modal, you would do the following:
import { defineCustomElement } from "@ionic/core/components/ion-modal.js";
import { initialize } from "@ionic/core/components";
// Initializes the Ionic config and `mode` behavior
initialize();
// Defines the `ion-modal` and child `ion-backdrop` web components.
defineCustomElement();
The defineCustomElement function will define ion-modal, but it will also define ion-backdrop, which is a component that ion-modal uses internally.
Using Overlay Controllers
When using an overlay controller, developers will need to define the overlay component before it can be used. Below is an example of using modalController:
import { defineCustomElement } from '@ionic/core/components/ion-modal.js';
import { initialize, modalController } from '@ionic/core/components';
initialize();
defineCustomElement();
const showModal = async () => {
const modal = await modalController.create({ ... });
...
}
How to contribute
Check out the CONTRIBUTE guide