Form
Combobox
Usage#
import { WDS_COMBOBOX } from '@wds/angular/combobox';Examples#
Default#
wds-change fires with value. Set empty-text: its default is in Polish.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-default-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Framework" placeholder="Select a framework" empty-text="No items found.">
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxDefaultDemo {}Disabled#
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-disabled-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Framework" placeholder="Select a framework" disabled>
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxDisabledDemo {}Invalid#
invalid on wds-field (or on the combobox) shows the error state; wds-field-error describes it.
import { Component } from '@angular/core';
import { WdsFieldComponent, WdsFieldErrorComponent, WdsFieldLabelComponent } from '@wds/angular/field';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-invalid-demo',
imports: [WdsFieldComponent, WdsFieldLabelComponent, WdsFieldErrorComponent, WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-field class="w-full max-w-xs" invalid>
<wds-field-label>Framework</wds-field-label>
<wds-combobox class="w-full" placeholder="Select a framework" empty-text="No items found.">
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
<wds-field-error>This field is required.</wds-field-error>
</wds-field>
`,
})
export class ComboboxInvalidDemo {}Clear button#
show-clear replaces the chevron with a button that clears the value while something is selected. Name it with clear-label.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-clear-button-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Framework" placeholder="Select a framework" empty-text="No items found." value="next" show-clear clear-label="Clear">
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxClearButtonDemo {}Auto highlight#
auto-highlight highlights the first matching option as you type, so Enter selects it right away.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-auto-highlight-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Framework" placeholder="Select a framework" empty-text="No items found." auto-highlight>
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxAutoHighlightDemo {}Groups#
wds-combobox-group with a wds-combobox-label groups the options. Groups without a match hide.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxGroupComponent, WdsComboboxItemComponent, WdsComboboxLabelComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-groups-demo',
imports: [WdsComboboxComponent, WdsComboboxGroupComponent, WdsComboboxLabelComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Timezone" placeholder="Select a timezone" empty-text="No timezones found.">
<wds-combobox-group>
<wds-combobox-label>Americas</wds-combobox-label>
<wds-combobox-item value="new-york">(GMT-5) New York</wds-combobox-item>
<wds-combobox-item value="los-angeles">(GMT-8) Los Angeles</wds-combobox-item>
<wds-combobox-item value="chicago">(GMT-6) Chicago</wds-combobox-item>
<wds-combobox-item value="toronto">(GMT-5) Toronto</wds-combobox-item>
<wds-combobox-item value="vancouver">(GMT-8) Vancouver</wds-combobox-item>
<wds-combobox-item value="s-o-paulo">(GMT-3) São Paulo</wds-combobox-item>
</wds-combobox-group>
<wds-combobox-group>
<wds-combobox-label>Europe</wds-combobox-label>
<wds-combobox-item value="london">(GMT+0) London</wds-combobox-item>
<wds-combobox-item value="paris">(GMT+1) Paris</wds-combobox-item>
<wds-combobox-item value="berlin">(GMT+1) Berlin</wds-combobox-item>
<wds-combobox-item value="rome">(GMT+1) Rome</wds-combobox-item>
<wds-combobox-item value="madrid">(GMT+1) Madrid</wds-combobox-item>
<wds-combobox-item value="amsterdam">(GMT+1) Amsterdam</wds-combobox-item>
</wds-combobox-group>
<wds-combobox-group>
<wds-combobox-label>Asia/Pacific</wds-combobox-label>
<wds-combobox-item value="tokyo">(GMT+9) Tokyo</wds-combobox-item>
<wds-combobox-item value="shanghai">(GMT+8) Shanghai</wds-combobox-item>
<wds-combobox-item value="singapore">(GMT+8) Singapore</wds-combobox-item>
<wds-combobox-item value="dubai">(GMT+4) Dubai</wds-combobox-item>
<wds-combobox-item value="sydney">(GMT+11) Sydney</wds-combobox-item>
<wds-combobox-item value="seoul">(GMT+9) Seoul</wds-combobox-item>
</wds-combobox-group>
</wds-combobox>
`,
})
export class ComboboxGroupsDemo {}Groups and separators#
wds-combobox-separator draws a line between groups. Separators hide while you type.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxGroupComponent, WdsComboboxItemComponent, WdsComboboxLabelComponent, WdsComboboxSeparatorComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-groups-separators-demo',
imports: [WdsComboboxComponent, WdsComboboxGroupComponent, WdsComboboxLabelComponent, WdsComboboxItemComponent, WdsComboboxSeparatorComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Timezone" placeholder="Select a timezone" empty-text="No timezones found.">
<wds-combobox-group>
<wds-combobox-label>Americas</wds-combobox-label>
<wds-combobox-item value="new-york">(GMT-5) New York</wds-combobox-item>
<wds-combobox-item value="los-angeles">(GMT-8) Los Angeles</wds-combobox-item>
<wds-combobox-item value="chicago">(GMT-6) Chicago</wds-combobox-item>
<wds-combobox-item value="toronto">(GMT-5) Toronto</wds-combobox-item>
<wds-combobox-item value="vancouver">(GMT-8) Vancouver</wds-combobox-item>
<wds-combobox-item value="s-o-paulo">(GMT-3) São Paulo</wds-combobox-item>
</wds-combobox-group>
<wds-combobox-separator></wds-combobox-separator>
<wds-combobox-group>
<wds-combobox-label>Europe</wds-combobox-label>
<wds-combobox-item value="london">(GMT+0) London</wds-combobox-item>
<wds-combobox-item value="paris">(GMT+1) Paris</wds-combobox-item>
<wds-combobox-item value="berlin">(GMT+1) Berlin</wds-combobox-item>
<wds-combobox-item value="rome">(GMT+1) Rome</wds-combobox-item>
<wds-combobox-item value="madrid">(GMT+1) Madrid</wds-combobox-item>
<wds-combobox-item value="amsterdam">(GMT+1) Amsterdam</wds-combobox-item>
</wds-combobox-group>
<wds-combobox-separator></wds-combobox-separator>
<wds-combobox-group>
<wds-combobox-label>Asia/Pacific</wds-combobox-label>
<wds-combobox-item value="tokyo">(GMT+9) Tokyo</wds-combobox-item>
<wds-combobox-item value="shanghai">(GMT+8) Shanghai</wds-combobox-item>
<wds-combobox-item value="singapore">(GMT+8) Singapore</wds-combobox-item>
<wds-combobox-item value="dubai">(GMT+4) Dubai</wds-combobox-item>
<wds-combobox-item value="sydney">(GMT+11) Sydney</wds-combobox-item>
<wds-combobox-item value="seoul">(GMT+9) Seoul</wds-combobox-item>
</wds-combobox-group>
</wds-combobox>
`,
})
export class ComboboxGroupsSeparatorsDemo {}Large list#
import { Component } from '@angular/core';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-large-list-demo',
host: { class: 'flex w-full justify-center' },
imports: [...WDS_COMBOBOX],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Item" placeholder="Search from 500 items" empty-text="No items found.">
@for (item of items; track item) {
<wds-combobox-item [value]="item">{{ item }}</wds-combobox-item>
}
</wds-combobox>
`,
})
export class ComboboxLargeListDemo {
protected readonly items = Array.from({ length: 500 }, (_, i) => `Item ${i + 1}`);
}Icon addon#
icon-start shows a registered icon at the start of the field; the start slot takes your own content instead.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
import '@wds/core/icons/lucide/globe';
@Component({
selector: 'app-combobox-icon-addon-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Framework" placeholder="Select a framework" empty-text="No items found." icon-start="lucide-globe">
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxIconAddonDemo {}Popup#
trigger="button" turns the field into a button that opens a panel with a search field (search-placeholder). Use it for pickers whose value is more than text: the icon-start of the selected option, or an <img>, <svg>, wds-avatar or wds-icon placed directly in it, also shows in the button.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-popup-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" trigger="button" aria-label="Country" placeholder="Select a country" search-placeholder="Search" empty-text="No items found.">
<wds-combobox-item value="af" selected><img src="https://flagcdn.com/af.svg" alt="" width="16" height="12" class="rounded-xs" />Afghanistan</wds-combobox-item>
<wds-combobox-item value="al"><img src="https://flagcdn.com/al.svg" alt="" width="16" height="12" class="rounded-xs" />Albania</wds-combobox-item>
<wds-combobox-item value="dz"><img src="https://flagcdn.com/dz.svg" alt="" width="16" height="12" class="rounded-xs" />Algeria</wds-combobox-item>
<wds-combobox-item value="as"><img src="https://flagcdn.com/as.svg" alt="" width="16" height="12" class="rounded-xs" />American Samoa</wds-combobox-item>
<wds-combobox-item value="ad"><img src="https://flagcdn.com/ad.svg" alt="" width="16" height="12" class="rounded-xs" />Andorra</wds-combobox-item>
<wds-combobox-item value="ao"><img src="https://flagcdn.com/ao.svg" alt="" width="16" height="12" class="rounded-xs" />Angola</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxPopupDemo {}Form#
<form> the value is submitted under name; required blocks an empty submit.
import { Component } from '@angular/core';
import { WdsButtonComponent } from '@wds/angular/button';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { WDS_FIELD } from '@wds/angular/field';
import { toast } from '@wds/angular/toast';
@Component({
selector: 'app-combobox-form-demo',
host: { class: 'flex w-full justify-center' },
imports: [...WDS_COMBOBOX, ...WDS_FIELD, WdsButtonComponent],
template: `
<form class="grid w-full max-w-xs gap-4" (submit)="submit($event)">
<wds-field>
<wds-field-label>Framework</wds-field-label>
<wds-combobox class="w-full" name="framework" placeholder="Select a framework" empty-text="No items found." required>
@for (framework of frameworks; track framework) {
<wds-combobox-item [value]="framework">{{ framework }}</wds-combobox-item>
}
</wds-combobox>
</wds-field>
<wds-button type="submit" class="w-full">Submit</wds-button>
</form>
`,
})
export class ComboboxFormDemo {
protected readonly frameworks = ['Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro'];
protected submit(e: SubmitEvent): void {
e.preventDefault();
const framework = new FormData(e.target as HTMLFormElement).get('framework');
toast(`You selected ${framework} as your framework.`);
}
}Multiple#
multiple selects several options, shown as chips in the field; the list stays open after each pick. Backspace in the empty field removes the last chip; ArrowLeft moves to the chips. wds-change has all selected values; options with selected are selected by default. Name the remove buttons with remove-label.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-multiple-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Frameworks" placeholder="Select frameworks..." empty-text="No items found." remove-label="Remove" multiple auto-highlight>
<wds-combobox-item value="next" selected>Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxMultipleDemo {}Multiple disabled#
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-multiple-disabled-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Frameworks" placeholder="Select frameworks..." multiple disabled>
<wds-combobox-item value="next" selected>Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit" selected>SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxMultipleDisabledDemo {}Multiple invalid#
import { Component } from '@angular/core';
import { WdsFieldComponent, WdsFieldErrorComponent, WdsFieldLabelComponent } from '@wds/angular/field';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-multiple-invalid-demo',
imports: [WdsFieldComponent, WdsFieldLabelComponent, WdsFieldErrorComponent, WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-field class="w-full max-w-xs" invalid>
<wds-field-label>Frameworks</wds-field-label>
<wds-combobox class="w-full" placeholder="Select frameworks..." empty-text="No items found." remove-label="Remove" multiple auto-highlight>
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
<wds-field-error>Select at least one framework.</wds-field-error>
</wds-field>
`,
})
export class ComboboxMultipleInvalidDemo {}Locked chips#
locked on a selected option keeps it selected: its chip has no remove button.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-locked-chips-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Frameworks" placeholder="Select frameworks..." empty-text="No items found." remove-label="Remove" multiple auto-highlight>
<wds-combobox-item value="next" selected locked>Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit" selected locked>SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxLockedChipsDemo {}Custom items#
label sets the text shown in the field and used by the search.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
import { WdsAvatarComponent } from '@wds/angular/avatar';
@Component({
selector: 'app-combobox-custom-items-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsAvatarComponent],
template: `
<wds-combobox class="w-full max-w-xs" trigger="button" aria-label="Member" placeholder="Select a member" search-placeholder="Search members..." empty-text="No members found.">
<wds-combobox-item value="alex-morgan" label="Alex Morgan" selected>
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=96&h=96&dpr=2&q=80" aria-hidden="true">AM</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Alex Morgan</span>
<span class="truncate text-xs text-muted-foreground">Software Engineer</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="emma-carter" label="Emma Carter">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=96&h=96&dpr=2&q=80" aria-hidden="true">EC</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Emma Carter</span>
<span class="truncate text-xs text-muted-foreground">Product Manager</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="ryan-mitchell" label="Ryan Mitchell">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=96&h=96&dpr=2&q=80" aria-hidden="true">RM</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Ryan Mitchell</span>
<span class="truncate text-xs text-muted-foreground">UX Designer</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="olivia-bennett" label="Olivia Bennett">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1517841905240-472988babdf9?w=96&h=96&dpr=2&q=80" aria-hidden="true">OB</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Olivia Bennett</span>
<span class="truncate text-xs text-muted-foreground">Technical Lead</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="ethan-brooks" label="Ethan Brooks">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1504593811423-6dd665756598?w=96&h=96&dpr=2&q=80" aria-hidden="true">EB</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Ethan Brooks</span>
<span class="truncate text-xs text-muted-foreground">CTO</span>
</span>
</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxCustomItemsDemo {}Dialog#
wds-dialog.
import { Component } from '@angular/core';
import { WdsButtonComponent } from '@wds/angular/button';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { WdsDialogComponent } from '@wds/angular/dialog';
import { toast } from '@wds/angular/toast';
@Component({
selector: 'app-combobox-dialog-demo',
host: { class: 'flex w-full justify-center' },
imports: [...WDS_COMBOBOX, WdsButtonComponent, WdsDialogComponent],
template: `
<wds-button class="w-full max-w-xs" (click)="dialog.show()">Open Dialog</wds-button>
<wds-dialog
#dialog
class="[--wds-dialog-width:24rem]"
heading="Select Framework"
description="Choose your preferred framework from the list below."
>
<wds-combobox class="w-full" aria-label="Framework" placeholder="Select a framework" empty-text="No items found.">
@for (framework of frameworks; track framework.value) {
<wds-combobox-item [value]="framework.value">{{ framework.label }}</wds-combobox-item>
}
</wds-combobox>
<wds-button slot="footer" variant="outline" (click)="dialog.close()">Cancel</wds-button>
<wds-button slot="footer" (click)="confirm(); dialog.close()">Confirm</wds-button>
</wds-dialog>
`,
})
export class ComboboxDialogDemo {
protected readonly frameworks = [
{ value: 'next', label: 'Next.js' },
{ value: 'sveltekit', label: 'SvelteKit' },
{ value: 'nuxt', label: 'Nuxt.js' },
{ value: 'remix', label: 'Remix' },
{ value: 'astro', label: 'Astro' },
];
protected confirm(): void {
toast('Framework selected.');
}
}Custom trigger icon#
<svg> in the icon slot replaces the chevron.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/chevrons-up-down';
@Component({
selector: 'app-combobox-custom-trigger-icon-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsIconComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Framework" placeholder="Select framework" empty-text="No items found." show-clear clear-label="Clear">
<wds-icon name="lucide-chevrons-up-down" slot="icon"></wds-icon>
<wds-combobox-item value="next">Next.js</wds-combobox-item>
<wds-combobox-item value="sveltekit">SvelteKit</wds-combobox-item>
<wds-combobox-item value="nuxt">Nuxt.js</wds-combobox-item>
<wds-combobox-item value="remix">Remix</wds-combobox-item>
<wds-combobox-item value="astro">Astro</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxCustomTriggerIconDemo {}Member chips#
::part(chip) styles the chips, here as pills.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
import { WdsAvatarComponent } from '@wds/angular/avatar';
@Component({
selector: 'app-combobox-member-chips-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsAvatarComponent],
template: `
<wds-combobox class="w-full max-w-xs [&::part(chip)]:rounded-full" aria-label="Members" placeholder="Add members..." empty-text="No members found." remove-label="Remove" multiple>
<wds-combobox-item value="alex-morgan" label="Alex Morgan" selected>
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=96&h=96&dpr=2&q=80" aria-hidden="true">AM</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Alex Morgan</span>
<span class="truncate text-xs text-muted-foreground">Software Engineer</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="emma-carter" label="Emma Carter" selected>
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=96&h=96&dpr=2&q=80" aria-hidden="true">EC</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Emma Carter</span>
<span class="truncate text-xs text-muted-foreground">Product Manager</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="ryan-mitchell" label="Ryan Mitchell">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=96&h=96&dpr=2&q=80" aria-hidden="true">RM</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Ryan Mitchell</span>
<span class="truncate text-xs text-muted-foreground">UX Designer</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="olivia-bennett" label="Olivia Bennett">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1517841905240-472988babdf9?w=96&h=96&dpr=2&q=80" aria-hidden="true">OB</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Olivia Bennett</span>
<span class="truncate text-xs text-muted-foreground">Technical Lead</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="ethan-brooks" label="Ethan Brooks">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1504593811423-6dd665756598?w=96&h=96&dpr=2&q=80" aria-hidden="true">EB</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Ethan Brooks</span>
<span class="truncate text-xs text-muted-foreground">CTO</span>
</span>
</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxMemberChipsDemo {}Invisible#
variant="ghost" removes the border and background of the field, for inline tags in a chat, a task or an assignment.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
import { WdsAvatarComponent } from '@wds/angular/avatar';
@Component({
selector: 'app-combobox-invisible-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsAvatarComponent],
template: `
<wds-combobox class="w-full max-w-xs" variant="ghost" aria-label="Members" placeholder="Add members..." empty-text="No members found." remove-label="Remove" multiple>
<wds-combobox-item value="alex-morgan" label="Alex Morgan">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=96&h=96&dpr=2&q=80" aria-hidden="true">AM</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Alex Morgan</span>
<span class="truncate text-xs text-muted-foreground">Software Engineer</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="emma-carter" label="Emma Carter" selected>
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=96&h=96&dpr=2&q=80" aria-hidden="true">EC</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Emma Carter</span>
<span class="truncate text-xs text-muted-foreground">Product Manager</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="ryan-mitchell" label="Ryan Mitchell">
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=96&h=96&dpr=2&q=80" aria-hidden="true">RM</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Ryan Mitchell</span>
<span class="truncate text-xs text-muted-foreground">UX Designer</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="olivia-bennett" label="Olivia Bennett" selected>
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1517841905240-472988babdf9?w=96&h=96&dpr=2&q=80" aria-hidden="true">OB</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Olivia Bennett</span>
<span class="truncate text-xs text-muted-foreground">Technical Lead</span>
</span>
</wds-combobox-item>
<wds-combobox-item value="ethan-brooks" label="Ethan Brooks" selected>
<wds-avatar size="sm" src="https://images.unsplash.com/photo-1504593811423-6dd665756598?w=96&h=96&dpr=2&q=80" aria-hidden="true">EB</wds-avatar>
<span class="flex min-w-0 flex-col">
<span class="truncate">Ethan Brooks</span>
<span class="truncate text-xs text-muted-foreground">CTO</span>
</span>
</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxInvisibleDemo {}Status#
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/circle-dot';
import '@wds/core/icons/lucide/circle';
import '@wds/core/icons/lucide/circle-pause';
import '@wds/core/icons/lucide/check-circle-2';
import '@wds/core/icons/lucide/circle-x';
@Component({
selector: 'app-combobox-status-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsIconComponent],
template: `
<wds-combobox class="w-full max-w-xs" trigger="button" aria-label="Status" placeholder="Set status" search-placeholder="Change status" empty-text="No statuses found." auto-highlight>
<wds-combobox-item value="backlog"><wds-icon name="lucide-circle-dot" class="text-muted-foreground/70"></wds-icon>Backlog</wds-combobox-item>
<wds-combobox-item value="planned" selected><wds-icon name="lucide-circle" class="text-foreground/70"></wds-icon>Planned</wds-combobox-item>
<wds-combobox-item value="in-progress"><wds-icon name="lucide-circle-dot" class="text-sky-500"></wds-icon>In Progress</wds-combobox-item>
<wds-combobox-item value="paused"><wds-icon name="lucide-circle-pause" class="text-amber-500"></wds-icon>Paused</wds-combobox-item>
<wds-combobox-item value="completed"><wds-icon name="lucide-check-circle-2" class="text-emerald-500"></wds-icon>Completed</wds-combobox-item>
<wds-combobox-item value="cancelled"><wds-icon name="lucide-circle-x" class="text-muted-foreground"></wds-icon>Cancelled</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxStatusDemo {}Priority#
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/ellipsis';
import '@wds/core/icons/lucide/triangle-alert';
@Component({
selector: 'app-combobox-priority-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsIconComponent],
template: `
<wds-combobox class="w-full max-w-xs" trigger="button" aria-label="Priority" placeholder="Set priority" search-placeholder="Change priority" empty-text="No priorities found." auto-highlight>
<wds-combobox-item value="none"><wds-icon name="lucide-ellipsis" class="text-muted-foreground"></wds-icon>No Priority</wds-combobox-item>
<wds-combobox-item value="urgent"><wds-icon name="lucide-triangle-alert" class="text-yellow-500"></wds-icon>Urgent</wds-combobox-item>
<wds-combobox-item value="high"><svg data-wds-graphic viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="3" y="9" width="2.5" height="4" rx="1" fill="currentColor" /><rect x="7" y="6" width="2.5" height="7" rx="1" fill="currentColor" /><rect x="11" y="3" width="2.5" height="10" rx="1" fill="currentColor" /></svg>High</wds-combobox-item>
<wds-combobox-item value="medium" selected><svg data-wds-graphic viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="3" y="9" width="2.5" height="4" rx="1" fill="currentColor" /><rect x="7" y="6" width="2.5" height="7" rx="1" fill="currentColor" /><rect x="11" y="3" width="2.5" height="10" rx="1" fill="currentColor" opacity="0.28" /></svg>Medium</wds-combobox-item>
<wds-combobox-item value="low"><svg data-wds-graphic viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="3" y="9" width="2.5" height="4" rx="1" fill="currentColor" /><rect x="7" y="6" width="2.5" height="7" rx="1" fill="currentColor" opacity="0.28" /><rect x="11" y="3" width="2.5" height="10" rx="1" fill="currentColor" opacity="0.28" /></svg>Low</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxPriorityDemo {}Lead#
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent, WdsComboboxSeparatorComponent } from '@wds/angular/combobox';
import { WdsIconComponent } from '@wds/angular/icon';
import { WdsAvatarComponent } from '@wds/angular/avatar';
import '@wds/core/icons/lucide/user-round';
@Component({
selector: 'app-combobox-lead-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsComboboxSeparatorComponent, WdsIconComponent, WdsAvatarComponent],
template: `
<wds-combobox class="w-full max-w-xs" trigger="button" aria-label="Lead" placeholder="Set lead" search-placeholder="Set project lead..." empty-text="No members found." auto-highlight>
<wds-combobox-item value="none" keywords="unassigned clear remove"><wds-icon name="lucide-user-round" class="text-muted-foreground"></wds-icon>No lead</wds-combobox-item>
<wds-combobox-separator></wds-combobox-separator>
<wds-combobox-item value="alex-morgan" label="Alex Morgan"><wds-avatar size="sm" src="https://images.unsplash.com/photo-1500648767791-00dcc994a43e?w=96&h=96&dpr=2&q=80" aria-hidden="true">AM</wds-avatar>Alex Morgan <span class="text-muted-foreground">(you)</span></wds-combobox-item>
<wds-combobox-item value="emma-carter" selected><wds-avatar size="sm" src="https://images.unsplash.com/photo-1494790108377-be9c29b29330?w=96&h=96&dpr=2&q=80" aria-hidden="true">EC</wds-avatar>Emma Carter</wds-combobox-item>
<wds-combobox-item value="ryan-mitchell"><wds-avatar size="sm" src="https://images.unsplash.com/photo-1506794778202-cad84cf45f1d?w=96&h=96&dpr=2&q=80" aria-hidden="true">RM</wds-avatar>Ryan Mitchell</wds-combobox-item>
<wds-combobox-item value="olivia-bennett"><wds-avatar size="sm" src="https://images.unsplash.com/photo-1517841905240-472988babdf9?w=96&h=96&dpr=2&q=80" aria-hidden="true">OB</wds-avatar>Olivia Bennett</wds-combobox-item>
<wds-combobox-item value="ethan-brooks"><wds-avatar size="sm" src="https://images.unsplash.com/photo-1504593811423-6dd665756598?w=96&h=96&dpr=2&q=80" aria-hidden="true">EB</wds-avatar>Ethan Brooks</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxLeadDemo {}Multiple members#
trigger="button" and multiple the button shows the selected options as badges. The value slot replaces them with your own summary, here avatars and a count. “No members” clears the selection.
import { Component, computed, signal } from '@angular/core';
import { WDS_AVATAR } from '@wds/angular/avatar';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { MEMBERS } from './members';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/users';
@Component({
selector: 'app-combobox-multi-member-demo',
host: { class: 'flex w-full justify-center' },
imports: [WdsIconComponent, ...WDS_COMBOBOX, ...WDS_AVATAR],
template: `
<wds-combobox
class="w-full max-w-xs"
trigger="button"
multiple
aria-label="Members"
search-placeholder="Select members"
empty-text="No members found."
auto-highlight
[values]="values()"
(wdsChange)="change($event.values)"
>
<span slot="value" class="flex min-w-0 items-center gap-2">
@if (selected().length) {
<wds-avatar-group>
@for (member of selected().slice(0, 3); track member.value) {
<wds-avatar size="sm" [src]="member.avatar" aria-hidden="true">{{ member.initials }}</wds-avatar>
}
</wds-avatar-group>
<span class="truncate">{{ selected().length }} {{ selected().length === 1 ? 'member' : 'members' }}</span>
} @else {
<wds-icon name="lucide-users" class="size-4 text-muted-foreground"></wds-icon>
<span class="text-muted-foreground">Members</span>
}
</span>
<wds-combobox-item value="none" keywords="clear remove nobody">
<wds-icon name="lucide-users" class="text-muted-foreground"></wds-icon>No members
</wds-combobox-item>
<wds-combobox-separator />
@for (member of members; track member.value) {
<wds-combobox-item [value]="member.value" [label]="member.name">
<wds-avatar size="sm" [src]="member.avatar" aria-hidden="true">{{ member.initials }}</wds-avatar>
{{ member.name }}
@if (member.you) {
<span class="text-muted-foreground">(you)</span>
}
</wds-combobox-item>
}
</wds-combobox>
`,
})
export class ComboboxMultiMemberDemo {
protected readonly members = MEMBERS;
protected readonly values = signal(MEMBERS.slice(0, 3).map((m) => m.value));
protected readonly selected = computed(() => this.values().map((v) => MEMBERS.find((m) => m.value === v)!));
protected change(values: string[]): void {
// "No members" clears the selection.
this.values.set(values.includes('none') ? [] : values);
}
}export interface Member {
value: string;
name: string;
initials: string;
avatar: string;
you?: boolean;
}
const photo = (id: string) => `https://images.unsplash.com/photo-${id}?w=96&h=96&dpr=2&q=80`;
export const MEMBERS: Member[] = [
{ value: 'alex-morgan', name: 'Alex Morgan', initials: 'AM', avatar: photo('1500648767791-00dcc994a43e'), you: true },
{ value: 'emma-carter', name: 'Emma Carter', initials: 'EC', avatar: photo('1494790108377-be9c29b29330') },
{ value: 'ryan-mitchell', name: 'Ryan Mitchell', initials: 'RM', avatar: photo('1506794778202-cad84cf45f1d') },
{ value: 'olivia-bennett', name: 'Olivia Bennett', initials: 'OB', avatar: photo('1517841905240-472988babdf9') },
{ value: 'ethan-brooks', name: 'Ethan Brooks', initials: 'EB', avatar: photo('1504593811423-6dd665756598') },
];Date#
wds-dialog.
import { Component, signal } from '@angular/core';
import { WdsButtonComponent } from '@wds/angular/button';
import { WdsCalendarComponent } from '@wds/angular/calendar';
import { WDS_COMBOBOX, type WdsComboboxComponent } from '@wds/angular/combobox';
import { WdsDialogComponent } from '@wds/angular/dialog';
import { dateOptions, fromIso, numericDate, shortDate, toIso } from './date-options';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/calendar';
import '@wds/core/icons/lucide/calendar-search';
@Component({
selector: 'app-combobox-date-demo',
host: { class: 'flex w-full justify-center' },
imports: [WdsIconComponent, ...WDS_COMBOBOX, WdsButtonComponent, WdsCalendarComponent, WdsDialogComponent],
template: `
<wds-combobox
#combobox
class="w-full max-w-xs"
trigger="button"
aria-label="Start date"
search-placeholder="Set start date..."
empty-text="No dates found."
auto-highlight
[value]="preset()"
(wdsChange)="change($event.value, combobox, dialog)"
>
<span slot="value" class="flex min-w-0 items-center gap-2">
<wds-icon name="lucide-calendar" class="size-4 shrink-0 text-muted-foreground"></wds-icon>
@if (label()) {
<span class="truncate">{{ label() }}</span>
} @else {
<span class="truncate text-muted-foreground">Set start</span>
}
</span>
<wds-combobox-item value="none" keywords="clear remove empty">
<wds-icon name="lucide-calendar" class="text-muted-foreground"></wds-icon>No date
</wds-combobox-item>
@for (option of options; track option.value) {
<wds-combobox-item [value]="option.value" [label]="option.label" [keywords]="option.keywords">
<wds-icon name="lucide-calendar" class="text-muted-foreground"></wds-icon>
<span class="flex-1">{{ option.label }}</span>
<span class="text-xs text-muted-foreground tabular-nums">{{ numericDate(option.date) }}</span>
</wds-combobox-item>
}
<wds-combobox-item value="custom" keywords="pick choose calendar">
<wds-icon name="lucide-calendar-search" class="text-muted-foreground"></wds-icon>Custom date...
</wds-combobox-item>
</wds-combobox>
<wds-dialog #dialog class="[--wds-dialog-width:20rem]" heading="Pick a date">
<wds-calendar class="mx-auto" [value]="draft()" (wdsChange)="draft.set($event.value)" />
<wds-button slot="footer" variant="outline" (click)="dialog.close()">Cancel</wds-button>
<wds-button slot="footer" (click)="confirm(); dialog.close()">Set date</wds-button>
</wds-dialog>
`,
})
export class ComboboxDateDemo {
protected readonly options = dateOptions();
protected readonly numericDate = numericDate;
/** The selected option: `none`, a preset, or empty for a custom date. */
protected readonly preset = signal('none');
protected readonly label = signal('');
protected readonly draft = signal(toIso(this.options[0].date));
protected change(value: string, combobox: WdsComboboxComponent, dialog: WdsDialogComponent): void {
if (value === 'custom') {
// "Custom date..." opens the calendar; the field keeps its value until the date is set.
combobox.value = this.preset();
dialog.show();
return;
}
this.preset.set(value);
this.label.set(this.options.find((o) => o.value === value)?.label ?? '');
}
protected confirm(): void {
this.preset.set('');
this.label.set(shortDate(fromIso(this.draft())));
}
}export interface DateOption {
value: string;
label: string;
date: Date;
keywords: string;
}
const addDays = (date: Date, days: number) => new Date(date.getFullYear(), date.getMonth(), date.getDate() + days);
/** Dates relative to today: tomorrow, the end of the week (Sunday), in a week, the end of the month, in a month. */
export function dateOptions(today = new Date()): DateOption[] {
const endOfWeek = addDays(today, (7 - today.getDay()) % 7 || 7);
const endOfMonth = new Date(today.getFullYear(), today.getMonth() + 1, 0);
const inMonth = new Date(today.getFullYear(), today.getMonth() + 1, today.getDate());
return [
{ value: 'tomorrow', label: 'Tomorrow', date: addDays(today, 1), keywords: 'next day due date' },
{ value: 'end-of-week', label: 'End of week', date: endOfWeek, keywords: 'sunday week close target' },
{ value: 'in-one-week', label: 'In one week', date: addDays(today, 7), keywords: 'next week seven days' },
{ value: 'end-of-month', label: 'End of month', date: endOfMonth, keywords: 'month close month end' },
{ value: 'in-one-month', label: 'In one month', date: inMonth, keywords: 'next month thirty days' },
];
}
/** `2026-10-08`: the format of `wds-calendar`. */
export const toIso = (date: Date) =>
`${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}-${String(date.getDate()).padStart(2, '0')}`;
export const fromIso = (iso: string) => {
const [y, m, d] = iso.split('-').map(Number);
return new Date(y, m - 1, d);
};
/** `Oct 8` */
export const shortDate = (date: Date) => date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
/** `08/10/2026` */
export const numericDate = (date: Date) => date.toLocaleDateString('en-GB');Labels#
value slot; “No labels” clears the selection.
import { Component, computed, signal } from '@angular/core';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/tag';
const LABELS = [
{ value: 'bug', name: 'Bug', color: 'text-red-500' },
{ value: 'feature', name: 'Feature', color: 'text-violet-500' },
{ value: 'improvement', name: 'Improvement', color: 'text-sky-500' },
{ value: 'documentation', name: 'Documentation', color: 'text-emerald-500' },
{ value: 'design', name: 'Design', color: 'text-amber-500' },
];
@Component({
selector: 'app-combobox-labels-demo',
host: { class: 'flex w-full justify-center' },
imports: [WdsIconComponent, ...WDS_COMBOBOX],
template: `
<wds-combobox
class="w-full max-w-xs"
trigger="button"
multiple
aria-label="Labels"
search-placeholder="Select labels"
empty-text="No labels found."
auto-highlight
[values]="values()"
(wdsChange)="change($event.values)"
>
<span slot="value" class="flex min-w-0 items-center gap-2">
@if (selected().length === 0) {
<wds-icon name="lucide-tag" class="size-4 text-muted-foreground"></wds-icon>
<span class="text-muted-foreground">Add label</span>
} @else {
<span class="flex -space-x-1.5">
@for (label of selected(); track label.value) {
<svg data-wds-graphic class="size-4 {{ label.color }}" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="4" fill="currentColor" stroke="var(--wds-background)" stroke-width="2" /></svg>
}
</span>
<span class="truncate">{{ selected().length === 1 ? selected()[0].name : selected().length + ' labels' }}</span>
}
</span>
<wds-combobox-item value="none" keywords="clear remove empty">
<wds-icon name="lucide-tag" class="text-muted-foreground"></wds-icon>No labels
</wds-combobox-item>
<wds-combobox-separator />
@for (label of labels; track label.value) {
<wds-combobox-item [value]="label.value">
<svg data-wds-graphic [class]="label.color" viewBox="0 0 16 16" aria-hidden="true"><circle cx="8" cy="8" r="4" fill="currentColor" /></svg>{{ label.name }}
</wds-combobox-item>
}
</wds-combobox>
`,
})
export class ComboboxLabelsDemo {
protected readonly labels = LABELS;
protected readonly values = signal(['bug', 'design']);
protected readonly selected = computed(() => LABELS.filter((l) => this.values().includes(l.value)));
protected change(values: string[]): void {
// "No labels" clears the selection.
this.values.set(values.includes('none') ? [] : values);
}
}Team#
keywords lets the search find a team by what it does.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent, WdsComboboxSeparatorComponent } from '@wds/angular/combobox';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/users';
@Component({
selector: 'app-combobox-team-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent, WdsComboboxSeparatorComponent, WdsIconComponent],
template: `
<wds-combobox class="w-full max-w-xs" trigger="button" aria-label="Team" placeholder="Set team" search-placeholder="Change team..." empty-text="No teams found." auto-highlight>
<wds-combobox-item value="none" keywords="clear remove empty"><wds-icon name="lucide-users" class="text-muted-foreground"></wds-icon>No team</wds-combobox-item>
<wds-combobox-separator></wds-combobox-separator>
<wds-combobox-item value="testo-growth" keywords="experiments lifecycle activation"><svg data-wds-graphic class="text-lime-600" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="2" y="2" width="12" height="12" rx="3" fill="currentColor" /></svg>Testo Growth</wds-combobox-item>
<wds-combobox-item value="atlas-platform" keywords="infrastructure systems"><svg data-wds-graphic class="text-sky-600" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="2" y="2" width="12" height="12" rx="3" fill="currentColor" /></svg>Atlas Platform</wds-combobox-item>
<wds-combobox-item value="nova-studio" keywords="design systems creative" selected><svg data-wds-graphic class="text-violet-600" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="2" y="2" width="12" height="12" rx="3" fill="currentColor" /></svg>Nova Studio</wds-combobox-item>
<wds-combobox-item value="pulse-support" keywords="product health customer care"><svg data-wds-graphic class="text-rose-600" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="2" y="2" width="12" height="12" rx="3" fill="currentColor" /></svg>Pulse Support</wds-combobox-item>
<wds-combobox-item value="orbit-ops" keywords="operations dependencies releases"><svg data-wds-graphic class="text-amber-600" viewBox="0 0 16 16" fill="none" aria-hidden="true"><rect x="2" y="2" width="12" height="12" rx="3" fill="currentColor" /></svg>Orbit Ops</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxTeamDemo {}Assignee#
import { Component, signal } from '@angular/core';
import { WDS_AVATAR } from '@wds/angular/avatar';
import { WDS_COMBOBOX, type WdsComboboxComponent } from '@wds/angular/combobox';
import { toast } from '@wds/angular/toast';
import { MEMBERS } from './members';
import { WdsIconComponent } from '@wds/angular/icon';
import '@wds/core/icons/lucide/user-plus';
import '@wds/core/icons/lucide/user-round';
@Component({
selector: 'app-combobox-assignee-demo',
host: { class: 'flex w-full justify-center' },
imports: [WdsIconComponent, ...WDS_COMBOBOX, ...WDS_AVATAR],
template: `
<wds-combobox
#combobox
class="w-full max-w-xs"
trigger="button"
aria-label="Assignee"
placeholder="Assign"
search-placeholder="Assign to..."
empty-text="No people found."
auto-highlight
[value]="value()"
(wdsChange)="change($event.value, combobox)"
>
<wds-combobox-item value="none" keywords="unassigned clear remove">
<wds-icon name="lucide-user-round" class="text-muted-foreground"></wds-icon>No assignee
</wds-combobox-item>
<wds-combobox-separator />
@for (member of members; track member.value) {
<wds-combobox-item [value]="member.value" [label]="member.name">
<wds-avatar size="sm" [src]="member.avatar" aria-hidden="true">{{ member.initials }}</wds-avatar>
{{ member.name }}
@if (member.you) {
<span class="text-muted-foreground">(you)</span>
}
</wds-combobox-item>
}
<wds-combobox-separator />
<wds-combobox-item value="invite" keywords="add new teammate email">
<wds-icon name="lucide-user-plus" class="text-muted-foreground"></wds-icon>Invite...
</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxAssigneeDemo {
protected readonly members = MEMBERS;
protected readonly value = signal('alex-morgan');
protected change(value: string, combobox: WdsComboboxComponent): void {
// "Invite..." is an action, not a value: the assignee stays the same.
if (value === 'invite') {
combobox.value = this.value();
toast('Invitation link copied to the clipboard.');
return;
}
this.value.set(value);
}
}export interface Member {
value: string;
name: string;
initials: string;
avatar: string;
you?: boolean;
}
const photo = (id: string) => `https://images.unsplash.com/photo-${id}?w=96&h=96&dpr=2&q=80`;
export const MEMBERS: Member[] = [
{ value: 'alex-morgan', name: 'Alex Morgan', initials: 'AM', avatar: photo('1500648767791-00dcc994a43e'), you: true },
{ value: 'emma-carter', name: 'Emma Carter', initials: 'EC', avatar: photo('1494790108377-be9c29b29330') },
{ value: 'ryan-mitchell', name: 'Ryan Mitchell', initials: 'RM', avatar: photo('1506794778202-cad84cf45f1d') },
{ value: 'olivia-bennett', name: 'Olivia Bennett', initials: 'OB', avatar: photo('1517841905240-472988babdf9') },
{ value: 'ethan-brooks', name: 'Ethan Brooks', initials: 'EB', avatar: photo('1504593811423-6dd665756598') },
];Keywords#
keywords adds words that match without being shown: type “dollar” or “£”. The search ignores case and diacritics.
import { Component } from '@angular/core';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-keywords-demo',
imports: [WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-combobox class="w-full max-w-xs" aria-label="Currency" placeholder="Select currency…" empty-text="No currency found.">
<wds-combobox-item value="PLN" keywords="zloty zł">Polish złoty (PLN)</wds-combobox-item>
<wds-combobox-item value="EUR" keywords="€">Euro (EUR)</wds-combobox-item>
<wds-combobox-item value="USD" keywords="dollar $ usa">US dollar (USD)</wds-combobox-item>
<wds-combobox-item value="GBP" keywords="pound sterling £">British pound (GBP)</wds-combobox-item>
<wds-combobox-item value="CHF" keywords="franc">Swiss franc (CHF)</wds-combobox-item>
</wds-combobox>
`,
})
export class ComboboxKeywordsDemo {}Field#
wds-field the label and the description become the accessible name and description of the combobox.
import { Component } from '@angular/core';
import { WdsFieldComponent, WdsFieldDescriptionComponent, WdsFieldLabelComponent } from '@wds/angular/field';
import { WdsComboboxComponent, WdsComboboxItemComponent } from '@wds/angular/combobox';
@Component({
selector: 'app-combobox-field-demo',
imports: [WdsFieldComponent, WdsFieldLabelComponent, WdsFieldDescriptionComponent, WdsComboboxComponent, WdsComboboxItemComponent],
template: `
<wds-field class="w-full max-w-xs">
<wds-field-label>Country</wds-field-label>
<wds-combobox class="w-full" placeholder="Select country…" empty-text="No country found.">
<wds-combobox-item value="pl">Poland</wds-combobox-item>
<wds-combobox-item value="de">Germany</wds-combobox-item>
<wds-combobox-item value="cz">Czechia</wds-combobox-item>
<wds-combobox-item value="sk">Slovakia</wds-combobox-item>
</wds-combobox>
<wds-field-description>We ship to these countries only.</wds-field-description>
</wds-field>
`,
})
export class ComboboxFieldDemo {}Server search#
filter="none" the combobox does not filter by itself: it fires wds-search and the app replaces the options (here a simulated 400 ms request). The empty slot shows the loading state and the message when nothing matches.
import { Component, signal } from '@angular/core';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { WdsSpinnerComponent } from '@wds/angular/spinner';
const CITIES = [
'Amsterdam', 'Athens', 'Barcelona', 'Berlin', 'Brussels', 'Budapest', 'Copenhagen', 'Dublin', 'Helsinki', 'Kraków',
'Lisbon', 'London', 'Madrid', 'Milan', 'Munich', 'Oslo', 'Paris', 'Prague', 'Rome', 'Stockholm', 'Vienna', 'Warsaw',
];
/** Simulates a request to a server. */
const fetchCities = (query: string) =>
new Promise<string[]>((resolve) =>
setTimeout(() => resolve(CITIES.filter((c) => c.toLowerCase().includes(query.trim().toLowerCase())).slice(0, 8)), 400)
);
@Component({
selector: 'app-combobox-server-search-demo',
host: { class: 'flex w-full justify-center' },
imports: [...WDS_COMBOBOX, WdsSpinnerComponent],
template: `
<wds-combobox
class="w-full max-w-xs"
aria-label="City"
filter="none"
placeholder="Type a city name…"
(wdsSearch)="search($event.query)"
>
@for (city of results(); track city) {
<wds-combobox-item [value]="city">{{ city }}</wds-combobox-item>
}
<span slot="empty">
@if (loading()) {
<span class="inline-flex items-center gap-2 text-muted-foreground"><wds-spinner decorative size="sm" />Searching…</span>
} @else {
No city matches “{{ query() }}”.
}
</span>
</wds-combobox>
`,
})
export class ComboboxServerSearchDemo {
protected readonly query = signal('');
protected readonly loading = signal(false);
protected readonly results = signal(CITIES.slice(0, 8));
private request = 0;
protected async search(query: string): Promise<void> {
const id = ++this.request;
this.query.set(query);
this.loading.set(true);
this.results.set([]);
const cities = await fetchCities(query);
// Only the latest request updates the list.
if (id !== this.request) return;
this.results.set(cities);
this.loading.set(false);
}
}Forms#
Integration with Angular forms. Pick the API your app uses.
Signal forms#
WdsSelectField connects wds-combobox to [formField]; the value is a string (string[] with multiple).
import { Component, computed, signal } from '@angular/core';
import { FormField, FormRoot, form, required } from '@angular/forms/signals';
import { WdsButtonComponent } from '@wds/angular/button';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { WDS_FIELD } from '@wds/angular/field';
import { WdsSelectField } from '@wds/angular/forms';
@Component({
selector: 'app-combobox-signal-forms-demo',
imports: [...WDS_COMBOBOX, ...WDS_FIELD, FormField, FormRoot, WdsButtonComponent, WdsSelectField],
template: `
<form class="flex w-sm max-w-full flex-col gap-4" [formRoot]="taskForm">
<wds-field [invalid]="showAssigneeError()">
<wds-field-label>Assignee</wds-field-label>
<wds-combobox class="w-full" placeholder="Select person…" empty-text="No person found." [formField]="taskForm.assignee">
<wds-combobox-item value="anna">Anna Smith</wds-combobox-item>
<wds-combobox-item value="john">John Carter</wds-combobox-item>
<wds-combobox-item value="maria">Maria Garcia</wds-combobox-item>
<wds-combobox-item value="wei">Wei Chen</wds-combobox-item>
</wds-combobox>
<wds-field-error [errors]="showAssigneeError() ? taskForm.assignee().errors() : []" />
</wds-field>
<wds-button type="submit" class="self-start">Submit</wds-button>
<p class="m-0 font-mono text-sm text-muted-foreground">Submitted: {{ submitted() }}</p>
</form>
`,
})
export class ComboboxSignalFormsDemo {
protected readonly task = signal({ assignee: '' });
protected readonly submitted = signal('—');
protected readonly taskForm = form(
this.task,
(path) => {
required(path.assignee, { message: 'Select a person.' });
},
{
submission: {
action: async (form) => {
this.submitted.set(JSON.stringify(form().value()));
},
},
}
);
/** The error appears after the user leaves the field or submits the form. */
protected readonly showAssigneeError = computed(() => this.taskForm.assignee().touched() && this.taskForm.assignee().invalid());
}Template-driven#
WdsSelectValueAccessor makes ngModel work on wds-combobox.
import { Component, signal } from '@angular/core';
import { FormsModule, type NgForm } from '@angular/forms';
import { WdsButtonComponent } from '@wds/angular/button';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { WDS_FIELD } from '@wds/angular/field';
import { WdsSelectValueAccessor } from '@wds/angular/forms';
@Component({
selector: 'app-combobox-template-driven-demo',
imports: [...WDS_COMBOBOX, ...WDS_FIELD, FormsModule, WdsButtonComponent, WdsSelectValueAccessor],
template: `
<form #taskForm="ngForm" class="flex w-sm max-w-full flex-col gap-4" (ngSubmit)="save(taskForm)">
<wds-field [invalid]="!!assignee.invalid && !!assignee.touched">
<wds-field-label>Assignee</wds-field-label>
<wds-combobox
#assignee="ngModel"
class="w-full"
name="assignee"
placeholder="Select person…"
empty-text="No person found."
[(ngModel)]="task.assignee"
required
>
<wds-combobox-item value="anna">Anna Smith</wds-combobox-item>
<wds-combobox-item value="john">John Carter</wds-combobox-item>
<wds-combobox-item value="maria">Maria Garcia</wds-combobox-item>
<wds-combobox-item value="wei">Wei Chen</wds-combobox-item>
</wds-combobox>
@if (assignee.invalid && assignee.touched) {
<wds-field-error>Select a person.</wds-field-error>
}
</wds-field>
<wds-button type="submit" class="self-start">Submit</wds-button>
<p class="m-0 font-mono text-sm text-muted-foreground">Submitted: {{ submitted() }}</p>
</form>
`,
})
export class ComboboxTemplateDrivenDemo {
protected readonly task = { assignee: '' };
protected readonly submitted = signal('—');
protected save(form: NgForm): void {
if (form.invalid) {
form.form.markAllAsTouched();
return;
}
this.submitted.set(JSON.stringify(form.value));
}
}Reactive forms#
WdsSelectValueAccessor works with formControl and formControlName.
import { Component, signal } from '@angular/core';
import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms';
import { WdsButtonComponent } from '@wds/angular/button';
import { WDS_COMBOBOX } from '@wds/angular/combobox';
import { WDS_FIELD } from '@wds/angular/field';
import { WdsSelectValueAccessor } from '@wds/angular/forms';
@Component({
selector: 'app-combobox-reactive-forms-demo',
imports: [...WDS_COMBOBOX, ...WDS_FIELD, ReactiveFormsModule, WdsButtonComponent, WdsSelectValueAccessor],
template: `
<form class="flex w-sm max-w-full flex-col gap-4" [formGroup]="taskForm" (ngSubmit)="save()">
<wds-field [invalid]="assignee.invalid && assignee.touched">
<wds-field-label>Assignee</wds-field-label>
<wds-combobox class="w-full" placeholder="Select person…" empty-text="No person found." formControlName="assignee">
<wds-combobox-item value="anna">Anna Smith</wds-combobox-item>
<wds-combobox-item value="john">John Carter</wds-combobox-item>
<wds-combobox-item value="maria">Maria Garcia</wds-combobox-item>
<wds-combobox-item value="wei">Wei Chen</wds-combobox-item>
</wds-combobox>
@if (assignee.invalid && assignee.touched) {
<wds-field-error>Select a person.</wds-field-error>
}
</wds-field>
<wds-button type="submit" class="self-start">Submit</wds-button>
<p class="m-0 font-mono text-sm text-muted-foreground">Submitted: {{ submitted() }}</p>
</form>
`,
})
export class ComboboxReactiveFormsDemo {
protected readonly taskForm = new FormGroup({
assignee: new FormControl('', { nonNullable: true, validators: [Validators.required] }),
});
protected readonly assignee = this.taskForm.controls.assignee;
protected readonly submitted = signal('—');
protected save(): void {
if (this.taskForm.invalid) {
this.taskForm.markAllAsTouched();
return;
}
this.submitted.set(JSON.stringify(this.taskForm.getRawValue()));
}
}API References#
wds-combobox#
aria-activedescendant points to the highlighted one.
With trigger="button" the field is a button that opens a panel (role="dialog") with a search field,
for pickers whose value is more than text (status, assignee, labels).
multiple selects several options, shown as removable chips (or badges with trigger="button").
Works in a form like <select>: name, required, and a reset restores the options with selected.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| value | string | '' | multiple mode the first of values). |
| multiple | boolean | false | |
| trigger | WdsComboboxTrigger | 'input' | input: a text field to type in. button: a button that opens a panel with a search field. |
| variant | WdsComboboxVariant | 'default' | ghost: no border and background (e.g. inline tags in a chat or a task). |
| placeholder | string | '' | |
| search-placeholder.searchPlaceholder | string | '' | trigger="button"). Empty: built-in text (common.searchPlaceholder). |
| empty-text.emptyText | string | '' | empty slot takes precedence. Empty: built-in text (combobox.empty). |
| filter | WdsComboboxFilter | 'auto' | auto filters the options by their text. none leaves filtering to the app
(e.g. results from a server after wds-search). |
| auto-highlight.autoHighlight | boolean | false | |
| show-clear.showClear | boolean | false | |
| clear-label.clearLabel | string | '' | common.clear). |
| remove-label.removeLabel | string | '' | common.remove). |
| max-label-count.maxLabelCount | number | 2 | multiple with trigger="button": how many selected options to show as badges, the rest as "+N". 0 = all. |
| name | string | '' | |
| disabled | boolean | false | |
| required | boolean | false | valueMissing when empty). |
| invalid | boolean | false | aria-invalid). |
| open | boolean | false | |
| icon-start.iconStart | string | undefined | trigger="input"): the name of a registered icon, e.g. lucide-search
(after import '@wds/core/icons/lucide/search'). The start slot takes your own content instead. |
Properties
| Property | Description |
|---|---|
| valuesstring[] | multiple mode). |
Events
| Event | Description |
|---|---|
| wds-open-changeCustomEvent<WdsComboboxOpenChangeDetail> | |
| wds-changeCustomEvent<WdsComboboxChangeDetail> | |
| wds-searchCustomEvent<WdsComboboxSearchDetail> |
Methods
| Method | Description |
|---|---|
| show() | |
| close() | |
| formResetCallback() | |
| formDisabledCallback(disabled: boolean) | |
| checkValidity() | true when the value is valid; otherwise fires invalid on the element. |
| reportValidity() | checkValidity(), and shows the browser validation bubble when the value is invalid. |
| setCustomValidity(message: string) | input.setCustomValidity(). |
Slots
| Slot | Description |
|---|---|
| (default) | wds-combobox-item, wds-combobox-group, wds-combobox-separator. |
| start | trigger="input") instead of icon-start. |
| icon | |
| value | trigger="button" (e.g. avatars of the selected people). |
| empty | empty-text), e.g. a spinner while loading. |
CSS parts (::part)
| Part | Description |
|---|---|
| field | trigger="button". |
| input | trigger="button"). |
| value | trigger="button"). |
| chip | multiple mode. |
| content | |
| list | |
| empty |
CSS custom properties
| Property | Description |
|---|---|
| --wds-combobox-list-height |
wds-combobox-item#
wds-combobox (role="option"). The selected attribute marks the default selection.
A direct child <svg>, <img>, wds-avatar or wds-icon is also shown next to the text in the field and in chips.
Attributes
| Attribute | Type | Default | Description |
|---|---|---|---|
| keywords | string | '' | |
| locked | boolean | false | multiple mode: the selected option cannot be removed (its chip has no remove button). |
| value | string | '' | |
| label | string | undefined | ||
| disabled | boolean | false | |
| icon-start.iconStart | string | undefined | lucide-globe (after import '@wds/core/icons/lucide/globe'). | |
| icon-end.iconEnd | string | undefined |
Properties
| Property | Description |
|---|---|
| selectedboolean | wds-select sets it; the default selection is the selected attribute. |
Slots
| Slot | Description |
|---|---|
| (default) |
CSS parts (::part)
| Part | Description |
|---|---|
| indicator | |
| icon-start | icon-start). |
| icon-end | icon-end). |
| base |
wds-combobox-group#
wds-combobox options (role="group") named by its wds-combobox-label.
It hides when none of its options match the search.
Slots
| Slot | Description |
|---|---|
| (default) | wds-combobox-label and wds-combobox-item. |
wds-combobox-label#
wds-combobox-group.
Slots
| Slot | Description |
|---|---|
| (default) |
CSS parts (::part)
| Part | Description |
|---|---|
| base |
wds-combobox-separator#
CSS parts (::part)
| Part | Description |
|---|---|
| base |
Accessibility#
Screen reader#
<input> with role="combobox", aria-autocomplete="list" and aria-expanded (WAI-ARIA combobox with list autocomplete). Focus stays in it; aria-activedescendant points to the highlighted option. Give it a name: wds-field-label in wds-field, or aria-label on the element. The placeholder is not a name.
trigger="button" the field is a <button> with aria-haspopup="dialog", named by the label and the selected value. The panel is a role="dialog" with a search field (role="combobox") that controls the list; focus moves to it on open and returns to the button on Escape or after a pick.
role="option" with aria-selected; with multiple the list has aria-multiselectable. wds-combobox-group has role="group" named by its wds-combobox-label; separators, check marks and the icons copied into the field are hidden from screen readers.
remove-label + option text”; a removed chip is announced in a role="status" region. The clear button is named by clear-label. Both are skipped by Tab: Backspace removes chips and an empty field clears the value.
empty-text or the empty slot) is a role="status" region, so it is announced.
invalid and required set aria-invalid and aria-required. In a form the value is submitted under name (one entry per value with multiple), and a reset restores the options with selected.
Keyboard support#
| Key | Function |
|---|---|
multiple the list stays open; otherwise it closes. | |
multiple, empty field: removes the last chip that is not locked. | |
multiple: from the start of the field moves between the chips; Backspace or Delete removes the focused chip. | |
trigger="button", on the button: opens the panel with the search field. |