diff --git a/apps/www/src/content/docs/components/combobox/demo.ts b/apps/www/src/content/docs/components/combobox/demo.ts index 71fb48d4b..bcdd15c73 100644 --- a/apps/www/src/content/docs/components/combobox/demo.ts +++ b/apps/www/src/content/docs/components/combobox/demo.ts @@ -78,13 +78,13 @@ export const groupDemo = { - Fruits + Fruits Apple Banana - Vegetables + Vegetables Carrot Broccoli @@ -92,6 +92,40 @@ export const groupDemo = { ` }; +export const labelDemo = { + type: 'code', + code: ` + + + Fruits + + + + + + + Apple + Banana + Grape + Orange + + ` +}; + +export const emptyDemo = { + type: 'code', + code: ` + + + + No fruit matches your search + Apple + Banana + Grape + + ` +}; + export const iconDemo = { type: 'code', code: ` diff --git a/apps/www/src/content/docs/components/combobox/index.mdx b/apps/www/src/content/docs/components/combobox/index.mdx index ad9c2c0be..05e0923f1 100644 --- a/apps/www/src/content/docs/components/combobox/index.mdx +++ b/apps/www/src/content/docs/components/combobox/index.mdx @@ -13,6 +13,8 @@ import { withFieldDemo, controlledDemo, createItemsDemo, + labelDemo, + emptyDemo, } from "./demo.ts"; @@ -25,8 +27,18 @@ Import and assemble the component: import { Combobox } from "@raystack/apsara"; + - + + + + + + + + + + ``` @@ -54,7 +66,7 @@ Wrap the Combobox with [Field](/docs/components/field) to add a label, descripti ### Groups and separators -Organize items into groups with labels and visual separators. Groups and labels are automatically hidden when the user is searching. +Organize items into groups with `Combobox.GroupLabel` and separators. Groups, group labels, and separators are hidden while the user is searching. @@ -64,8 +76,22 @@ Pass the `multiple` prop to enable multi-select. Selected values appear as chips Each chip shows its value as text. To show a label instead, pass `itemToStringLabel` to the root. Values in the `{ value, label }` shape show their `label` without it. +The input shows the first two chips and a "+N" count for the rest. Press Backspace in an empty input to remove the last value. Press Left Arrow at the start of the input to move focus to the chips. On a focused chip, press Backspace or Delete to remove it. + +### Label and clear button + +`Combobox.Label` renders a visible label linked to the input. `Combobox.Clear` renders a button that clears the value. It shows only when there is a value or input text. Place both anywhere inside `Combobox`. + + + +### Empty state + +`Combobox.Content` shows "No results" when no item matches the input. To change the text, add `Combobox.Empty` as a direct child of `Combobox.Content`. + + + ### Controlled Use `value` and `onValueChange` for controlled behavior. @@ -114,17 +140,41 @@ When no `value` prop is provided, the text content of `children` is used as the +### Label Props + +A visible label for the input. It renders a `