From b8d02537a6c9f534aa1748ef5fcbf8aeea168637 Mon Sep 17 00:00:00 2001 From: Cory LaViska Date: Tue, 20 Dec 2022 18:44:33 -0500 Subject: [PATCH] add grouping example --- docs/components/select.md | 31 +++++++++++++++++++++++++- src/components/select/select.styles.ts | 8 +++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/docs/components/select.md b/docs/components/select.md index efe937b9..51f482e5 100644 --- a/docs/components/select.md +++ b/docs/components/select.md @@ -286,7 +286,36 @@ TODO ### Grouping Options -TODO +Use `` to group listbox items visually. You can also use `` to provide labels, but they won't be announced by most assistive devices. + +```html preview + + Section 1 + Option 1 + Option 2 + Option 3 + + Section 2 + Option 4 + Option 5 + Option 6 + +``` + +```jsx react +import { SlOption, SlSelect } from '@shoelace-style/shoelace/dist/react'; + +const App = () => ( + + Option 1 + Option 2 + Option 3 + Option 4 + Option 5 + Option 6 + +); +``` ### Sizes diff --git a/src/components/select/select.styles.ts b/src/components/select/select.styles.ts index 14f27455..4323eef7 100644 --- a/src/components/select/select.styles.ts +++ b/src/components/select/select.styles.ts @@ -244,7 +244,15 @@ export default css` max-height: var(--auto-size-available-height); } + /* Slotted content */ .select__listbox::slotted(sl-divider) { --spacing: var(--sl-spacing-x-small); } + + .select__listbox::slotted(small) { + font-size: var(--sl-font-size-small); + font-weight: var(--sl-font-weight-semibold); + color: var(--sl-color-neutral-500); + padding: var(--sl-spacing-x-small) var(--sl-spacing-x-large); + } `;