File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-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 } from " carbon-components-svelte" ;
3+
4+ // Generate large dataset
5+ const items = Array .from ({ length: 5000 }, (_ , i ) => ({
6+ id: String (i),
7+ text: " Item " + (i + 1 ),
8+ }));
9+
10+ let selectedId = undefined ;
11+ let value = " " ;
12+ </script >
13+
14+ <ComboBox
15+ titleText =" Virtualized ComboBox (5,000 items)"
16+ placeholder =" Filter..."
17+ helperText =" Only visible items are rendered in the DOM"
18+ {items }
19+ shouldFilterItem ={(item , value ) =>
20+ item .text .toLowerCase ().includes (value .toLowerCase ())}
21+ bind:selectedId
22+ bind:value
23+ virtualize ={true }
24+ />
25+
26+ <div style =" margin-top: 1rem;" >
27+ {#if selectedId !== undefined }
28+ <strong >Selected:</strong >
29+ {items .find ((item ) => item .id === selectedId )?.text }
30+ {/if }
31+ </div >
You can’t perform that action at this time.
0 commit comments