File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -115,6 +115,12 @@ Set `allowCustomValue` to `true` to let users enter custom text that isn't in th
115115
116116<FileSource src="/framed/ComboBox/AllowCustomValue" />
117117
118+ ## Virtualized (large lists)
119+
120+ Enable virtualization for large lists to improve performance. Only visible items are rendered in the DOM.
121+
122+ <FileSource src="/framed/ComboBox/VirtualizedComboBox" />
123+
118124## Top direction
119125
120126Set `direction` to `"top"` to make the dropdown menu appear above the input.
Original file line number Diff line number Diff line change 1+ <script >
2+ import { ComboBox , Stack } from " carbon-components-svelte" ;
3+
4+ const items = Array .from ({ length: 10_000 }, (_ , i ) => ({
5+ id: i,
6+ text: " Item " + (i + 1 ),
7+ }));
8+
9+ let value = " " ;
10+ let selectedId = undefined ;
11+ $: selectedItem = items .find ((item ) => item .id === selectedId);
12+ </script >
13+
14+ <Stack gap ={4 }>
15+ <ComboBox
16+ virtualize ={true }
17+ titleText =" Virtualized ComboBox (50,000 items)"
18+ placeholder =" Filter..."
19+ helperText =" Only visible items are rendered in the DOM"
20+ {items }
21+ shouldFilterItem ={(item , value ) =>
22+ item .text .toLowerCase ().includes (value .toLowerCase ())}
23+ bind:selectedId
24+ bind:value
25+ />
26+ <div >
27+ <strong >Selected:</strong >
28+ {selectedItem ?.text }
29+ </div >
30+ </Stack >
You can’t perform that action at this time.
0 commit comments