Forms
Validation form Preview link
<form class="row g-3 needs-validation custom-input" novalidate="" [ngClass]="{'was-validated': validate}">
<div class="col-12">
<label class="form-label" for="validationCustom01">First name</label>
<input class="form-control" id="validationCustom01" type="text" placeholder="Mark" required="">
<div class="invalid-feedback">Please enter your valid </div>
<div class="valid-feedback">Looks's Good!</div>
</div>
<div class="col-12">
<label class="col-sm-12 col-form-label" for="inputPassword1">Password</label>
<input class="form-control" id="inputPassword1" type="password" required="">
<div class="invalid-feedback">Please enter your valid password </div>
</div>
<div class="col-12">
<label class="form-label" for="validationCustom04">State</label>
<select class="form-select" id="validationCustom04" required="">
<option selected="" disabled="" value="">Choose...</option>
<option>U.K </option>
<option>India </option>
<option>Thailand</option>
<option>Newyork</option>
</select>
<div class="invalid-feedback">Please select a valid state.</div>
<div class="valid-feedback">Looks's Good! </div>
</div>
<div class="col-md-6">
<label class="form-label" for="validationCustom03">City</label>
<input class="form-control" id="validationCustom03" type="text" required="">
<div class="invalid-feedback">Please provide a valid city.</div>
<div class="valid-feedback">
Looks's Good!</div>
</div>
<div class="col-md-6">
<label class="form-label" for="validationCustom05">Zip</label>
<input class="form-control" id="validationCustom05" type="text" required="">
<div class="invalid-feedback">Please provide a valid zip.</div>
<div class="valid-feedback">
Looks's Good!</div>
</div>
<div class="col-12">
<div class="card-wrapper border rounded-3 checkbox-checked">
<h6 class="sub-title">Select your payment method</h6>
<div class="radio-form">
<div class="form-check">
<input class="form-check-input" id="validationFormCheck25" type="radio"
name="radio-stacked" required="">
<label class="form-check-label" for="validationFormCheck25">MaterCard</label>
</div>
<div class="form-check">
<input class="form-check-input" id="validationFormCheck23" type="radio"
name="radio-stacked" required="">
<label class="form-check-label" for="validationFormCheck23">VISA</label>
</div>
</div>
</div>
</div>
<div class="col-12">
<select class="form-select" required="" aria-label="select example">
<option value="">Select Your Favorite Pixelstrap theme</option>
<option value="1">Kabul</option>
<option value="2">Tivo</option>
<option value="3">Wingo</option>
</select>
<div class="invalid-feedback">Invalid select feedback</div>
</div>
<div class="col-12">
<label class="form-label" for="formFile1">Choose File</label>
<input class="form-control" id="formFile1" type="file" aria-label="file example" required="">
<div class="invalid-feedback">Invalid form file selected</div>
</div>
<div class="col-12">
<label class="form-label" for="validationTextarea">Description</label>
<textarea class="form-control" id="validationTextarea" placeholder="Enter your comment"
required=""></textarea>
<div class="invalid-feedback">Please enter a message in the textarea.</div>
</div>
<div class="col-12">
<div class="form-check">
<input class="form-check-input" id="invalidCheck" type="checkbox" value="" required="">
<label class="form-check-label" for="invalidCheck">Agree to terms and conditions</label>
<div class="invalid-feedback">You must agree before submitting.</div>
</div>
</div>
<div class="col-12">
<button class="btn btn-primary" type="submit" (click)="submit()">Submit form</button>
</div>
</form>
To use validation you have to add the following script tag
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
@Component({
selector: 'app-forms-validation',
templateUrl: './forms-validation.html',
styleUrls: ['./forms-validation.scss'],
standalone: true,
imports: [FormsModule, CommonModule]
})
export class FormsValidation {
public validate = false;
public submit() {
this.validate = !this.validate;
}
}
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>
</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 Preview link
<input class="datepicker-here form-control digits" placeholder="yyyy-mm-dd" name="dp" [(ngModel)]="model" ngbDatepicker #d="ngbDatepicker" (click)="d.toggle()">
import { Component } from '@angular/core';
import { NgbCalendar, NgbDate, NgbDateParserFormatter, NgbDateStruct, NgbInputDatepicker } from '@ng-bootstrap/ng-bootstrap';
import { FormsModule } from '@angular/forms';
import { FeatherIconComponent } from '../../../../shared/component/header/feather-icon/feather-icon';
@Component({
selector: 'app-datepicker',
templateUrl: './datepicker.html',
styleUrls: ['./datepicker.scss'],
standalone: true,
imports: [FormsModule, NgbInputDatepicker, FeatherIconComponent]
})
export class Datepicker {
model: NgbDateStruct;
}
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 Preview link
@for(data of touchSpinData; track data){
<div class="touchspin-wrapper">
<button class="decrement-touchspin btn-touchspin touchspin-{{data.class}}" (click)="decrement(data.id)">
<i class="fa fa-minus"></i>
</button>
<input class="input-touchspin spin-outline-{{data.class}}" type="number" value="{{data.value}}">
<button class="increment-touchspin btn-touchspin touchspin-{{data.class}}" (click)="increment(data.id)">
<i class="fa fa-plus"></i>
</button>
</div>
}
import { Component } from '@angular/core';
import { touchSpin } from '../../../../../shared/data/data/forms/forms-widgets/touchSpin';
@Component({
selector: 'app-default-touch-spin',
templateUrl: './default-touch-spin.html',
styleUrls: ['./default-touch-spin.scss'],
standalone: true
})
export class DefaultTouchSpin {
public touchSpinData = touchSpin;
decrement(i: number) {
if (this.touchSpinData[i].value > 0) {
this.touchSpinData[i].value -= 1;
}
}
increment(i: number) {
this.touchSpinData[i].value += 1;
}
}
export const touchSpin = [
{
id: 0,
class: 'primary',
value: 0
},
{
id: 1,
class: 'secondary',
value: 2
},
{
id: 2,
class: 'success',
value: 1
},
{
id: 3,
class: 'danger',
value: 8
},
{
id: 4,
class: 'warning',
value: 3
},
{
id: 5,
class: 'info',
value: 9
},
{
id: 6,
class: 'dark',
value: 4
},
];
Select2 Offical link Preview link
Default Placeholder
<ng-select [items]="Placeholder" bindLabel="name" bindValue="id" [multiple]="true" placeholder="Select cities" [(ngModel)]="selectedCityIds"></ng-select>
import { Component } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { NgSelectModule } from '@ng-select/ng-select';
@Component({
selector: 'app-default-select',
templateUrl: './default-select.html',
styleUrls: ['./default-select.scss'],
standalone: true,
imports: [NgSelectModule, FormsModule]
})
export class DefaultSelect {
selectedCityIds: string[] = [];
Placeholder = [
{ id: 1, name: 'Alabama' },
{ id: 2, name: 'Wyoming' },
{ id: 3, name: 'Coming' },
{ id: 4, name: 'Hanry Die' },
{ id: 4, name: 'John Deo' },
];
}
@import "../../../node_modules/@ng-select/ng-select/scss/default.theme.scss";
Typeahead Offical link Preview link
<input id="typeahead-basic" type="text" class="form-control" placeholder="Search for a state" [(ngModel)]="model" [ngbTypeahead]="search" />
To use typeahead you have to add the following script files
import { Component } from '@angular/core';
import { Observable, OperatorFunction } from 'rxjs';
import { debounceTime, distinctUntilChanged, map } from 'rxjs/operators';
import { NgbTypeahead } from '@ng-bootstrap/ng-bootstrap';
import { FormsModule } from '@angular/forms';
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-simple-type-ahead',
templateUrl: './simple-type-ahead.html',
styleUrls: ['./simple-type-ahead.scss'],
standalone: true,
imports: [FormsModule, NgbTypeahead]
})
export class SimpleTypeAhead {
public model: string;
search: OperatorFunction = (text$: Observable) =>
text$.pipe(
debounceTime(200),
distinctUntilChanged(),
map((term) =>
term.length < 2 ? [] : states.filter((v) => v.toLowerCase().indexOf(term.toLowerCase()) > -1).slice(0, 10),
),
);
}