diff --git a/docs/components/select.md b/docs/components/select.md index df203a4c7..9eec72f37 100644 --- a/docs/components/select.md +++ b/docs/components/select.md @@ -394,6 +394,33 @@ const App = () => ( ); ``` +### Placement + +The preferred placement of the dropdown can be set with the `placement` attribute. Note that the actual position may vary to ensure the panel remains in the viewport. + +```html preview + + Option 1 + Option 2 + Option 3 + +``` + +```jsx react +import { + SlMenuItem, + SlSelect +} from '@shoelace-style/shoelace/dist/react'; + +const App = () => ( + + Option 1 + Option 2 + Option 3 + +); +``` + ### Prefix & Suffix Icons Use the `prefix` and `suffix` slots to add icons. diff --git a/src/components/select/select.ts b/src/components/select/select.ts index 203d9b660..b4374a6bf 100644 --- a/src/components/select/select.ts +++ b/src/components/select/select.ts @@ -121,6 +121,12 @@ export default class SlSelect extends LitElement { /** The select's label. Alternatively, you can use the label slot. */ @property() label = ''; + /** + * The preferred placement of the dropdown panel. Note that the actual placement may vary as needed to keep the panel + * inside of the viewport. + */ + @property() placement: 'top' | 'bottom' = 'bottom'; + /** The select's help text. Alternatively, you can use the help-text slot. */ @property({ attribute: 'help-text' }) helpText = ''; @@ -451,6 +457,7 @@ export default class SlSelect extends LitElement {