Forms
Validation form Preview link
<form class="needs-validation" novalidate="">
<div class="row g-3">
<div class="col-md-4">
<label class="form-label" for="validationCustom01">First name</label>
<input class="form-control" id="validationCustom01" type="text" value="Mark" required="" data-bs-original-title="" title="">
<div class="valid-feedback">Looks good!</div>
</div>
<div class="col-md-4">
<label class="form-label" for="validationCustom02">Last name</label>
<input class="form-control" id="validationCustom02" type="text" value="Otto" required="" data-bs-original-title="" title="">
<div class="valid-feedback">Looks good!</div>
</div>
<div class="col-md-4 mb-3">
<label class="form-label" for="validationCustomUsername">Username</label>
<div class="input-group">
<span class="input-group-text" id="inputGroupPrepend">@</span>
<input class="form-control" id="validationCustomUsername" type="text" placeholder="Username" aria-describedby="inputGroupPrepend" required="" data-bs-original-title="" title="">
<div class="invalid-feedback">Please choose a username.</div>
</div>
</div>
</div>
<div class="row g-3">
<div class="col-md-6">
<label class="form-label" for="validationCustom03">City</label>
<input class="form-control" id="validationCustom03" type="text" placeholder="City" required="" data-bs-original-title="" title="">
<div class="invalid-feedback">Please provide a valid city.</div>
</div>
<div class="col-md-3">
<label class="form-label" for="validationCustom04">State</label>
<select class="form-select" id="validationCustom04" required="">
<option selected="" disabled="" value="">Choose...</option>
<option>...</option>
</select>
<div class="invalid-feedback">Please select a valid state.</div>
</div>
<div class="col-md-3 mb-3">
<label class="form-label" for="validationCustom05">Zip</label>
<input class="form-control" id="validationCustom05" type="text" placeholder="Zip" required="" data-bs-original-title="" title="">
<div class="invalid-feedback">Please provide a valid zip.</div>
</div>
</div>
<div class="mb-3">
<div class="form-check">
<div class="checkbox p-0">
<input class="form-check-input" id="invalidCheck" type="checkbox" required="" data-bs-original-title="" title="">
<label class="form-check-label" for="invalidCheck">Agree to terms and conditions</label>
</div>
<div class="invalid-feedback">You must agree before submitting.</div>
</div>
</div>
<button class="btn btn-primary" type="submit" data-bs-original-title="" title="">Submit form</button>
</form>
To use validation you have to add the following typescript file.
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
@Component({
selector: 'app-tooltip-form-validation',
imports: [CommonModule,FormsModule,ReactiveFormsModule],
templateUrl: './tooltip-form-validation.component.html',
styleUrls: ['./tooltip-form-validation.component.scss']
})
export class TooltipFormValidationComponent {
public validate = false;
public tooltipValidation = false;
public submit() {
this.validate = !this.validate;
}
public tooltipSubmit() {
this.tooltipValidation = !this.tooltipValidation;
}
}
Base input Preview link
<form class="form theme-form">
<div class="card-body p-0">
<div class="row">
<div class="col">
<div class="mb-3">
<label class="form-label" for="exampleFormControlInput1">Email address</label>
<input class="form-control" id="exampleFormControlInput1" type="email" placeholder="name@example.com" data-bs-original-title="" title="">
</div>
</div>
</div>
</div>
</form>
Checkbox & Radio Preview link
<div class="row">
<div class="custom-radio-ml col-lg-3 col-md-6">
<div class="form-check radio radio-primary">
<input class="form-check-input" id="radio1" type="radio" name="radio1" value="option1" data-bs-original-title="" title="">
<label class="form-check-label" for="radio1">Option<span class="digits"> 1</span></label>
</div>
<div class="form-check radio radio-primary">
<input class="form-check-input" id="radio3" type="radio" name="radio1" value="option1" disabled="" data-bs-original-title="" title="">
<label class="form-check-label" for="radio3">Disabled</label>
</div>
<div class="form-check radio radio-primary">
<input class="form-check-input" id="radio4" type="radio" name="radio1" value="option1" checked="" data-bs-original-title="" title="">
<label class="form-check-label" for="radio4">Checked</label>
</div>
</div>
<div class="col-md-6 col-lg-3">
<div class="form-check checkbox mb-0">
<input class="form-check-input" id="checkbox1" type="checkbox" data-bs-original-title="" title="">
<label class="form-check-label my-0" for="checkbox1">Default</label>
</div>
<div class="form-check checkbox mb-0">
<input class="form-check-input" id="checkbox2" type="checkbox" disabled="" data-bs-original-title="" title="">
<label class="form-check-label my-0" for="checkbox2">Disabled</label>
</div>
<div class="form-check checkbox mb-0">
<input class="form-check-input" id="checkbox3" type="checkbox" checked="" data-bs-original-title="" title="">
<label class="form-check-label my-0" for="checkbox3">Checked</label>
</div>
</div>
Input group Preview link
<form>
<div class="mb-3 m-form__group">
<div class="form-label">Left Addon</div>
<div class="input-group">
<span class="input-group-text">@</span>
<input class="form-control" type="text" placeholder="Email" data-bs-original-title="" title="">
</div>
</div>
</form>
Datepicker Offical link Preview link
<label class="col-sm-3 col-form-label text-sm-end">Default</label>
<div class="col-xl-5 col-sm-9">
<div class="input-group">
<input class="datepicker-here form-control digits" placeholder="yyyy-mm-dd" name="dp"
[(ngModel)]="model" ngbDatepicker #d="ngbDatepicker" (click)="d.toggle()">
</div>
</div>
</div>
To use datepicker you have to add the following type script
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgbCalendar, NgbDate, NgbDateParserFormatter, NgbDateStruct, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { FeathericonComponent } from '../../../shared/component/feathericon/feathericon.component';
@Component({
selector: 'app-datepicker',
imports: [CommonModule, NgbModule, FormsModule, FeathericonComponent],
templateUrl: './datepicker.component.html',
styleUrls: ['./datepicker.component.scss']
})
export class DatepickerComponent {
model: NgbDateStruct;
date: { year: number, month: number };
displayMonths = 2;
navigation = 'select';
showWeekNumbers = false;
outsideDays = 'visible';
fromDate: NgbDate | null;
toDate: NgbDate | null;
model2: NgbDateStruct;
placement = 'top';
hoveredDate: NgbDate | null = null;
constructor(private calendar: NgbCalendar, public formatter: NgbDateParserFormatter) {
this.fromDate = calendar.getToday();
this.toDate = calendar.getNext(calendar.getToday(), 'd', 10);
}
onDateSelection(date: NgbDate) {
if (!this.fromDate && !this.toDate) {
this.fromDate = date;
} else if (this.fromDate && !this.toDate && date && date.after(this.fromDate)) {
this.toDate = date;
} else {
this.toDate = null;
this.fromDate = date;
}
}
isHovered(date: NgbDate) {
return this.fromDate && !this.toDate && this.hoveredDate && date.after(this.fromDate) &&
date.before(this.hoveredDate);
}
isInside(date: NgbDate) { return this.toDate && date.after(this.fromDate) && date.before(this.toDate); }
isRange(date: NgbDate) {
return date.equals(this.fromDate) || (this.toDate && date.equals(this.toDate)) || this.isInside(date) ||
this.isHovered(date)
}
validateInput(currentValue: NgbDate | null, input: string): NgbDate | null {
const parsed = this.formatter.parse(input);
return parsed && this.calendar.isValid(NgbDate.from(parsed)) ? NgbDate.from(parsed) : currentValue;
}
}
You have to add the following style scss file for the datepicker design
@import"/node_modules/@danielmoncada/angular-datetime-picker/assets/style/picker.min.css";
@import "/node_modules/angular-calendar/css/angular-calendar.css"
Switch Preview link
<label class="switch">
<input type="checkbox" checked="" data-bs-original-title="" title="">
<span class="switch-state"></span>
</label>
<label class="switch">
<input type="checkbox" data-bs-original-title="" title="">
<span class="switch-state"></span>
</label>
Touchspin Offical link Preview link
<div class="card-body common-flex pre-post-touchspin">
<div class="input-group">
<button class="decrement-touchspin btn-touchspin touchspin-primary"
(click)="decrement(0)"><i
class="fa fa-minus"></i></button><span class="input-group-text">$</span>
& lt;input class="input-touchspin spin-outline-primary" type="number" value={{counter[0]}}>
<button class="increment-touchspin btn-touchspin touchspin-primary"
(click)="increment(0)"><i
class="fa fa-plus"></i></button>
</div>
<div class="input-group">
<button class="decrement-touchspin btn-touchspin touchspin-primary"
(click)="decrement(1)"><i class=" fa
fa-minus"></i></button>
<input class="input-touchspin spin-outline-primary" type="number"
value={{counter[1]}}><span
class="input-group-text">%</span>
<button class="increment-touchspin btn-touchspin touchspin-primary"
(click)="increment(1)"><i
class="fa fa-plus"></i></button>
</div>
</div>
To use touchspin you have to add the following script files
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-icons-prefix-postfix',
imports: [CommonModule],
templateUrl: './icons-prefix-postfix.component.html',
styleUrls: ['./icons-prefix-postfix.component.scss']
})
export class IconsPrefixPostfixComponent {
public counter: number[] = [0, 0];
public increment(i: number) {
if (i === 0 || i === 1) {
this.counter[i] += 1;
}
}
public decrement(i: number) {
if (i === 0 || i === 1) {
if (this.counter[i] > 0) {
this.counter[i] -= 1;
}
}
}
}
Select2 Offical link Preview link
Default Placeholder
<label class="col-form-label">Default Placeholder</label>
<span class="select2 select2-container select2-container--default select2-container--below">
<ng-select [items]="Placeholder" bindLabel="name" bindValue="id" [multiple]="true"
placeholder="Select Your Name" [(ngModel)]="selectedCityIds">
</ng-select>
</span>
To use select2 you have to add the following type script files
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { NgSelectModule } from '@ng-select/ng-select';
@Component({
selector: 'app-select',
imports: [CommonModule,FormsModule, ReactiveFormsModule, NgSelectModule , NgbModule],
templateUrl: './select.component.html',
styleUrl: './select.component.scss'
})
export class Defaultselect2Component {
selectedCity: string;
selectedCityIds: string[] = [];
selectedCityIds3: string[] = [];
selectedCityIds2: string[] = [];
selectedCityIds4: string[] = [];
selectedCityIds5: string[] = [];
selectedCityIds6: string[] = [];
selectedCityName = 'Vilnius';
selectedCityId: number = 0;
selectedUserIds: number[] = [];
store: boolean = true;
Placeholder = [
{ id: 1, name: 'Alabama' },
{ id: 2, name: 'Wyoming' },
{ id: 3, name: 'Coming' },
{ id: 4, name: 'Hanry Die' },
{ id: 4, name: 'John Deo' },
];
Enable(val: boolean): void {
this.store = val;
}
}
Typeahead Offical link Preview link
<div class="card-body">
<input id="typeahead-format" type="text" class="form-control" placeholder="Countries" [(ngModel)]="model"
[ngbTypeahead]="search" [resultFormatter]="formatter" />
</div>
To use typeahead you have to add the following type script files
import { CommonModule } from '@angular/common';
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { Observable, OperatorFunction } from 'rxjs';
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
const states = [
'Alabama',
'Alaska',
'American Samoa',
'Arizona',
'Arkansas',
'California',
'Colorado',
'Connecticut',
'Delaware',
'District Of Columbia',
'Federated States Of Micronesia',
'Florida',
'Georgia',
'Guam',
'Hawaii',
'Idaho',
'Illinois',
'Indiana',
'Iowa',
'Kansas',
'Kentucky',
'Louisiana',
'Maine',
'Marshall Islands',
'Maryland',
'Massachusetts',
'Michigan',
'Minnesota',
'Mississippi',
'Missouri',
'Montana',
'Nebraska',
'Nevada',
'New Hampshire',
'New Jersey',
'New Mexico',
'New York',
'North Carolina',
'North Dakota',
'Northern Mariana Islands',
'Ohio',
'Oklahoma',
'Oregon',
'Palau',
'Pennsylvania',
'Puerto Rico',
'Rhode Island',
'South Carolina',
'South Dakota',
'Tennessee',
'Texas',
'Utah',
'Vermont',
'Virgin Islands',
'Virginia',
'Washington',
'West Virginia',
'Wisconsin',
'Wyoming',
];
@Component({
selector: 'app-formatted-results',
imports: [CommonModule,FormsModule,NgbModule],
templateUrl: './formatted-results.component.html',
styleUrls: ['./formatted-results.component.scss']
})
export class FormattedResultsComponent {
public model: string
formatter = (result: string) => result.toUpperCase();
search: OperatorFunction = (text$: Observable) =>
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
map((term) =>
term === '' ? [] : states.filter((v) => v.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10),
),
);
}