Skip to content

Commit

Permalink
Add listbox placement demo for Select (#38130)
Browse files Browse the repository at this point in the history
  • Loading branch information
sai6855 committed Jul 25, 2023
1 parent 35f2950 commit 1140095
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
29 changes: 29 additions & 0 deletions docs/data/joy/components/select/SelectPosition.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';
import Select from '@mui/joy/Select';
import Option from '@mui/joy/Option';

function SelectPosition() {
return (
<Select
placeholder="Select address"
sx={{ width: 240 }}
slotProps={{
listbox: {
placement: 'bottom-start',
},
}}
>
<Option value="1">
Flat 5, 24 Bhlenheiman Avenue, South Kensington, EW13 9SD
</Option>
<Option value="2">
Flat 6, 24 Bhlenheiman Avenue, South Kensington, EW13 9SD
</Option>
<Option value="3">
Flat 6b, 24 Bhlenheiman Avenue, South Kensington, EW13 9SD
</Option>
</Select>
);
}

export default SelectPosition;
29 changes: 29 additions & 0 deletions docs/data/joy/components/select/SelectPosition.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as React from 'react';
import Select from '@mui/joy/Select';
import Option from '@mui/joy/Option';

function SelectPosition() {
return (
<Select
placeholder="Select address"
sx={{ width: 240 }}
slotProps={{
listbox: {
placement: 'bottom-start',
},
}}
>
<Option value="1">
Flat 5, 24 Bhlenheiman Avenue, South Kensington, EW13 9SD
</Option>
<Option value="2">
Flat 6, 24 Bhlenheiman Avenue, South Kensington, EW13 9SD
</Option>
<Option value="3">
Flat 6b, 24 Bhlenheiman Avenue, South Kensington, EW13 9SD
</Option>
</Select>
);
}

export default SelectPosition;
6 changes: 6 additions & 0 deletions docs/data/joy/components/select/select.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ To control the placement of the listbox, use `placement`:
:::
#### Placement
To align `listbox` position to `Select` while displaying long options, use `slotProps` prop to position listbox slot:
{{"demo": "SelectPosition.js"}}
#### Controlling the open state
You can control the open state of the select with the `listboxOpen` prop. Alternatively, it is also possible to set the initial (uncontrolled) open state of the component with the `defaultListboxOpen` prop.
Expand Down

0 comments on commit 1140095

Please sign in to comment.