Getting Started
UI
Components
- 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
- Native Select
- 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
Stack
Native Select
A styled native HTML select element with consistent design system integration.
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmNativeSelectImports } from '@spartan-ng/helm/native-select';
@Component({
selector: 'spartan-native-select-preview',
imports: [HlmNativeSelectImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-native-select>
<option hlmNativeSelectOption value="">Select status</option>
<option hlmNativeSelectOption value="todo">Todo</option>
<option hlmNativeSelectOption value="in-progress">In Progress</option>
<option hlmNativeSelectOption value="done">Done</option>
<option hlmNativeSelectOption value="cancelled">Cancelled</option>
</hlm-native-select>
`,
})
export class NativeSelectPreview {}Installation
ng g @spartan-ng/cli:ui native-select
npx nx g @spartan-ng/cli:ui native-select
Usage
import { HlmNativeSelectImports } from '@spartan-ng/helm/native-select';<hlm-native-select>
<option hlmNativeSelectOption value="">Select a fruit</option>
<option hlmNativeSelectOption value="apple">Apple</option>
<option hlmNativeSelectOption value="banana">Banana</option>
<option hlmNativeSelectOption value="blueberry">Blueberry</option>
<option hlmNativeSelectOption value="pineapple">Pineapple</option>
</hlm-native-select>Examples
Groups
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmNativeSelectImports } from '@spartan-ng/helm/native-select';
@Component({
selector: 'spartan-native-select-groups-example',
imports: [HlmNativeSelectImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-native-select>
<option hlmNativeSelectOption value="">Select department</option>
<optgroup hlmNativeSelectOptGroup label="Engineering">
<option hlmNativeSelectOption value="frontend">Frontend</option>
<option hlmNativeSelectOption value="backend">Backend</option>
<option hlmNativeSelectOption value="devops">DevOps</option>
</optgroup>
<optgroup hlmNativeSelectOptGroup label="Sales">
<option hlmNativeSelectOption value="sales-rep">Sales Rep</option>
<option hlmNativeSelectOption value="account-manager">Account Manager</option>
<option hlmNativeSelectOption value="sales-director">Sales Director</option>
</optgroup>
<optgroup hlmNativeSelectOptGroup label="Operations">
<option hlmNativeSelectOption value="support">Support</option>
<option hlmNativeSelectOption value="product-manager">Product Manager</option>
<option hlmNativeSelectOption value="ops-manager">Ops Manager</option>
</optgroup>
</hlm-native-select>
`,
})
export class NativeSelectGroupsExample {}Disabled
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmNativeSelectImports } from '@spartan-ng/helm/native-select';
@Component({
selector: 'spartan-native-select-disabled-example',
imports: [HlmNativeSelectImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-native-select disabled>
<option hlmNativeSelectOption value="">Select a fruit</option>
<option hlmNativeSelectOption value="apple">Apple</option>
<option hlmNativeSelectOption value="banana">Banana</option>
<option hlmNativeSelectOption value="blueberry">Blueberry</option>
</hlm-native-select>
`,
})
export class NativeSelectDisabledExample {}Invalid
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { HlmNativeSelectImports } from '@spartan-ng/helm/native-select';
@Component({
selector: 'spartan-native-select-invalid-example',
imports: [HlmNativeSelectImports],
changeDetection: ChangeDetectionStrategy.OnPush,
template: `
<hlm-native-select aria-invalid="true">
<option hlmNativeSelectOption value="">Select a fruit</option>
<option hlmNativeSelectOption value="apple">Apple</option>
<option hlmNativeSelectOption value="banana">Banana</option>
<option hlmNativeSelectOption value="blueberry">Blueberry</option>
</hlm-native-select>
`,
})
export class NativeSelectInvalidExample {}Form
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
import { FormBuilder, FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
import { HlmButtonImports } from '@spartan-ng/helm/button';
import { HlmFieldImports } from '@spartan-ng/helm/field';
import { HlmNativeSelectImports } from '@spartan-ng/helm/native-select';
@Component({
selector: 'spartan-native-select-form-example',
imports: [ReactiveFormsModule, HlmNativeSelectImports, HlmFieldImports, HlmButtonImports],
changeDetection: ChangeDetectionStrategy.OnPush,
host: {
class: 'w-full max-w-xs',
},
template: `
<form [formGroup]="form" (ngSubmit)="submit()">
<hlm-field-group>
<hlm-field>
<label hlmFieldLabel for="fruit">Favorite Fruit</label>
<hlm-native-select selectId="fruit" formControlName="fruit">
<option hlmNativeSelectOption value="">Select a fruit</option>
<option hlmNativeSelectOption value="apple">Apple</option>
<option hlmNativeSelectOption value="banana">Banana</option>
<option hlmNativeSelectOption value="blueberry">Blueberry</option>
</hlm-native-select>
</hlm-field>
<hlm-field orientation="horizontal">
<button hlmBtn type="submit" [disabled]="form.invalid">Submit</button>
</hlm-field>
</hlm-field-group>
</form>
`,
})
export class NativeSelectFormExample {
private readonly _formBuilder = inject(FormBuilder);
public form = this._formBuilder.group({
fruit: new FormControl<string | null>('', Validators.required),
});
submit() {
console.log(this.form.value);
}
}Native Select vs Select
- Use
NativeSelectfor native browser behavior, better performance, or mobile-optimized dropdowns. - Use
Selectfor custom styling, animations, or complex interactions.
Helm API
HlmNativeSelectOptGroup
Selector: [hlmNativeSelectOptGroup]
HlmNativeSelectOption
Selector: [hlmNativeSelectOption]
HlmNativeSelect
Selector: hlm-native-select
Inputs
| Prop | Type | Default | Description |
|---|---|---|---|
| selectId | string | - | - |
| selectClass | ClassValue | - | - |
| selectIconClass | ClassValue | - | - |
| size | 'sm' | 'default' | default | - |
| disabled | boolean | false | - |
| aria-invalid | boolean | false | - |
| value | string | null | - | - |
Outputs
| Prop | Type | Default | Description |
|---|---|---|---|
| valueChange | string | null | - | - |
On This Page
Stop configuring. Start shipping.
Zerops powers spartan.ng and Angular teams worldwide.
One-command deployment. Zero infrastructure headaches.
Deploy with Zerops