diff --git a/.prettierignore b/.prettierignore index 92476da66..e3f4ba0ae 100644 --- a/.prettierignore +++ b/.prettierignore @@ -7,6 +7,7 @@ docs/search.json src/components/icon/icons src/react/index.ts node_modules +package.json package-lock.json tsconfig.json cdn diff --git a/cspell.json b/cspell.json index 1ae873361..028a62671 100644 --- a/cspell.json +++ b/cspell.json @@ -160,6 +160,7 @@ "unbundles", "unbundling", "unicons", + "unsanitized", "unsupportive", "valpha", "valuenow", diff --git a/docs/pages/components/select.md b/docs/pages/components/select.md index 6fd05cbe1..4705dc07b 100644 --- a/docs/pages/components/select.md +++ b/docs/pages/components/select.md @@ -454,3 +454,53 @@ const App = () => ( ); ``` + +### Custom Tags + +When multiple options can be selected, you can provide custom tags by passing a function to the `getTag` property. Your function can return a string of HTML, a Lit Template, or an [`HTMLElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement). The `getTag()` function will be called for each option. The first argument is an `` element and the second argument is the tag's index (its position in the tag list). + +Remember that custom tags are rendered in a shadow root. To style them, you can use the `style` attribute in your template or you can add your own [parts](/getting-started/customizing/#css-parts) and target them with the [`::part()`](https://developer.mozilla.org/en-US/docs/Web/CSS/::part) selector. + +```html:preview + + + + Email + + + + Phone + + + + Chat + + + + +``` + +:::warning +Be sure you trust the content you are outputting! Passing unsanitized user input to `getTag()` can result in XSS vulnerabilities. +::: diff --git a/docs/pages/getting-started/form-controls.md b/docs/pages/getting-started/form-controls.md index 1fccb422f..8cc04584e 100644 --- a/docs/pages/getting-started/form-controls.md +++ b/docs/pages/getting-started/form-controls.md @@ -462,7 +462,7 @@ To disable the browser's error messages, you need to cancel the `sl-invalid` eve Reset -