Skip to content

docs(select): add new section on rich content options#4512

Open
brandyscarney wants to merge 8 commits into
major-9.0from
FW-7289
Open

docs(select): add new section on rich content options#4512
brandyscarney wants to merge 8 commits into
major-9.0from
FW-7289

Conversation

@brandyscarney
Copy link
Copy Markdown
Member

@brandyscarney brandyscarney commented May 20, 2026

Adds the following:

  1. Select documentation for the new feature allowing HTML to be passed to select options.
  2. Adds a new property to Playground called ionicConfig which allows you to pass config options that get merged with mode in the Playground example.

Preview

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

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

Project Deployment Actions Updated (UTC)
ionic-docs Ready Ready Preview, Comment May 22, 2026 5:22pm

Request Review

* example: `{ innerHTMLTemplatesEnabled: true }`. Merges with the active
* preview `mode` when opening the editor.
*/
ionicConfig?: IonicConfig;
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 decided to add this as a config object instead of adding innerHTMLTemplatesEnabled as a boolean because this will allow us to enhance the Config documentation if desired by adding playgrounds passing different config options.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't mind this, but my concern is that it might be confusing for devs who are reviewing the demos. Some might not realize the important admonition and only copy/paste code. They'll probably think that the select option has a bug. If we included innerHTMLTemplatesEnabled within the code then we can avoid this.

I don't feel strongly about this since:

  1. you do have that admonition
  2. the demos only provide the bare minimal (meaning we don't show files like App.tsx to showcase config changes)

* Ionic app configuration. See [IonicConfig](/docs/developing/config#ionicconfig).
* Playground only injects serializable values (string, number, boolean) into StackBlitz.
*/
export type IonicConfig = Record<string, unknown>;
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 was going to import the type from Ionic but then we would have a dependency on @ionic/core and I don't know if we want that.


## Ionic Config

Pass an [IonicConfig](/docs/developing/config#ionicconfig) object so generated StackBlitz projects bootstrap with the same settings. This is merged with the active preview `mode` when opening the editor. Only string, number, and boolean values are injected into generated code:
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 chose this rather than adding an entire file for each framework to pass the config like Vue but if we prefer that approach I can revert this.

Comment on lines +56 to +64
const formatInterfaceLabel = (selectInterface) => {
return selectInterface
.split('-')
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
};

/* Dynamically create the different Select components */
const selectInterfaces = ['alert', 'action-sheet', 'modal', 'popover'];
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.

Originally I defined the interface array like this:

const selectInterfaces = [{
  label: 'Alert',
  value: 'alert',
}, {
  label: 'Action Sheet',
  value: 'action-sheet',
}, {
  label: 'Modal',
  value: 'modal',
}, {
  label: 'Popover',
  value: 'popover',
}];

but I removed it in favor of using the single string and converting it to the label. If we think this is too much for the demo, I can go back to the object array.

Comment on lines +102 to +106
/* The interfaceOptions property is for demonstration purposes only. */
/* It is not required for the rich options to work. */
select.interfaceOptions = {
header: 'Travel mode',
};
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 just to make the demo look nicer but can be removed if desired.

@brandyscarney brandyscarney marked this pull request as ready for review May 20, 2026 18:26
@brandyscarney brandyscarney requested a review from a team as a code owner May 20, 2026 18:26
@brandyscarney brandyscarney requested review from gnbm and thetaPC and removed request for a team and gnbm May 20, 2026 18:26
Copy link
Copy Markdown
Contributor

@thetaPC thetaPC left a comment

Choose a reason for hiding this comment

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

LGTM, minor suggestions!

Thank you for updating the Playground docs!

Comment thread docs/api/select.md

<StartEndSlots />

## Rich Content Options
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It should also mention that a selected text will strip out the HTML to only provide plain text. Also start, end slots and descriptions are not included.

Comment thread docs/api/select.md

## Rich Content Options

:::important
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not part of this PR but personal question: Do you think purple is appropriate for important?

Comment thread docs/api/select.md
## Rich Content Options

:::important
Rich content in select options is disabled by default. Set [`innerHTMLTemplatesEnabled`](/docs/developing/config#ionicconfig) to `true` in your [global Ionic config](/docs/developing/config#global-config). Markup inside options is treated as plain text when it is disabled. Refer to [Security](/docs/techniques/security.md) for sanitization guidance when enabling custom HTML.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By adding .md, it will be easier to migrate the files later from .md to .mdx.

Suggested change
Rich content in select options is disabled by default. Set [`innerHTMLTemplatesEnabled`](/docs/developing/config#ionicconfig) to `true` in your [global Ionic config](/docs/developing/config#global-config). Markup inside options is treated as plain text when it is disabled. Refer to [Security](/docs/techniques/security.md) for sanitization guidance when enabling custom HTML.
Rich content in select options is disabled by default. Set [`innerHTMLTemplatesEnabled`](/docs/developing/config.md#ionicconfig) to `true` in your [global Ionic config](/docs/developing/config.md#global-config). Markup inside options is treated as plain text when it is disabled. Refer to [Security](/docs/techniques/security.md) for sanitization guidance when enabling custom HTML.

## Enabling Custom HTML Parsing via `innerHTML`

`ion-alert`, `ion-infinite-scroll-content`, `ion-loading`, `ion-refresher-content`, and `ion-toast` can accept custom HTML as strings for certain properties. These strings are added to the DOM using `innerHTML` and must be properly sanitized by the developer. This behavior is disabled by default which means values passed to the affected components will always be interpreted as plaintext. Developers can enable this custom HTML behavior by setting `innerHTMLTemplatesEnabled: true` in the [IonicConfig](../developing/config#ionicconfig).
`ion-alert`, `ion-infinite-scroll-content`, `ion-loading`, `ion-refresher-content`, `ion-select-option`, and `ion-toast` can accept custom HTML as strings for certain properties. These strings are added to the DOM using `innerHTML` and must be properly sanitized by the developer. This behavior is disabled by default which means values passed to the affected components will always be interpreted as plaintext. Developers can enable this custom HTML behavior by setting `innerHTMLTemplatesEnabled: true` in the [IonicConfig](../developing/config#ionicconfig).
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By adding .md, it will be easier to migrate the files later from .md to .mdx. Might as well add it since we're here.

Suggested change
`ion-alert`, `ion-infinite-scroll-content`, `ion-loading`, `ion-refresher-content`, `ion-select-option`, and `ion-toast` can accept custom HTML as strings for certain properties. These strings are added to the DOM using `innerHTML` and must be properly sanitized by the developer. This behavior is disabled by default which means values passed to the affected components will always be interpreted as plaintext. Developers can enable this custom HTML behavior by setting `innerHTMLTemplatesEnabled: true` in the [IonicConfig](../developing/config#ionicconfig).
`ion-alert`, `ion-infinite-scroll-content`, `ion-loading`, `ion-refresher-content`, `ion-select-option`, and `ion-toast` can accept custom HTML as strings for certain properties. These strings are added to the DOM using `innerHTML` and must be properly sanitized by the developer. This behavior is disabled by default which means values passed to the affected components will always be interpreted as plaintext. Developers can enable this custom HTML behavior by setting `innerHTMLTemplatesEnabled: true` in the [IonicConfig](../developing/config.md#ionicconfig).

* example: `{ innerHTMLTemplatesEnabled: true }`. Merges with the active
* preview `mode` when opening the editor.
*/
ionicConfig?: IonicConfig;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't mind this, but my concern is that it might be confusing for devs who are reviewing the demos. Some might not realize the important admonition and only copy/paste code. They'll probably think that the select option has a bug. If we included innerHTMLTemplatesEnabled within the code then we can avoid this.

I don't feel strongly about this since:

  1. you do have that admonition
  2. the demos only provide the bare minimal (meaning we don't show files like App.tsx to showcase config changes)


## Ionic Config

Pass an [IonicConfig](/docs/developing/config#ionicconfig) object so generated StackBlitz projects bootstrap with the same settings. This is merged with the active preview `mode` when opening the editor. Only string, number, and boolean values are injected into generated code:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

By adding .md, it will be easier to migrate the files later from .md to .mdx.

Suggested change
Pass an [IonicConfig](/docs/developing/config#ionicconfig) object so generated StackBlitz projects bootstrap with the same settings. This is merged with the active preview `mode` when opening the editor. Only string, number, and boolean values are injected into generated code:
Pass an [IonicConfig](/docs/developing/config.md#ionicconfig) object so generated StackBlitz projects bootstrap with the same settings. This is merged with the active preview `mode` when opening the editor. Only string, number, and boolean values are injected into generated code:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants