- Accordion
- Alert
- Alert Dialog
- Aspect Ratio
- Autocomplete
- Avatar
- Badge
- Breadcrumb
- Button
- Button Group
- Calendar
- Card
- Carousel
- Checkbox
- Collapsible
- Combobox
- Command
- Context Menu
- Data Table
- Date Picker
- Dialog
- Dropdown Menu
- Empty
- Field
- Form Field
- Hover Card
- Icon
- Input Group
- Input OTP
- Input
- Item
- Kbd
- Label
- Menubar
- Navigation Menu
- Pagination
- Popover
- Progress
- Radio Group
- Resizable
- Scroll Area
- Select
- Separator
- Sheet
- Sidebar
- Skeleton
- Slider
- Sonner (Toast)
- Spinner
- Switch
- Table
- Tabs
- Textarea
- Toggle
- Toggle Group
- Tooltip
Combobox
An input combined with a list of predefined items to select.
import { Component } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
template: `
<hlm-combobox>
<hlm-combobox-input placeholder="Select a framework"></hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework.label }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox>
`,
})
export class ComboboxPreview {
public frameworks = [
{
label: 'AnalogJs',
value: 'analogjs',
},
{
label: 'Angular',
value: 'angular',
},
{
label: 'Vue',
value: 'vue',
},
{
label: 'Nuxt',
value: 'nuxt',
},
{
label: 'React',
value: 'react',
},
{
label: 'NextJs',
value: 'nextjs',
},
];
}
export const comboboxDefaultConfig = `
import { comboboxContainsFilter, provideBrnComboboxConfig } from '@spartan-ng/brain/combobox';
provideBrnComboboxConfig({
filterOptions: {
usage: 'search',
sensitivity: 'base',
ignorePunctuation: true,
},
filter: (itemValue: T, search: string, collator: Intl.Collator, itemToString?: ComboboxItemToString<T>) =>
comboboxContainsFilter(itemValue, search, collator, itemToString),
isItemEqualToValue: (itemValue: T, selectedValue: T | null) => Object.is(itemValue, selectedValue),
itemToString: undefined,
});
`;Installation
ng g @spartan-ng/cli:ui combobox
npx nx g @spartan-ng/cli:ui combobox
Usage
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';<hlm-combobox>
<hlm-combobox-input placeholder="Select a framework"></hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework.label }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox>Configuration
The combobox can be configured via provideBrnComboboxConfig or by passing the individual config as input. This is the default combobox config:
import { comboboxContainsFilter, provideBrnComboboxConfig } from '@spartan-ng/brain/combobox';
provideBrnComboboxConfig({
filterOptions: {
usage: 'search',
sensitivity: 'base',
ignorePunctuation: true,
},
filter: (itemValue: T, search: string, collator: Intl.Collator, itemToString?: ComboboxItemToString<T>) =>
comboboxContainsFilter(itemValue, search, collator, itemToString),
isItemEqualToValue: (itemValue: T, selectedValue: T | null) => Object.is(itemValue, selectedValue),
itemToString: undefined,
});Filter
The combobox matches items using Intl.Collator for robust string comparison. The filterOptions accepts all Intl.CollatorOptions , plus a locale .
The default filter implementation uses a comboboxContainsFilter to check if the item value contains the search string. Provide a custom filter function for other filtering behavior.
Built-in combobox filters are:
comboboxContainsFilter- Returns true if the item value contains the search string.comboboxStartsWithFilter- Returns true if the item value starts with the search string.comboboxEndsWithFilter- Returns true if the item value ends with the search string.
Objects
The combobox works out of the box with string values and objects in the shape of { label: string; value: string; } , the label (1) or the value (2) will be used automatically. For other object shapes provide a custom itemToString function to extract the label from the object.
Provide a custom isItemEqualToValue function to determine if a combobox item value matches the current selected value. Defaults to Object.is comparison.
Examples
With Clear Button
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-clear-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox>
<hlm-combobox-input placeholder="Select a framework" showClear></hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox>
`,
})
export class ComboboxClearPreview {
public frameworks = ['Analog', 'Angular', 'Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro'];
}Disabled
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-disabled-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox disabled>
<hlm-combobox-input placeholder="Select a framework" showClear></hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox>
`,
})
export class ComboboxDisabledPreview {
public frameworks = ['Analog', 'Angular', 'Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro'];
}With Groups
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-group-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox>
<hlm-combobox-input placeholder="Select a timezone"></hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (timezoneGroup of timezones; track $index) {
<div hlmComboboxGroup>
<div hlmComboboxLabel>{{ timezoneGroup.value }}</div>
@for (timezone of timezoneGroup.items; track $index) {
<hlm-combobox-item [value]="timezone">{{ timezone }}</hlm-combobox-item>
}
</div>
}
</div>
</div>
</hlm-combobox>
`,
})
export class ComboboxGroupPreview {
public timezones = [
{
value: 'Americas',
items: [
'(GMT-5) New York',
'(GMT-8) Los Angeles',
'(GMT-6) Chicago',
'(GMT-5) Toronto',
'(GMT-8) Vancouver',
'(GMT-3) São Paulo',
],
},
{
value: 'Europe',
items: [
'(GMT+0) London',
'(GMT+1) Paris',
'(GMT+1) Berlin',
'(GMT+1) Rome',
'(GMT+1) Madrid',
'(GMT+1) Amsterdam',
],
},
{
value: 'Asia/Pacific',
items: [
'(GMT+9) Tokyo',
'(GMT+8) Shanghai',
'(GMT+8) Singapore',
'(GMT+4) Dubai',
'(GMT+11) Sydney',
'(GMT+9) Seoul',
],
},
];
}With Groups and Separators
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-group-separator-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox>
<hlm-combobox-input placeholder="Select a timezone"></hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (timezoneGroup of timezones; track $index) {
<div hlmComboboxGroup>
<div hlmComboboxLabel>{{ timezoneGroup.value }}</div>
@for (timezone of timezoneGroup.items; track $index) {
<hlm-combobox-item [value]="timezone">{{ timezone }}</hlm-combobox-item>
}
<div hlmComboboxSeparator></div>
</div>
}
</div>
</div>
</hlm-combobox>
`,
})
export class ComboboxGroupSeparatorPreview {
public timezones = [
{
value: 'Americas',
items: [
'(GMT-5) New York',
'(GMT-8) Los Angeles',
'(GMT-6) Chicago',
'(GMT-5) Toronto',
'(GMT-8) Vancouver',
'(GMT-3) São Paulo',
],
},
{
value: 'Europe',
items: [
'(GMT+0) London',
'(GMT+1) Paris',
'(GMT+1) Berlin',
'(GMT+1) Rome',
'(GMT+1) Madrid',
'(GMT+1) Amsterdam',
],
},
{
value: 'Asia/Pacific',
items: [
'(GMT+9) Tokyo',
'(GMT+8) Shanghai',
'(GMT+8) Singapore',
'(GMT+4) Dubai',
'(GMT+11) Sydney',
'(GMT+9) Seoul',
],
},
];
}With Icon Addon
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { NgIcon, provideIcons } from '@ng-icons/core';
import { lucideGlobe } from '@ng-icons/lucide';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
import { HlmInputGroupAddon } from '@spartan-ng/helm/input-group';
@Component({
selector: 'spartan-combobox-icon-addon-preview',
imports: [HlmComboboxImports, BrnPopoverContent, HlmInputGroupAddon, NgIcon],
providers: [provideIcons({ lucideGlobe })],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox>
<hlm-combobox-input placeholder="Select a timezone">
<hlm-input-group-addon>
<ng-icon name="lucideGlobe" />
</hlm-input-group-addon>
</hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (timezoneGroup of timezones; track $index) {
<div hlmComboboxGroup>
<div hlmComboboxLabel>{{ timezoneGroup.value }}</div>
@for (timezone of timezoneGroup.items; track $index) {
<hlm-combobox-item [value]="timezone">{{ timezone }}</hlm-combobox-item>
}
<div hlmComboboxSeparator></div>
</div>
}
</div>
</div>
</hlm-combobox>
`,
})
export class ComboboxIconAddonPreview {
public timezones = [
{
value: 'Americas',
items: [
'(GMT-5) New York',
'(GMT-8) Los Angeles',
'(GMT-6) Chicago',
'(GMT-5) Toronto',
'(GMT-8) Vancouver',
'(GMT-3) São Paulo',
],
},
{
value: 'Europe',
items: [
'(GMT+0) London',
'(GMT+1) Paris',
'(GMT+1) Berlin',
'(GMT+1) Rome',
'(GMT+1) Madrid',
'(GMT+1) Amsterdam',
],
},
{
value: 'Asia/Pacific',
items: [
'(GMT+9) Tokyo',
'(GMT+8) Shanghai',
'(GMT+8) Singapore',
'(GMT+4) Dubai',
'(GMT+11) Sydney',
'(GMT+9) Seoul',
],
},
];
}Popup
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-popup-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox [value]="countries[0]" autoFocus="first-tabbable">
<hlm-combobox-trigger class="w-64 justify-between font-normal">
<span hlmComboboxValue></span>
</hlm-combobox-trigger>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-input showTrigger="false" mode="popup" placeholder="Search"></hlm-combobox-input>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (country of countries; track country.code) {
<hlm-combobox-item [value]="country">{{ country.label }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox>
`,
})
export class ComboboxPopupPreview {
public countries = [
{ code: '', value: '', continent: '', label: 'Select country' },
{ code: 'af', value: 'afghanistan', label: 'Afghanistan', continent: 'Asia' },
{ code: 'al', value: 'albania', label: 'Albania', continent: 'Europe' },
{ code: 'dz', value: 'algeria', label: 'Algeria', continent: 'Africa' },
{ code: 'ad', value: 'andorra', label: 'Andorra', continent: 'Europe' },
{ code: 'ao', value: 'angola', label: 'Angola', continent: 'Africa' },
{
code: 'ar',
value: 'argentina',
label: 'Argentina',
continent: 'South America',
},
{ code: 'am', value: 'armenia', label: 'Armenia', continent: 'Asia' },
{ code: 'au', value: 'australia', label: 'Australia', continent: 'Oceania' },
{ code: 'at', value: 'austria', label: 'Austria', continent: 'Europe' },
{ code: 'az', value: 'azerbaijan', label: 'Azerbaijan', continent: 'Asia' },
{
code: 'bs',
value: 'bahamas',
label: 'Bahamas',
continent: 'North America',
},
{ code: 'bh', value: 'bahrain', label: 'Bahrain', continent: 'Asia' },
{ code: 'bd', value: 'bangladesh', label: 'Bangladesh', continent: 'Asia' },
{
code: 'bb',
value: 'barbados',
label: 'Barbados',
continent: 'North America',
},
{ code: 'by', value: 'belarus', label: 'Belarus', continent: 'Europe' },
{ code: 'be', value: 'belgium', label: 'Belgium', continent: 'Europe' },
{ code: 'bz', value: 'belize', label: 'Belize', continent: 'North America' },
{ code: 'bj', value: 'benin', label: 'Benin', continent: 'Africa' },
{ code: 'bt', value: 'bhutan', label: 'Bhutan', continent: 'Asia' },
{
code: 'bo',
value: 'bolivia',
label: 'Bolivia',
continent: 'South America',
},
{
code: 'ba',
value: 'bosnia-and-herzegovina',
label: 'Bosnia and Herzegovina',
continent: 'Europe',
},
{ code: 'bw', value: 'botswana', label: 'Botswana', continent: 'Africa' },
{ code: 'br', value: 'brazil', label: 'Brazil', continent: 'South America' },
{ code: 'bn', value: 'brunei', label: 'Brunei', continent: 'Asia' },
{ code: 'bg', value: 'bulgaria', label: 'Bulgaria', continent: 'Europe' },
{
code: 'bf',
value: 'burkina-faso',
label: 'Burkina Faso',
continent: 'Africa',
},
{ code: 'bi', value: 'burundi', label: 'Burundi', continent: 'Africa' },
{ code: 'kh', value: 'cambodia', label: 'Cambodia', continent: 'Asia' },
{ code: 'cm', value: 'cameroon', label: 'Cameroon', continent: 'Africa' },
{ code: 'ca', value: 'canada', label: 'Canada', continent: 'North America' },
{ code: 'cv', value: 'cape-verde', label: 'Cape Verde', continent: 'Africa' },
{
code: 'cf',
value: 'central-african-republic',
label: 'Central African Republic',
continent: 'Africa',
},
{ code: 'td', value: 'chad', label: 'Chad', continent: 'Africa' },
{ code: 'cl', value: 'chile', label: 'Chile', continent: 'South America' },
{ code: 'cn', value: 'china', label: 'China', continent: 'Asia' },
{
code: 'co',
value: 'colombia',
label: 'Colombia',
continent: 'South America',
},
{ code: 'km', value: 'comoros', label: 'Comoros', continent: 'Africa' },
{ code: 'cg', value: 'congo', label: 'Congo', continent: 'Africa' },
{
code: 'cr',
value: 'costa-rica',
label: 'Costa Rica',
continent: 'North America',
},
{ code: 'hr', value: 'croatia', label: 'Croatia', continent: 'Europe' },
{ code: 'cu', value: 'cuba', label: 'Cuba', continent: 'North America' },
{ code: 'cy', value: 'cyprus', label: 'Cyprus', continent: 'Asia' },
{
code: 'cz',
value: 'czech-republic',
label: 'Czech Republic',
continent: 'Europe',
},
{ code: 'dk', value: 'denmark', label: 'Denmark', continent: 'Europe' },
{ code: 'dj', value: 'djibouti', label: 'Djibouti', continent: 'Africa' },
{
code: 'dm',
value: 'dominica',
label: 'Dominica',
continent: 'North America',
},
{
code: 'do',
value: 'dominican-republic',
label: 'Dominican Republic',
continent: 'North America',
},
{
code: 'ec',
value: 'ecuador',
label: 'Ecuador',
continent: 'South America',
},
{ code: 'eg', value: 'egypt', label: 'Egypt', continent: 'Africa' },
{
code: 'sv',
value: 'el-salvador',
label: 'El Salvador',
continent: 'North America',
},
{
code: 'gq',
value: 'equatorial-guinea',
label: 'Equatorial Guinea',
continent: 'Africa',
},
{ code: 'er', value: 'eritrea', label: 'Eritrea', continent: 'Africa' },
{ code: 'ee', value: 'estonia', label: 'Estonia', continent: 'Europe' },
{ code: 'et', value: 'ethiopia', label: 'Ethiopia', continent: 'Africa' },
{ code: 'fj', value: 'fiji', label: 'Fiji', continent: 'Oceania' },
{ code: 'fi', value: 'finland', label: 'Finland', continent: 'Europe' },
{ code: 'fr', value: 'france', label: 'France', continent: 'Europe' },
{ code: 'ga', value: 'gabon', label: 'Gabon', continent: 'Africa' },
{ code: 'gm', value: 'gambia', label: 'Gambia', continent: 'Africa' },
{ code: 'ge', value: 'georgia', label: 'Georgia', continent: 'Asia' },
{ code: 'de', value: 'germany', label: 'Germany', continent: 'Europe' },
{ code: 'gh', value: 'ghana', label: 'Ghana', continent: 'Africa' },
{ code: 'gr', value: 'greece', label: 'Greece', continent: 'Europe' },
{
code: 'gd',
value: 'grenada',
label: 'Grenada',
continent: 'North America',
},
{
code: 'gt',
value: 'guatemala',
label: 'Guatemala',
continent: 'North America',
},
{ code: 'gn', value: 'guinea', label: 'Guinea', continent: 'Africa' },
{
code: 'gw',
value: 'guinea-bissau',
label: 'Guinea-Bissau',
continent: 'Africa',
},
{ code: 'gy', value: 'guyana', label: 'Guyana', continent: 'South America' },
{ code: 'ht', value: 'haiti', label: 'Haiti', continent: 'North America' },
{
code: 'hn',
value: 'honduras',
label: 'Honduras',
continent: 'North America',
},
{ code: 'hu', value: 'hungary', label: 'Hungary', continent: 'Europe' },
{ code: 'is', value: 'iceland', label: 'Iceland', continent: 'Europe' },
{ code: 'in', value: 'india', label: 'India', continent: 'Asia' },
{ code: 'id', value: 'indonesia', label: 'Indonesia', continent: 'Asia' },
{ code: 'ir', value: 'iran', label: 'Iran', continent: 'Asia' },
{ code: 'iq', value: 'iraq', label: 'Iraq', continent: 'Asia' },
{ code: 'ie', value: 'ireland', label: 'Ireland', continent: 'Europe' },
{ code: 'il', value: 'israel', label: 'Israel', continent: 'Asia' },
{ code: 'it', value: 'italy', label: 'Italy', continent: 'Europe' },
{
code: 'jm',
value: 'jamaica',
label: 'Jamaica',
continent: 'North America',
},
{ code: 'jp', value: 'japan', label: 'Japan', continent: 'Asia' },
{ code: 'jo', value: 'jordan', label: 'Jordan', continent: 'Asia' },
{ code: 'kz', value: 'kazakhstan', label: 'Kazakhstan', continent: 'Asia' },
{ code: 'ke', value: 'kenya', label: 'Kenya', continent: 'Africa' },
{ code: 'kw', value: 'kuwait', label: 'Kuwait', continent: 'Asia' },
{ code: 'kg', value: 'kyrgyzstan', label: 'Kyrgyzstan', continent: 'Asia' },
{ code: 'la', value: 'laos', label: 'Laos', continent: 'Asia' },
{ code: 'lv', value: 'latvia', label: 'Latvia', continent: 'Europe' },
{ code: 'lb', value: 'lebanon', label: 'Lebanon', continent: 'Asia' },
{ code: 'ls', value: 'lesotho', label: 'Lesotho', continent: 'Africa' },
{ code: 'lr', value: 'liberia', label: 'Liberia', continent: 'Africa' },
{ code: 'ly', value: 'libya', label: 'Libya', continent: 'Africa' },
{
code: 'li',
value: 'liechtenstein',
label: 'Liechtenstein',
continent: 'Europe',
},
{ code: 'lt', value: 'lithuania', label: 'Lithuania', continent: 'Europe' },
{ code: 'lu', value: 'luxembourg', label: 'Luxembourg', continent: 'Europe' },
{ code: 'mg', value: 'madagascar', label: 'Madagascar', continent: 'Africa' },
{ code: 'mw', value: 'malawi', label: 'Malawi', continent: 'Africa' },
{ code: 'my', value: 'malaysia', label: 'Malaysia', continent: 'Asia' },
{ code: 'mv', value: 'maldives', label: 'Maldives', continent: 'Asia' },
{ code: 'ml', value: 'mali', label: 'Mali', continent: 'Africa' },
{ code: 'mt', value: 'malta', label: 'Malta', continent: 'Europe' },
{
code: 'mh',
value: 'marshall-islands',
label: 'Marshall Islands',
continent: 'Oceania',
},
{ code: 'mr', value: 'mauritania', label: 'Mauritania', continent: 'Africa' },
{ code: 'mu', value: 'mauritius', label: 'Mauritius', continent: 'Africa' },
{ code: 'mx', value: 'mexico', label: 'Mexico', continent: 'North America' },
{
code: 'fm',
value: 'micronesia',
label: 'Micronesia',
continent: 'Oceania',
},
{ code: 'md', value: 'moldova', label: 'Moldova', continent: 'Europe' },
{ code: 'mc', value: 'monaco', label: 'Monaco', continent: 'Europe' },
{ code: 'mn', value: 'mongolia', label: 'Mongolia', continent: 'Asia' },
{ code: 'me', value: 'montenegro', label: 'Montenegro', continent: 'Europe' },
{ code: 'ma', value: 'morocco', label: 'Morocco', continent: 'Africa' },
{ code: 'mz', value: 'mozambique', label: 'Mozambique', continent: 'Africa' },
{ code: 'mm', value: 'myanmar', label: 'Myanmar', continent: 'Asia' },
{ code: 'na', value: 'namibia', label: 'Namibia', continent: 'Africa' },
{ code: 'nr', value: 'nauru', label: 'Nauru', continent: 'Oceania' },
{ code: 'np', value: 'nepal', label: 'Nepal', continent: 'Asia' },
{
code: 'nl',
value: 'netherlands',
label: 'Netherlands',
continent: 'Europe',
},
{
code: 'nz',
value: 'new-zealand',
label: 'New Zealand',
continent: 'Oceania',
},
{
code: 'ni',
value: 'nicaragua',
label: 'Nicaragua',
continent: 'North America',
},
{ code: 'ne', value: 'niger', label: 'Niger', continent: 'Africa' },
{ code: 'ng', value: 'nigeria', label: 'Nigeria', continent: 'Africa' },
{ code: 'kp', value: 'north-korea', label: 'North Korea', continent: 'Asia' },
{
code: 'mk',
value: 'north-macedonia',
label: 'North Macedonia',
continent: 'Europe',
},
{ code: 'no', value: 'norway', label: 'Norway', continent: 'Europe' },
{ code: 'om', value: 'oman', label: 'Oman', continent: 'Asia' },
{ code: 'pk', value: 'pakistan', label: 'Pakistan', continent: 'Asia' },
{ code: 'pw', value: 'palau', label: 'Palau', continent: 'Oceania' },
{ code: 'ps', value: 'palestine', label: 'Palestine', continent: 'Asia' },
{ code: 'pa', value: 'panama', label: 'Panama', continent: 'North America' },
{
code: 'pg',
value: 'papua-new-guinea',
label: 'Papua New Guinea',
continent: 'Oceania',
},
{
code: 'py',
value: 'paraguay',
label: 'Paraguay',
continent: 'South America',
},
{ code: 'pe', value: 'peru', label: 'Peru', continent: 'South America' },
{ code: 'ph', value: 'philippines', label: 'Philippines', continent: 'Asia' },
{ code: 'pl', value: 'poland', label: 'Poland', continent: 'Europe' },
{ code: 'pt', value: 'portugal', label: 'Portugal', continent: 'Europe' },
{ code: 'qa', value: 'qatar', label: 'Qatar', continent: 'Asia' },
{ code: 'ro', value: 'romania', label: 'Romania', continent: 'Europe' },
{ code: 'ru', value: 'russia', label: 'Russia', continent: 'Europe' },
{ code: 'rw', value: 'rwanda', label: 'Rwanda', continent: 'Africa' },
{ code: 'ws', value: 'samoa', label: 'Samoa', continent: 'Oceania' },
{ code: 'sm', value: 'san-marino', label: 'San Marino', continent: 'Europe' },
{
code: 'sa',
value: 'saudi-arabia',
label: 'Saudi Arabia',
continent: 'Asia',
},
{ code: 'sn', value: 'senegal', label: 'Senegal', continent: 'Africa' },
{ code: 'rs', value: 'serbia', label: 'Serbia', continent: 'Europe' },
{ code: 'sc', value: 'seychelles', label: 'Seychelles', continent: 'Africa' },
{
code: 'sl',
value: 'sierra-leone',
label: 'Sierra Leone',
continent: 'Africa',
},
{ code: 'sg', value: 'singapore', label: 'Singapore', continent: 'Asia' },
{ code: 'sk', value: 'slovakia', label: 'Slovakia', continent: 'Europe' },
{ code: 'si', value: 'slovenia', label: 'Slovenia', continent: 'Europe' },
{
code: 'sb',
value: 'solomon-islands',
label: 'Solomon Islands',
continent: 'Oceania',
},
{ code: 'so', value: 'somalia', label: 'Somalia', continent: 'Africa' },
{
code: 'za',
value: 'south-africa',
label: 'South Africa',
continent: 'Africa',
},
{ code: 'kr', value: 'south-korea', label: 'South Korea', continent: 'Asia' },
{
code: 'ss',
value: 'south-sudan',
label: 'South Sudan',
continent: 'Africa',
},
{ code: 'es', value: 'spain', label: 'Spain', continent: 'Europe' },
{ code: 'lk', value: 'sri-lanka', label: 'Sri Lanka', continent: 'Asia' },
{ code: 'sd', value: 'sudan', label: 'Sudan', continent: 'Africa' },
{
code: 'sr',
value: 'suriname',
label: 'Suriname',
continent: 'South America',
},
{ code: 'se', value: 'sweden', label: 'Sweden', continent: 'Europe' },
{
code: 'ch',
value: 'switzerland',
label: 'Switzerland',
continent: 'Europe',
},
{ code: 'sy', value: 'syria', label: 'Syria', continent: 'Asia' },
{ code: 'tw', value: 'taiwan', label: 'Taiwan', continent: 'Asia' },
{ code: 'tj', value: 'tajikistan', label: 'Tajikistan', continent: 'Asia' },
{ code: 'tz', value: 'tanzania', label: 'Tanzania', continent: 'Africa' },
{ code: 'th', value: 'thailand', label: 'Thailand', continent: 'Asia' },
{ code: 'tl', value: 'timor-leste', label: 'Timor-Leste', continent: 'Asia' },
{ code: 'tg', value: 'togo', label: 'Togo', continent: 'Africa' },
{ code: 'to', value: 'tonga', label: 'Tonga', continent: 'Oceania' },
{
code: 'tt',
value: 'trinidad-and-tobago',
label: 'Trinidad and Tobago',
continent: 'North America',
},
{ code: 'tn', value: 'tunisia', label: 'Tunisia', continent: 'Africa' },
{ code: 'tr', value: 'turkey', label: 'Turkey', continent: 'Asia' },
{
code: 'tm',
value: 'turkmenistan',
label: 'Turkmenistan',
continent: 'Asia',
},
{ code: 'tv', value: 'tuvalu', label: 'Tuvalu', continent: 'Oceania' },
{ code: 'ug', value: 'uganda', label: 'Uganda', continent: 'Africa' },
{ code: 'ua', value: 'ukraine', label: 'Ukraine', continent: 'Europe' },
{
code: 'ae',
value: 'united-arab-emirates',
label: 'United Arab Emirates',
continent: 'Asia',
},
{
code: 'gb',
value: 'united-kingdom',
label: 'United Kingdom',
continent: 'Europe',
},
{
code: 'us',
value: 'united-states',
label: 'United States',
continent: 'North America',
},
{
code: 'uy',
value: 'uruguay',
label: 'Uruguay',
continent: 'South America',
},
{ code: 'uz', value: 'uzbekistan', label: 'Uzbekistan', continent: 'Asia' },
{ code: 'vu', value: 'vanuatu', label: 'Vanuatu', continent: 'Oceania' },
{
code: 'va',
value: 'vatican-city',
label: 'Vatican City',
continent: 'Europe',
},
{
code: 've',
value: 'venezuela',
label: 'Venezuela',
continent: 'South America',
},
{ code: 'vn', value: 'vietnam', label: 'Vietnam', continent: 'Asia' },
{ code: 'ye', value: 'yemen', label: 'Yemen', continent: 'Asia' },
{ code: 'zm', value: 'zambia', label: 'Zambia', continent: 'Africa' },
{ code: 'zw', value: 'zimbabwe', label: 'Zimbabwe', continent: 'Africa' },
];
}Form
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmButton } from '@spartan-ng/helm/button';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-form-preview',
imports: [HlmComboboxImports, BrnPopoverContent, ReactiveFormsModule, HlmButton],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<form [formGroup]="form" (ngSubmit)="submit()" class="space-y-8">
<hlm-combobox formControlName="framework">
<hlm-combobox-input placeholder="Select a framework"></hlm-combobox-input>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox>
<button type="submit" hlmBtn [disabled]="form.invalid">Submit</button>
</form>
`,
})
export class ComboboxFormPreview {
private readonly _formBuilder = inject(FormBuilder);
public form = this._formBuilder.group({
framework: new FormControl<string | null>(null),
});
public frameworks = ['Analog', 'Angular', 'Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro'];
submit() {
console.log(this.form.value);
}
}Multiple
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-multiple-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox-multiple [(value)]="values">
<hlm-combobox-chips class="max-w-xs">
<ng-template hlmComboboxValues let-values>
@for (value of values; track $index) {
<hlm-combobox-chip [value]="value">{{ value }}</hlm-combobox-chip>
}
</ng-template>
<input hlmComboboxChipInput />
</hlm-combobox-chips>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox-multiple>
`,
})
export class ComboboxMultiplePreview {
public values = signal(['Angular']);
public frameworks = ['Analog', 'Angular', 'Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro'];
}Multiple Disabled
import { ChangeDetectionStrategy, Component, signal } from '@angular/core';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-multiple-disabled-preview',
imports: [HlmComboboxImports, BrnPopoverContent],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-combobox-multiple [(value)]="values" disabled>
<hlm-combobox-chips class="max-w-xs">
<ng-template hlmComboboxValues let-values>
@for (value of values; track $index) {
<hlm-combobox-chip [value]="value">{{ value }}</hlm-combobox-chip>
}
</ng-template>
<input hlmComboboxChipInput />
</hlm-combobox-chips>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox-multiple>
`,
})
export class ComboboxMultipleDisabledPreview {
public values = signal(['Analog', 'Astro']);
public frameworks = ['Analog', 'Angular', 'Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro'];
}Multiple Form
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { FormBuilder, FormControl, ReactiveFormsModule } from '@angular/forms';
import { BrnPopoverContent } from '@spartan-ng/brain/popover';
import { HlmButton } from '@spartan-ng/helm/button';
import { HlmComboboxImports } from '@spartan-ng/helm/combobox';
@Component({
selector: 'spartan-combobox-multiple-form-preview',
imports: [HlmComboboxImports, BrnPopoverContent, ReactiveFormsModule, HlmButton],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<form [formGroup]="form" (ngSubmit)="submit()" class="space-y-8">
<hlm-combobox-multiple formControlName="framework">
<hlm-combobox-chips class="max-w-xs">
<ng-template hlmComboboxValues let-values>
@for (value of values; track $index) {
<hlm-combobox-chip [value]="value">{{ value }}</hlm-combobox-chip>
}
</ng-template>
<input hlmComboboxChipInput />
</hlm-combobox-chips>
<div *brnPopoverContent hlmComboboxContent>
<hlm-combobox-empty>No items found.</hlm-combobox-empty>
<div hlmComboboxList>
@for (framework of frameworks; track $index) {
<hlm-combobox-item [value]="framework">{{ framework }}</hlm-combobox-item>
}
</div>
</div>
</hlm-combobox-multiple>
<button type="submit" hlmBtn [disabled]="form.invalid">Submit</button>
</form>
`,
})
export class ComboboxMultipleFormPreview {
private readonly _formBuilder = inject(FormBuilder);
public form = this._formBuilder.group({
framework: new FormControl<string[] | null>(['Analog']),
});
public frameworks = ['Analog', 'Angular', 'Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro'];
submit() {
console.log(this.form.value);
}
}Brain API
BrnComboboxAnchor
Selector: [brnComboboxAnchor]
BrnComboboxChipInput
Selector: input[brnComboboxChipInput]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-combobox-input-${++BrnComboboxChipInput._id}` | The id of the combobox input |
BrnComboboxChipRemove
Selector: button[brnComboboxChipRemove]
BrnComboboxChip
Selector: [brnComboboxChip]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| value* (required) | T | - | - |
BrnComboboxClear
Selector: [brnComboboxClear]
BrnComboboxContent
Selector: [brnComboboxContent]
BrnComboboxEmpty
Selector: [brnComboboxEmpty]
BrnComboboxGroup
Selector: [brnComboboxGroup]
BrnComboboxInputWrapper
Selector: [brnComboboxInputWrapper]
BrnComboboxInput
Selector: input[brnComboboxInput]
ExportAs: brnComboboxInput
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-combobox-input-${++BrnComboboxInput._id}` | The id of the combobox input |
BrnComboboxItem
Selector: [brnComboboxItem]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-combobox-item-${++BrnComboboxItem._id}` | A unique id for the item |
| value* (required) | T | - | The value this item represents. |
| disabled | boolean | false | - |
BrnComboboxLabel
Selector: [brnComboboxLabel]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-combobox-label-${++BrnComboboxLabel._id}` | The id of the combobox label |
BrnComboboxList
Selector: [brnComboboxList]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | `brn-combobox-list-${++BrnComboboxList._id}` | The id of the combobox list |
BrnComboboxMultiple
Selector: [brnCombobox]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false | Whether the combobox is disabled |
| filterOptions | ComboboxFilterOptions | {} | Options for filtering the combobox items |
| isItemEqualToValue | ComboboxItemEqualToValue<T> | this._config.isItemEqualToValue | A function to compare an item with the selected value. |
| itemToString | ComboboxItemToString<T> | undefined | this._config.itemToString | A function to convert an item to a string for display. |
| filter | ComboboxFilter<T> | this._config.filter | A custom filter function to use when searching. |
| value | T[] | null | null | The selected values of the combobox. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| valueChanged | T[] | null | null | The selected values of the combobox. |
BrnComboboxPopoverTrigger
Selector: [brnComboboxPopoverTrigger]
BrnComboboxSeparator
Selector: [brnComboboxSeparator]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | 'horizontal' | 'vertical' | horizontal | - |
BrnComboboxTrigger
Selector: [brnComboboxTrigger]
BrnComboboxValue
Selector: [brnComboboxValue]
BrnComboboxValues
Selector: [brnComboboxValues]
BrnCombobox
Selector: [brnCombobox]
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| disabled | boolean | false | Whether the combobox is disabled |
| filterOptions | ComboboxFilterOptions | {} | Options for filtering the combobox items |
| isItemEqualToValue | ComboboxItemEqualToValue<T> | this._config.isItemEqualToValue | A function to compare an item with the selected value. |
| itemToString | ComboboxItemToString<T> | undefined | this._config.itemToString | A function to convert an item to a string for display. |
| filter | ComboboxFilter<T> | this._config.filter | A custom filter function to use when searching. |
| value | T | null | null | The selected value of the combobox. |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| valueChanged | T | null | null | The selected value of the combobox. |
Helm API
HlmComboboxChipInput
Selector: input[hlmComboboxChipInput]
HlmComboboxChipRemove
Selector: button[hlmComboboxChipRemove]
HlmComboboxChip
Selector: hlm-combobox-chip
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| showRemove | boolean | true | - |
HlmComboboxChips
Selector: [hlmComboboxChips],hlm-combobox-chips
HlmComboboxContent
Selector: [hlmComboboxContent]
HlmComboboxEmpty
Selector: [hlmComboboxEmpty],hlm-combobox-empty
HlmComboboxGroup
Selector: [hlmComboboxGroup]
HlmComboboxInput
Selector: hlm-combobox-input
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| placeholder | string | - | - |
| showTrigger | boolean | true | - |
| showClear | boolean | false | - |
| aria-invalid | boolean | false | - |
HlmComboboxItem
Selector: hlm-combobox-item
HlmComboboxLabel
Selector: [hlmComboboxLabel]
HlmComboboxList
Selector: [hlmComboboxList]
HlmComboboxMultiple
Selector: [hlmComboboxMultiple],hlm-combobox-multiple
HlmComboboxSeparator
Selector: [hlmComboboxSeparator]
HlmComboboxTrigger
Selector: hlm-combobox-trigger
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| class | ClassValue | - | - |
| variant | ButtonVariants['variant'] | outline | - |
HlmComboboxValue
Selector: [hlmComboboxValue]
HlmComboboxValues
Selector: [hlmComboboxValues]
HlmCombobox
Selector: [hlmCombobox],hlm-combobox
On This Page