From d907d000a678364eab8e913204a86e9c4edd0f59 Mon Sep 17 00:00:00 2001 From: Eric Liu Date: Sun, 20 Apr 2025 15:10:24 -0700 Subject: [PATCH] docs(combo-box): improve docs --- docs/src/pages/components/ComboBox.svx | 38 ++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/docs/src/pages/components/ComboBox.svx b/docs/src/pages/components/ComboBox.svx index 26d465b4..c02b01a7 100644 --- a/docs/src/pages/components/ComboBox.svx +++ b/docs/src/pages/components/ComboBox.svx @@ -3,6 +3,8 @@ import Preview from "../../components/Preview.svelte"; +ComboBox combines a text input with a dropdown menu. Use it to let users select from a predefined list of options or enter custom values. + `ComboBox` is keyed for performance reasons. @@ -11,6 +13,8 @@ ## Default +Create a combobox with a title and placeholder text. Each item requires a unique `id` and `text`. + ## Hidden label +Set `hideLabel` to `true` to visually hide the label while keeping it accessible to screen readers. + ## Clear selection -To programmatically clear the selection, access the component instance using the [bind:this](https://svelte.dev/docs#bind_element) directive and invoke the `ComboBox.clear()` accessor. +Use `bind:this` to access the component instance and call `ComboBox.clear()` to programmatically clear the selection. -Specify `focus: false` in the method options to avoid re-focusing the input. +Set `focus: false` in the method options to prevent re-focusing the input. ## Multiple combo boxes +See how to manage multiple comboboxes in a form. + ## Filterable +Enable filtering to let users search through the options. + ## Filterable with custom label -Combine a custom label `itemToString` with the filterable option (e.g., internationalization). +Set `itemToString` to customize how items display in the filterable combobox. ## Top direction -Set `direction` to `"top"` for the combobox dropdown menu to appear above the input. +Set `direction` to `"top"` to make the dropdown menu appear above the input.