Angular Stepper (ステッパー) コンポーネントの概要
Ignite UI for Angular Stepper は高度にカスタマイズ可能なコンポーネントで、必要なプロセスを可視化し、進行状況を各ステップで表示します。垂直線または水平線で表示されます。Ignite UI for Angular コンポーネント ライブラリ によって提供されるステッパー コンポーネントは、ウィザードのようなワークフローと、ステップ検証、スタイル設定、向き、キーボード ナビゲーションなどの複数の機能を提供します。
Angular Stepper の例
この Angular Stepper の例では、クレジット カードをカスタマイズでき、カード タイプの選択、ビジネス情報の追加、個人情報の入力、出荷の詳細の提供、確認の 5 つの論理ステップでプロセスを実行します。
Angular ステッパー デモの 4 番目のステップは、2 番目のステップでユーザーがチェックボックスにチェックを付けた場合にのみ有効になります。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { StepperOverviewSampleComponent } from "./stepper-overview-sample/stepper-overview-sample.component" ;
import {
IgxStepperModule,
IgxMaskModule,
IgxInputGroupModule,
IgxButtonModule,
IgxRadioModule,
IgxCardModule,
IgxCheckboxModule,
IgxSelectModule,
IgxIconModule,
IgxBadgeModule
} from "igniteui-angular" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
StepperOverviewSampleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxStepperModule,
IgxMaskModule,
IgxInputGroupModule,
IgxButtonModule,
IgxRadioModule,
IgxCardModule,
IgxCheckboxModule,
IgxSelectModule,
IgxIconModule,
IgxBadgeModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { ChangeDetectorRef, Component, ViewChild } from '@angular/core' ;
import { NgForm } from '@angular/forms' ;
import { IgxStepperComponent } from 'igniteui-angular' ;
@Component ({
selector : 'app-stepper-overview-sample' ,
styleUrls : ['./stepper-overview-sample.component.scss' ],
templateUrl : './stepper-overview-sample.component.html'
})
export class StepperOverviewSampleComponent {
@ViewChild ('stepper' , { static : true })
public stepper: IgxStepperComponent;
public today: Date = new Date ();
public cards: any [] = [
{
img : 'https://www.infragistics.com/angular-demos-lob/assets/images/stepper/card-gold.png' ,
price : 400 ,
offer : 'STATEMENT CREDIT OFFER' ,
type : 'Business Customized Advanced' ,
description : 'Cash Mastercard'
},
{
img : 'https://www.infragistics.com/angular-demos-lob/assets/images/stepper/card-red.png' ,
price : 600 ,
offer : 'STATEMENT CREDIT OFFER' ,
type : 'Business Travel Advanced' ,
description : 'World Mastercard'
},
{
img : 'https://www.infragistics.com/angular-demos-lob/assets/images/stepper/card-blue.png' ,
price : 500 ,
offer : 'STATEMENT CREDIT OFFER' ,
type : 'Business Golden' ,
description : 'World Mastercard'
}
];
public states: string [] = [
'Alabama' , 'Arizona' , 'California' , 'Colorado' , 'Florida' ,
'Georgia' , 'Hawaii' , 'Illinois' , 'Louisiana' , 'Minnesota' ,
'Nevada' , 'New York' , 'New Jersey' , 'Ohio' , 'Texas' , 'Virginia' , 'Washington'
];
public selectedCard: any ;
public businessInformation: any = {
name : '' ,
physicalAddress : '' ,
city : '' ,
state : '' ,
zip : null ,
taxIdNumber : null ,
differentAddress : false ,
nonUSBusinessActivity : null
};
public personalInformation: any = {
firstName : '' ,
lastName : '' ,
jobTitle : '' ,
phoneNumber : '' ,
email : '' ,
authorization : false ,
agreementAccepted : false
};
public shippingDetails: any = {
firstName : '' ,
lastName : '' ,
mailingAddress : '' ,
city : '' ,
state : '' ,
zip : null
};
constructor (private cdr: ChangeDetectorRef ) { }
public selectCard(card: any ): void {
this .selectedCard = card;
this .cdr.detectChanges();
this .stepper.next();
}
public resetStepper(form1: NgForm, form2 : NgForm, form3 : NgForm): void {
this .stepper.reset();
this .selectedCard = null ;
form1.reset();
this .businessInformation.differentAddress = false ;
form2.reset();
this .personalInformation.authorization = false ;
this .personalInformation.agreementAccepted = false ;
form3.reset();
}
public handleKeyDown(evt: KeyboardEvent, card : any ): void {
if (evt.key.toLowerCase() === ' ' || evt.key.toLowerCase() === 'spacebar' || evt.key.toLowerCase() === 'space' ) {
this .selectCard(card);
}
}
}
ts コピー <igx-stepper #stepper [linear ]="true" >
<igx-step #step1 [isValid ]="!!selectedCard" [completed ]="!!selectedCard" >
<span igxStepTitle > Card Type</span >
<div igxStepContent [tabIndex ]="-1" >
<h2 class ="sample-step-title" > Choose your business credit card</h2 >
<div class ="card-wrapper" >
<igx-card *ngFor ="let card of cards" (click )="selectCard(card)"
[ngClass ]="{'selected-card': selectedCard === card}" [tabIndex ]="0"
(keydown )="handleKeyDown($event, card)" >
<igx-badge *ngIf ="selectedCard === card" value ="Your current choice" > </igx-badge >
<igx-card-media >
<img src ="{{card.img}}" alt ="" >
</igx-card-media >
<igx-card-content >
<span class ="card-currency" > {{card.price}}</span >
<span class ="card-title" > {{card.offer}}</span >
<p > {{card.type}}</p >
<p > {{card.description}}</p >
</igx-card-content >
</igx-card >
</div >
</div >
</igx-step >
<igx-step #step2 [isValid ]="businessInformationForm.form.valid" [completed ]="businessInformationForm.form.valid" >
<span igxStepTitle > Business information</span >
<div igxStepContent [tabIndex ]="-1" >
<div class ="sample-row" >
<form class ="flex-form" #businessInformationForm ="ngForm" >
<igx-input-group type ="box" >
<input igxInput name ="name" id ="name" type ="text" [(ngModel )]="businessInformation.name"
required />
<label igxLabel for ="name" > Legal Business Name</label >
</igx-input-group >
<igx-input-group type ="box" >
<input igxInput name ="physicalAddress" id ="physicalAddress" type ="text"
[(ngModel )]="businessInformation.physicalAddress" required />
<label igxLabel for ="physicalAddress" > Business Physical Address</label >
</igx-input-group >
<div class ="form-row" >
<igx-input-group type ="box" >
<input igxInput name ="city" id ="city" type ="text" [(ngModel )]="businessInformation.city"
required />
<label igxLabel for ="city" > City</label >
</igx-input-group >
<igx-select type ="box" name ="state" [(ngModel )]="businessInformation.state" required >
<igx-select-item *ngFor ="let state of states" [value ]="state" >
{{state}}
</igx-select-item >
<label igxLabel > State</label >
</igx-select >
<igx-input-group type ="box" >
<input igxInput name ="zip" id ="zip" type ="text" pattern ="[0-9]{5}" [igxMask ]="'00000'"
[placeholder ]="'#####'" [(ngModel )]="businessInformation.zip" required />
<label igxLabel for ="zip" > ZIP Code</label >
</igx-input-group >
</div >
<igx-checkbox name ="differentAddress" [(ngModel )]="businessInformation.differentAddress" >
The mailing address is different than the business physical address
</igx-checkbox >
<igx-input-group type ="box" >
<input igxInput name ="taxIdNumber" id ="taxIdNumber" type ="text" pattern ="[9]{1}[0-9]{8}"
[placeholder ]="'9##-##-####'" [igxMask ]="'000-00-0000'"
[(ngModel )]="businessInformation.taxIdNumber" required />
<igx-hint *ngIf ="!businessInformationForm.controls['taxIdNumber']?.pristine
&& !businessInformationForm.controls['taxIdNumber']?.valid" >
The Federal Tax ID Number should begin with 9
</igx-hint >
<label igxLabel for ="taxIdNumber" > Federal Tax ID Number</label >
</igx-input-group >
<p > Does this business operate outside the United States? <span class ="sample-required" > *</span > </p >
<igx-radio-group type ="box" name ="nonUSBusinessActivity" alignment ="vertical"
[(ngModel )]="businessInformation.nonUSBusinessActivity" required >
<igx-radio class ="radio-sample" value ="true" >
Yes
</igx-radio >
<igx-radio class ="radio-sample" value ="false" >
No
</igx-radio >
</igx-radio-group >
</form >
<igx-card type ="outlined" *ngIf ="selectedCard" >
<igx-card-content >
<div class ="sample-row sample-card" >
<img src ="{{selectedCard.img}}" alt ="" >
<div >
<span class ="card-currency" > {{selectedCard.price}}</span >
<span class ="card-title" > {{selectedCard.offer}}</span >
<p > {{selectedCard.type}}</p >
<p > {{selectedCard.description}}</p >
</div >
</div >
</igx-card-content >
</igx-card >
</div >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Back</button >
<button igxButton ="raised" (click )="stepper.next()"
[disabled ]="!businessInformationForm.form.valid" > Continue</button >
</div >
</div >
</igx-step >
<igx-step #step3 [isValid ]="personalInformationForm.form.valid" [completed ]="personalInformationForm.form.valid" >
<span igxStepTitle > Personal Information</span >
<div igxStepContent [tabIndex ]="-1" >
<div class ="sample-row" >
<form class ="flex-form" #personalInformationForm ="ngForm" >
<igx-input-group type ="box" >
<input igxInput name ="firstName" id ="firstName" type ="text"
[(ngModel )]="personalInformation.firstName" required />
<label igxLabel for ="firstName" > First Name</label >
</igx-input-group >
<igx-input-group type ="box" >
<input igxInput name ="lastName" id ="lastName" type ="text"
[(ngModel )]="personalInformation.lastName" required />
<label igxLabel for ="lastName" > Last Name</label >
</igx-input-group >
<igx-input-group type ="box" >
<input igxInput name ="jobTitle" id ="jobTitle" type ="text"
[(ngModel )]="personalInformation.jobTitle" required />
<label igxLabel for ="jobTitle" > Job Title</label >
</igx-input-group >
<igx-input-group type ="box" >
<input igxInput name ="phoneNumber" id ="phoneNumber" type ="text"
[(ngModel )]="personalInformation.phoneNumber" required />
<label igxLabel for ="phoneNumber" > Phone Number</label >
</igx-input-group >
<igx-input-group type ="box" >
<input igxInput name ="email" id ="email" type ="email" [(ngModel )]="personalInformation.email"
required email />
<label igxLabel for ="email" > Email Address</label >
</igx-input-group >
<igx-checkbox name ="authorization" [(ngModel )]="personalInformation.authorization" required >
I confirm that I am authorized to borrow on behalf of this business. <span
class ="sample-required" > *</span >
</igx-checkbox >
<div class ="sample-terms" >
<igx-checkbox name ="agreementAccepted" [(ngModel )]="personalInformation.agreementAccepted"
required >
I agree with the<span class ="sample-required" > *</span >
</igx-checkbox >
<a (click )="$event.stopPropagation()" > Terms and Conditions</a >
</div >
</form >
<igx-card type ="outlined" *ngIf ="selectedCard" >
<igx-card-content >
<div class ="sample-row sample-card" >
<img src ="{{selectedCard.img}}" alt ="" >
<div >
<span class ="card-currency" > {{selectedCard.price}}</span >
<span class ="card-title" > {{selectedCard.offer}}</span >
<p > {{selectedCard.type}}</p >
<p > {{selectedCard.description}}</p >
</div >
</div >
</igx-card-content >
</igx-card >
</div >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Back</button >
<button igxButton ="raised" (click )="stepper.next()"
[disabled ]="!personalInformationForm.form.valid" > Continue</button >
</div >
</div >
</igx-step >
<igx-step #step4 [disabled ]="!businessInformation.differentAddress" [isValid ]="shippingDetailsForm.form.valid"
[completed ]="shippingDetailsForm.form.valid || (!businessInformation.differentAddress && step3.completed)" >
<span igxStepTitle > Shipping Details</span >
<div igxStepContent [tabIndex ]="-1" >
<div class ="sample-row" >
<form class ="flex-form" #shippingDetailsForm ="ngForm" >
<igx-input-group type ="box" >
<input igxInput name ="sfirstName" id ="sfirstName" type ="text"
[(ngModel )]="shippingDetails.firstName" required />
<label igxLabel for ="sfirstName" > First Name</label >
</igx-input-group >
<igx-input-group type ="box" >
<input igxInput name ="slastName" id ="slastName" type ="text"
[(ngModel )]="shippingDetails.lastName" required />
<label igxLabel for ="slastName" > Last Name</label >
</igx-input-group >
<igx-input-group type ="box" >
<input igxInput name ="mailingAddress" type ="text" [(ngModel )]="shippingDetails.mailingAddress"
required />
<label igxLabel for ="mailingAddress" id ="mailingAddress" > Mailing Address</label >
</igx-input-group >
<div class ="form-row" >
<igx-input-group type ="box" >
<input igxInput name ="scity" id ="scity" type ="text" [(ngModel )]="shippingDetails.city"
required />
<label igxLabel for ="scity" > City</label >
</igx-input-group >
<igx-select type ="box" name ="sstate" [(ngModel )]="shippingDetails.state" required >
<igx-select-item *ngFor ="let state of states" [value ]="state" >
{{state}}
</igx-select-item >
<label igxLabel > State</label >
</igx-select >
<igx-input-group type ="box" >
<input igxInput name ="szip" id ="szip" type ="text" pattern ="[0-9]{5}" [placeholder ]="'#####'"
[igxMask ]="'00000'" [(ngModel )]="shippingDetails.zip" required />
<label igxLabel for ="szip" > ZIP Code</label >
</igx-input-group >
</div >
</form >
<igx-card type ="outlined" *ngIf ="selectedCard" >
<igx-card-content >
<div class ="sample-row sample-card" >
<img src ="{{selectedCard.img}}" alt ="" >
<div >
<span class ="card-currency" > {{selectedCard.price}}</span >
<span class ="card-title" > {{selectedCard.offer}}</span >
<p > {{selectedCard.type}}</p >
<p > {{selectedCard.description}}</p >
</div >
</div >
</igx-card-content >
</igx-card >
</div >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Back</button >
<button igxButton ="raised" (click )="stepper.next()"
[disabled ]="!shippingDetailsForm.form.valid" > Continue</button >
</div >
</div >
</igx-step >
<igx-step #step5 >
<span igxStepTitle > Confirmation</span >
<div igxStepContent [tabIndex ]="-1" >
<div class ="success-message" >
<div class ="success-marker" >
<igx-icon > check</igx-icon >
</div >
<div class ="success-text" >
<h2 class ="sample-step-title" > Your application for a business credit card has been sent
successfully!</h2 >
<p > We will contact you within a few days.</p >
</div >
</div >
<igx-card class ="sample-small-card" type ="outlined" *ngIf ="selectedCard" >
<igx-card-content >
<strong class ="sample-date" > Application date: {{ today | date:'d MMM y' }}</strong >
<div class ="sample-row sample-card" >
<img src ="{{selectedCard.img}}" alt ="" >
<div >
<span class ="card-currency" > {{selectedCard.price}}</span >
<span class ="card-title" > {{selectedCard.offer}}</span >
<p > {{selectedCard.type}}</p >
<p > {{selectedCard.description}}</p >
</div >
</div >
</igx-card-content >
</igx-card >
<div class ="sample-step-actions" >
<button igxButton ="raised"
(click )="resetStepper(businessInformationForm, personalInformationForm, shippingDetailsForm)" > Reset</button >
</div >
</div >
</igx-step >
</igx-stepper >
html コピー @use '../../variables' as *;
$sample-gap : 20px ;
:host {
display : block;
padding : $sample-gap ;
max-width : rem(1150px );
p {
margin : 0 ;
}
}
.sample-step-actions ,
.card-wrapper ,
.sample-row ,
.flex-form ,
.form-row ,
.success-message ,
.success-text {
display : flex;
}
.sample-row {
align-items : flex-start;
gap: rem(50px );
> * {
flex : 1 ;
}
}
.sample-step-actions {
gap: $sample-gap ;
margin-top : $sample-gap * 2 ;
}
.card-wrapper {
gap: rem(30px );
}
$my-card : card-theme(
$schema : $light-schema ,
$border-radius : rem(8px ),
$content-text-color : color($default-palette , 'gray' , 900 ),
);
@include card($my-card );
.selected-card {
border : 2px solid color($default-palette , 'primary' , 400 );
position : relative;
overflow : initial;
igx-badge {
position : absolute;
top : rem(-11px );
left : 0 ;
right : 0 ;
margin : 0 auto;
content : 'Current choice' ;
padding : rem(4px ) rem(8px );
max-width : 50% ;
}
}
.igx-card {
cursor : pointer;
user-select: none;
min-width : 280px ;
&:focus {
outline : none;
box-shadow : inset 0 0 0 1px color($default-palette , 'primary' , 400 ),
0 5px 5px -3px rgba(0 , 0 , 0 , 0.26 ),
0 8px 10px 1px rgba(0 , 0 , 0 , 0.12 ),
0 3px 14px 2px rgba(0 , 0 , 0 , 0.08 );
}
}
.sample-step-title {
font-size : rem(20px );
letter-spacing : 0 ;
font-weight : 500 ;
line-height : normal;
margin-bottom : rem(24px );
}
.igx-card__media {
max-width : rem(340px );
padding : rem(30px ) rem(30px ) 0 rem(30px );
}
.igx-card-content {
text-align : center;
p {
font-size : rem(16px );
line-height : rem(24px );
}
padding : rem(30px );
}
.card-title {
display : block;
font-size : rem(14px );
font-weight : 500 ;
margin : 0 rem(8px );
color : color($default-palette , 'secondary' );
}
.card-currency {
display : block;
font-size : rem(48px );
color : color($default-palette , 'secondary' );
margin-bottom : rem(8px );
&::before {
content : '$' ;
font-size : rem(34px );
margin-right : rem(6px );
position : relative;
top : rem(-12px );
}
}
.flex-form ,
.form-row {
gap: rem(16px );
}
.flex-form {
flex-direction : column;
igx-checkbox {
white-space : nowrap;
}
}
.sample-card {
align-items : center;
justify-content : center;
flex-wrap : wrap;
img {
width : rem(180px );
max-width : rem(300px );
min-width : rem(130px );
}
.card-title {
font-size : 12px ;
margin :0 rem(4px );
}
.card-currency {
font-size : rem(36px );
margin-bottom : rem(4px );
&::before {
font-size : rem(22px );
margin-right : rem(4px );
}
}
p {
font-size : rem(14px );
white-space : nowrap;
}
}
.radio-sample {
margin-bottom : rem(16px );
}
.success-marker {
display :flex;
align-items : center;
justify-content : center;
width : rem(30px );
height : rem(30px );
border-radius : rem(15px );
background : color($default-palette , 'success' );
color : #fff ;
user-select: none;
}
.success-message {
align-items : center;
gap: rem(16px );
margin-bottom : rem(32px );
}
.success-text {
flex-direction : column;
.sample-step-title {
margin : 0 ;
}
}
.sample-date {
display : block;
margin-bottom : rem(16px );
text-align : left;
font-weight : 500 ;
}
.sample-small-card {
max-width : rem(500px );
}
.sample-terms {
display : flex;
align-items : center;
justify-content : flex-start;
> a {
margin-left : rem(8px );
color : color($default-palette , 'primary' );
text-decoration : none;
&:hover {
color : color($default-palette , 'primary' , 600 );
}
}
}
.sample-required {
color : color($default-palette , 'error' );
margin-left : rem(2px );
}
scss コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Angularツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
これは、Angular Reactive Forms を使用して上記の機能を実現する方法を示すサンプルです。
Ignite UI for Angular Stepper を使用した作業の開始
Ignite UI for Angular Stepper コンポーネントを初期化するには、Ignite UI for Angular をインストールする必要があります。既存の Angular アプリケーションで、以下のコマンドを入力します。
ng add igniteui-angular
cmd
Ignite UI for Angular については、「はじめに 」トピックをご覧ください。
次に、app.module ファイルに IgxStepperModule
をインポートします。
...
import { IgxStepperModule } from 'igniteui-angular' ;
@NgModule ({
...
imports : [..., IgxStepperModule],
...
})
export class AppModule {}
typescript
あるいは、16.0.0
以降、IgxStepperComponent
をスタンドアロンの依存関係としてインポートすることも、IGX_STEPPER_DIRECTIVES
トークンを使用してコンポーネントとそのすべてのサポート コンポーネントおよびディレクティブをインポートすることもできます。
import { HammerModule } from '@angular/platform-browser' ;
import { FormsModule } from '@angular/forms' ;
import { IGX_STEPPER_DIRECTIVES } from 'igniteui-angular' ;
@Component ({
selector : 'app-home' ,
template : `<igx-stepper>
<igx-step>
<p igxStepTitle>Step 1</p>
</igx-step>
<igx-step>
<p igxStepTitle>Step 2</p>
</igx-step>
</igx-stepper>` ,
styleUrls : ['home.component.scss' ],
standalone : true ,
imports : [IGX_STEPPER_DIRECTIVES, FormsModule, HammerModule]
})
export class HomeComponent {
public task: Task;
}
typescript
Angular Stepper モジュールまたはディレクティブをインポート後、igx-stepper
とそのステップの基本設定を開始します。
Angular Stepper の使用
IgxStepComponent は、IgxStepperComponent に属するすべてのステップの表現です。ステップは isValid 、active 、optional 、disabled 、completed プロパティを提供し、ビジネス要件に応じてステップの状態を構成できます。
ステッパーの宣言
ステッパー モジュールをインポートした後で、構成を開始します。
ステップは、以下の方法のいずれかを使用して宣言できます。
<igx-stepper >
<igx-step *ngFor ="let step of stepsData" [disabled ]=”step.disabled” >
<igx-icon igxStepIndicator >
{{step.indicator}}
</igx-icon >
<p igxStepTitle >
{{step.title}}
</p >
</igx-step >
</igx-stepper >
html
<igx-stepper >
<igx-step >
<p igxStepTitle > Step 1</p >
</igx-step >
<igx-step >
<p igxStepTitle > Step 2</p >
</igx-step >
</igx-stepper >
html
各ステップで、igxStepIndicator
、igxStepTitle
、igxStepSubtitle
、および igxStepContent
ディレクティブを使用してインジケーター、タイトル、サブタイトル、コンテンツを構成できます。
<igx-stepper >
<igx-step >
<igx-icon igxStepIndicator > home</igx-icon >
<p igxStepTitle > Home</p >
<p igxStepSubtitle > Home Sub Title</p >
<div igxStepContent >
...
</div >
</igx-step >
</igx-stepper >
html
ステッパーの向きの変更
公開された orientation プロパティでステッパーの向きをカスタマイズできます。IgxStepperOrientation
列挙型の Horizontal
メンバー (デフォルト値) または Vertical
メンバーを取得します。
水平方向のステッパー
igx-stepper
の orientation プロパティのデフォルト値は horizontal
です。
ステッパーが水平方向の場合、ステップのコンテンツをステップのヘッダーの上または下に表示するかどうかを決定できます。これは、IgxStepperComponent の contentTop ブール型プロパティを設定することで実現できます。デフォルト値は false
です。有効な場合、ステップのコンテンツはステップのヘッダーの上に表示されます。
水平方向のステッパー
水平レイアウトから垂直レイアウトに簡単に切り替えることができます。デフォルトの方向を変更するには、orientation プロパティを vertical
に設定します。
<igx-stepper [orientation ]="'vertical'" >
<igx-step >
…
</igx-step >
<igx-step >
…
</igx-step >
</igx-stepper >
html
以下のサンプルは、実行時にステッパーの向き とタイトルの位置 を変更する方法を示しています。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { StepperLabelPositionAndOrientationSampleComponent } from "./stepper-label-position-and-orientation-sample/stepper-label-position-and-orientation-sample.component" ;
import {
IgxStepperModule,
IgxButtonModule,
IgxButtonGroupModule
} from "igniteui-angular" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
StepperLabelPositionAndOrientationSampleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxStepperModule,
IgxButtonModule,
IgxButtonGroupModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component } from '@angular/core' ;
import { IButtonGroupEventArgs, IgxStepperOrientation, IgxStepperTitlePosition } from 'igniteui-angular' ;
@Component ({
selector : 'app-stepper-label-position-and-orientation-sample' ,
styleUrls : ['./stepper-label-position-and-orientation-sample.component.scss' ],
templateUrl : './stepper-label-position-and-orientation-sample.component.html'
})
export class StepperLabelPositionAndOrientationSampleComponent {
public orientation: IgxStepperOrientation = 'horizontal' ;
public titlePosition: IgxStepperTitlePosition = 'bottom' ;
public stepperOrientations: any [] = [
{
label : 'Horizontal' , orientation : 'horizontal' ,
selected : this .orientation === 'horizontal' , togglable : true
},
{
label : 'Vertical' , orientation : 'vertical' ,
selected : this .orientation === 'vertical' , togglable : true
}
];
public stepperTitlePositions: any [] = [
{
label : 'Bottom' , titlePosition : 'bottom' ,
selected : this .titlePosition === 'bottom' , togglable : true
},
{
label : 'Top' , titlePosition : 'top' ,
selected : this .titlePosition === 'top' , togglable : true
},
{
label : 'End' , titlePosition : 'end' ,
selected : this .titlePosition === 'end' , togglable : true
},
{
label : 'Start' , titlePosition : 'start' ,
selected : this .titlePosition === 'start' , togglable : true
}
];
public toggleOrientation(event: IButtonGroupEventArgs): void {
this .orientation = this .stepperOrientations[event.index].orientation;
}
public toggleTitlePosition(event: IButtonGroupEventArgs): void {
this .titlePosition = this .stepperTitlePositions[event.index].titlePosition;
}
}
ts コピー <div class ="sample-split" >
<igx-buttongroup [values ]="stepperTitlePositions" (selected )="toggleTitlePosition($event)" >
</igx-buttongroup >
<igx-buttongroup [values ]="stepperOrientations" (selected )="toggleOrientation($event)" >
</igx-buttongroup >
</div >
<igx-stepper #stepper [titlePosition ]="titlePosition" [orientation ]="orientation" >
<igx-step >
<span igxStepTitle > Order</span >
<div igxStepContent >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.next()" > NEXT</button >
</div >
</div >
</igx-step >
<igx-step >
<span igxStepTitle > Payment</span >
<div igxStepContent >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > PREVIOUS</button >
<button igxButton ="raised" (click )="stepper.next()" > NEXT</button >
</div >
</div >
</igx-step >
<igx-step >
<span igxStepTitle > Confirmation</span >
<div igxStepContent >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > PREVIOUS</button >
<button igxButton ="raised" (click )="stepper.reset()" > RESET</button >
</div >
</div >
</igx-step >
</igx-stepper >
html コピー $sample-gap : 20px ;
:host {
display : block;
padding : $sample-gap ;
}
.sample-split ,
.sample-step-actions {
display : flex;
gap: $sample-gap ;
}
.sample-split {
> * {
max-width : 380px ;
flex : 1 ;
}
margin-bottom : $sample-gap ;
}
scss コピー
ステップ状態
IgxStepperComponent は 4 つのステップ状態をサポートし、それぞれがデフォルトで異なるスタイルを適用します。
active - ステップが現在表示されているかどうかを決定します。設計上、ユーザーが明示的にステップの active 属性を true
に設定しない場合、最初の有効なステップがアクティブになります。
disabled - ステップが操作可能かどうかを決定します。デフォルトでは、ステップの disabled 属性は false
に設定されています。
optional - デフォルトで、ステップの optional 属性は false
に設定されます。リニア ステッパーのステップの有効性が必要ない場合、オプションの属性を有効にして、ステップの有効性とは関係なく前進できます。
completed - デフォルトでは、ステップの completed 属性は false
を返します。ユーザーは、completed 属性を必要に応じて設定することにより、このデフォルトの completed 動作をオーバーライドできます。ステップが完了済みとしてマークされると、ステップ ヘッダーのスタイルがデフォルトで変更されるだけでなく、完了したステップと次のステップの間の進捗線のスタイルも変更されます。両方のスタイルは、公開された CSS 変数 を使用して変更できます。
IgxStepperComponent は、双方向バインド可能な isValid プロパティで各ステップの検証ロジックを設定できます。その値に基づいて、ユーザーがリニア ステッパー モードで前に進むことができるかどうかが決定されます。
デフォルトで、ステップの isValid プロパティは true
に設定されます。
リニア ステッパー
igx-stepper
は、linear プロパティを使用してステップ フローを設定できます。デフォルトで、linear は false
に設定され、ユーザーは IgxStepperComponent で無効にされていないステップを選択できます。
linear プロパティが true
に設定されている場合、ステッパーは次のステップに進む前に現在のオプションではないステップを有効にする必要があります。
現在のオプションではないステップが有効でない場合、現在のステップを検証するまで次のステップに進むことができません。
以下の例は、リニア ステッパーを構成する方法を示しています。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { StepperLinearSampleComponent } from "./stepper-linear-sample/stepper-linear-sample.component" ;
import {
IgxStepperModule,
IgxIconModule,
IgxButtonModule,
IgxButtonGroupModule,
IgxInputGroupModule,
IgxRadioModule
} from "igniteui-angular" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
StepperLinearSampleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxStepperModule,
IgxIconModule,
IgxButtonModule,
IgxButtonGroupModule,
IgxInputGroupModule,
IgxRadioModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component } from '@angular/core' ;
import { IButtonGroupEventArgs } from 'igniteui-angular' ;
@Component ({
selector : 'app-stepper-linear-sample' ,
styleUrls : ['./stepper-linear-sample.component.scss' ],
templateUrl : './stepper-linear-sample.component.html'
})
export class StepperLinearSampleComponent {
public linear = false ;
public user: any = {
fullName : '' ,
email : '' ,
city : '' ,
street : '' ,
city2 : '' ,
street2 : '' ,
payment : ''
};
public paymentTypes: string [] = [
'PayPal (n@mail.com; 18/02/2021)' ,
'Visa (**** **** **** 1234; 12/23)' ,
'MasterCard (**** **** **** 5678; 12/24)'
];
public modes: any [] = [
{
label : 'Linear' , linear : true ,
selected : this .linear === true , togglable : true
},
{
label : 'Non Linear' , linear : false ,
selected : this .linear === false , togglable : true
}
];
public toggleModes(event: IButtonGroupEventArgs): void {
this .linear = this .modes[event.index].linear;
}
}
ts コピー <div class ="sample-split" >
<igx-buttongroup [values ]="modes" (selected )="toggleModes($event)" >
</igx-buttongroup >
</div >
<igx-stepper #stepper [linear ]="linear" >
<ng-template igxStepActiveIndicator >
<igx-icon > edit</igx-icon >
</ng-template >
<igx-step #step1 [isValid ]="form1.form.valid" >
<span igxStepTitle > Personal Info</span >
<div igxStepContent >
<form #form1 ="ngForm" >
<igx-input-group >
<input igxInput name ="fullName" type ="text" [(ngModel )]="user.fullName" required />
<label igxLabel for ="fullName" id ="fullName" > Full Name</label >
</igx-input-group >
<igx-input-group >
<input igxInput name ="email" type ="email" [(ngModel )]="user.email" required email />
<label igxLabel for ="email" id ="email" > Email</label >
</igx-input-group >
</form >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.next()"
[disabled ]="!form1.form.valid && stepper.linear" > NEXT</button >
</div >
</div >
</igx-step >
<igx-step #step2 [isValid ]="form2.form.valid" >
<span igxStepTitle > Delivery address</span >
<div igxStepContent >
<form #form2 ="ngForm" >
<igx-input-group >
<input igxInput name ="city" type ="text" [(ngModel )]="user.city" required />
<label igxLabel for ="city" id ="city" > City</label >
</igx-input-group >
<igx-input-group >
<input igxInput name ="street" type ="text" [(ngModel )]="user.street" required />
<label igxLabel for ="street" id ="street" > Street</label >
</igx-input-group >
</form >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.next()"
[disabled ]="!form2.form.valid && stepper.linear" > Next</button >
</div >
</div >
</igx-step >
<igx-step #step3 [optional ]="true" >
<span igxStepTitle > Billing address</span >
<span igxStepSubTitle > (optional)</span >
<div igxStepContent >
<form #form3 ="ngForm" >
<igx-input-group >
<input igxInput name ="bil-city" type ="text" [(ngModel )]="user.city2" />
<label igxLabel for ="bil-city" id ="bil-city" > City</label >
</igx-input-group >
<igx-input-group >
<input igxInput name ="bil-street" type ="text" [(ngModel )]="user.street2" />
<label igxLabel for ="bil-street" id ="bil-street" > Street</label >
</igx-input-group >
</form >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.next()" > Next</button >
</div >
</div >
</igx-step >
<igx-step #step4 [isValid ]="user.payment" >
<span igxStepTitle > Payment</span >
<div igxStepContent >
<igx-radio-group [(ngModel )]="user.payment" alignment ="vertical" required >
<igx-radio *ngFor ="let paymentType of paymentTypes" value ="paymentType" >
{{ paymentType }}
</igx-radio >
</igx-radio-group >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.next()" > Submit</button >
</div >
</div >
</igx-step >
<igx-step #step5 >
<span igxStepTitle > Delivery status</span >
<div igxStepContent >
<p > Your order is on its way. Expect delivery on 25th September 2021. Delivery address: San Jose, CA 94243.
</p >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.reset()" > Reset</button >
</div >
</div >
</igx-step >
</igx-stepper >
html コピー $sample-gap : 20px ;
:host {
display : block;
padding : $sample-gap ;
}
.sample-split ,
.sample-step-actions {
display : flex;
gap: $sample-gap ;
}
.sample-step-actions {
margin-top : $sample-gap * 2 ;
}
.sample-split {
> * {
max-width : 380px ;
flex : 1 ;
}
margin-bottom : $sample-gap ;
}
form {
> * {
margin-bottom : calc(#{$sample-gap } / 2 );
}
margin-bottom : $sample-gap ;
}
igx-radio {
margin-bottom : $sample-gap ;
}
scss コピー
ステップ操作
IgxStepperComponent は、ステップ操作に以下の API メソッドを提供します。
navigateTo – 指定したインデックスでステップをアクティブ化します。
next - 次の無効化されていないステップをアクティブ化します。
prev – 前の無効化されていないステップをアクティブ化します。
reset – ステッパーを初期状態にリセットします。
reset メソッドはステップの内容をクリアしません。これは手動で行う必要があります。
ステップのカスタマイズ
Ignite UI for Angular Stepper では、タイトル、インジケーターなどのさまざまなオプションを構成できます。
これは、IgxStepperComponent の stepType プロパティで実現できます。IgxStepType
列挙型のメンバーを取得します。
Full (フル、デフォルト値 )
Indicator (インジケーター)
Title (タイトル)
Full (フル)
タイトルとサブタイトルが定義されている場合、この設定ではインジケーターとタイトルの両方が描画されます。
また、ユーザーはステップのタイトルの位置を定義できるため、ステップ インジケーターの前、後、上、または下に配置できます。
ユーザーは titlePosition プロパティを使用してタイトル位置を構成できます。両方のプロパティは IgxStepperTitlePosition
列挙型のメンバーを取得します。
igx-stepper
が水平方向の場合、タイトル位置のデフォルト値は bottom
です。
向きが垂直レイアウトに設定されている場合、タイトル位置のデフォルト値は end
です。
Indicator (インジケーター)
ステップのインジケーターのみを表示する場合は、stepType オプションを indicator
に設定します。
ステップ インジケーターはすべてのコンテンツをサポートしますが、サイズが常に 24 ピクセル になるという制限があります。この点に注意して、ステップ インジケーターとして IgxIconComponent または IgxAvatarComponent を使用することをお勧めします。
Title (タイトル)
ステップのタイトルのみを表示する場合は、stepType オプションを title
に設定します。
このように、サブタイトルが定義されている場合、それらもステップ タイトルの下に描画されます。
このコンテナーは、サイズ制限なしで要件に応じて再テンプレート化できます。たとえば、サイズが 24 ピクセルより大きいインジケーターを中に追加できます。
以下のサンプルは公開されたすべてのステップ タイプと変更方法を示しています。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { StepperStepTypesSampleComponent } from "./stepper-steptypes-sample/stepper-steptypes-sample.component" ;
import {
IgxStepperModule,
IgxButtonGroupModule
} from "igniteui-angular" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
StepperStepTypesSampleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxStepperModule,
IgxButtonGroupModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component } from '@angular/core' ;
import { IButtonGroupEventArgs, IgxStepType } from 'igniteui-angular' ;
@Component ({
selector : 'app-stepper-steptypes-sample' ,
styleUrls : ['./stepper-steptypes-sample.component.scss' ],
templateUrl : './stepper-steptypes-sample.component.html'
})
export class StepperStepTypesSampleComponent {
public stepType: IgxStepType = 'full' ;
public stepTypes: any [] = [
{
label : 'Indicator' , stepType : 'indicator' ,
selected : this .stepType === 'indicator' , togglable : true
},
{
label : 'Title' , stepType : 'title' ,
selected : this .stepType === 'title' , togglable : true
},
{
label : 'Full' , stepType : 'full' ,
selected : this .stepType === 'full' , togglable : true
}
];
public toggleStepType(event: IButtonGroupEventArgs): void {
this .stepType = this .stepTypes[event.index].stepType;
}
}
ts コピー <div class ="sample-split" >
<igx-buttongroup [values ]="stepTypes" (selected )="toggleStepType($event)" > </igx-buttongroup >
</div >
<igx-stepper #stepper [stepType ]="stepType" >
<igx-step >
<span igxStepTitle > Pricing Plan</span >
</igx-step >
<igx-step >
<span igxStepTitle > Car Details</span >
</igx-step >
<igx-step >
<span igxStepTitle > Payment</span >
</igx-step >
</igx-stepper >
html コピー $sample-gap : 20px ;
:host {
display : block;
padding : $sample-gap ;
}
.sample-split ,
.sample-step-actions {
display : flex;
gap: $sample-gap ;
}
.sample-step-actions {
margin-top : $sample-gap * 2 ;
}
.sample-split {
> * {
max-width : 380px ;
flex : 1 ;
}
margin-bottom : $sample-gap ;
}
scss コピー
IgxStepperComponent では、アクティブなステップ、無効なステップ、完了したステップの描画されたインジケーターをカスタマイズできます。これは、igxStepActiveIndicator
、igxStepInvalidIndicator
、および igxStepCompletedIndicator
ディレクティブで実現できます。
<igx-stepper >
<ng-template igxStepActiveIndicator >
<igx-icon > edit</igx-icon >
</ng-template >
<ng-template igxStepInvalidIndicator >
<igx-icon > error</igx-icon >
</ng-template >
<ng-template igxStepCompletedIndicator >
<igx-icon > check</igx-icon >
</ng-template >
...
</igx-stepper >
html
このテンプレートは、関連する状態のすべてのステップに適用されます。
Angular Stepper のアニメーション
Angular Stepper のアニメーションにより、エンドユーザーは定義されたステッをプ操作しているときに高いエクスペリエンスを得ることができます。使用可能なアニメーション オプションは、ステッパーの向きによって異なります。
ステッパーが水平方向 の場合、デフォルトで slide
アニメーションを使用するように構成されます。fade
もサポートします。アニメーションは、horizontalAnimationType 入力を介して構成されます。
垂直方向 のレイアウトでは、アニメーション タイプは verticalAnimationType プロパティを使用して定義できます。デフォルトで値は grow
で、ユーザーは fade
に設定できます。
両方のアニメーション タイプ入力に none
を設定すると、ステッパー アニメーションが無効になります。
IgxStepperComponent は、ステップ間のトランジションの期間を構成する機能を提供します。これは、引数として数値を受け取る animationDuration プロパティで実現できます。これは両方の方向に共通です。
キーボード ナビゲーション
Ignite UI for Angular は、さまざまなキーボード操作をエンドユーザーに提供します。この機能はデフォルトで有効になっており、エンドユーザーは簡単にステップを移動できます。
IgxStepperComponent ナビゲーションは W3 アクセシビリティ標準 に準拠しており、便利に使用できます。
キーの組み合わせ
Tab - 次の移動可能な要素にフォーカスを移動します。
Shift + Tab - 前移動可能な要素にフォーカスを移動します。
下矢印 - igx-stepper
が垂直方向 の場合、次のアクセス可能なステップのヘッダーにフォーカスを移動します。
上矢印 - igx-stepper
が垂直方向 の場合、前のアクセス可能なステップのヘッダーにフォーカスを移動します。
左矢印 - 両方の方向で前のアクセス可能なステップのヘッダーにフォーカスを移動します。
右矢印 - 両方の方向で次にアクセス可能なステップのヘッダーにフォーカスを移動します。
Home - igx-stepper
の最初の有効なステップのヘッダーにフォーカスを移動します。
End - igx-stepper
の最後の有効なステップのヘッダーにフォーカスを移動します。
Enter / Space - 現在フォーカスされているステップをアクティブ化します。
ユーザーがステップ ヘッダーで Tab キーを押すと、フォーカスはステップ コンテンツ コンテナーに移動します。コンテナーをスキップする場合、開発者は [tabIndex]="-1"
コンテンツ コンテナーを設定する必要があります。
Stepper コンポーネントは、ローコード ドラッグアンドドロップ App Builder™ でも使用できます。
Angular Stepper のスタイル設定
Ignite UI for Angular テーマ を使用して、igx-stepper
の外観を変更できます。
はじめに、テーマ エンジンによって公開されている関数を使用するために、スタイル ファイルに index
ファイルをインポートする必要があります。
@use "igniteui-angular/theming" as *;
scss
最も簡単な方法として、stepper-theme を拡張する新しいテーマを作成し、変更するパラメーターを渡す方法があります。
$custom-stepper-theme : stepper-theme(
$indicator-background : #fff ,
$current-indicator-background : #f6cd28 ,
$current-indicator-outline : #351e65 ,
$current-title-color : #351e65 ,
$current-subtitle-color : #5f4691 ,
$complete-indicator-background : #351e65 ,
$complete-indicator-outline : #351e65 ,
$complete-title-color : red,
$complete-subtitle-color : #5f4691 ,
$border-radius-step-header : 16px ,
$border-radius-indicator : 10px 4px 10px 4px ,
$step-separator-color : #f6cd28 ,
$complete-step-separator-color : #351e65 ,
);
scss
最後にコンポーネントのテーマを含めます。
@include css-vars($custom-stepper-theme );
scss
デモ
以下のサンプルは、Ignite UI for Angular テーマ で適用されるシンプルなスタイル設定を示します。
import { NgModule } from "@angular/core" ;
import { FormsModule } from "@angular/forms" ;
import { BrowserModule } from "@angular/platform-browser" ;
import { BrowserAnimationsModule } from "@angular/platform-browser/animations" ;
import { AppComponent } from "./app.component" ;
import { StepperLinearSampleComponent } from "./stepper-linear-sample/stepper-linear-sample.component" ;
import {
IgxStepperModule,
IgxIconModule,
IgxButtonModule,
IgxButtonGroupModule,
IgxInputGroupModule,
IgxRadioModule
} from "igniteui-angular" ;
@NgModule ({
bootstrap : [AppComponent],
declarations : [
AppComponent,
StepperLinearSampleComponent
],
imports : [
BrowserModule,
BrowserAnimationsModule,
FormsModule,
IgxStepperModule,
IgxIconModule,
IgxButtonModule,
IgxButtonGroupModule,
IgxInputGroupModule,
IgxRadioModule
],
providers : [],
entryComponents : [],
schemas : []
})
export class AppModule {}
ts コピー import { Component } from '@angular/core' ;
import { IButtonGroupEventArgs } from 'igniteui-angular' ;
@Component ({
selector : 'app-stepper-linear-sample' ,
styleUrls : ['./stepper-linear-sample.component.scss' ],
templateUrl : './stepper-linear-sample.component.html'
})
export class StepperLinearSampleComponent {
public linear = false ;
public user: any = {
fullName : '' ,
email : '' ,
city : '' ,
street : '' ,
city2 : '' ,
street2 : '' ,
payment : ''
};
public paymentTypes: string [] = [
'PayPal (n@mail.com; 18/02/2021)' ,
'Visa (**** **** **** 1234; 12/23)' ,
'MasterCard (**** **** **** 5678; 12/24)'
];
public modes: any [] = [
{
label : 'Linear' , linear : true ,
selected : this .linear === true , togglable : true
},
{
label : 'Non Linear' , linear : false ,
selected : this .linear === false , togglable : true
}
];
public toggleModes(event: IButtonGroupEventArgs): void {
this .linear = this .modes[event.index].linear;
}
}
ts コピー <div class ="sample-split" >
<igx-buttongroup [values ]="modes" (selected )="toggleModes($event)" >
</igx-buttongroup >
</div >
<igx-stepper #stepper [linear ]="linear" >
<ng-template igxStepActiveIndicator >
<igx-icon > edit</igx-icon >
</ng-template >
<igx-step #step1 [isValid ]="form1.form.valid" >
<span igxStepTitle > Personal Info</span >
<div igxStepContent >
<form #form1 ="ngForm" >
<igx-input-group >
<input igxInput name ="fullName" type ="text" [(ngModel )]="user.fullName" required />
<label igxLabel for ="fullName" id ="fullName" > Full Name</label >
</igx-input-group >
<igx-input-group >
<input igxInput name ="email" type ="email" [(ngModel )]="user.email" required email />
<label igxLabel for ="email" id ="email" > Email</label >
</igx-input-group >
</form >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.next()"
[disabled ]="!form1.form.valid && stepper.linear" > NEXT</button >
</div >
</div >
</igx-step >
<igx-step #step2 [isValid ]="form2.form.valid" >
<span igxStepTitle > Delivery address</span >
<div igxStepContent >
<form #form2 ="ngForm" >
<igx-input-group >
<input igxInput name ="city" type ="text" [(ngModel )]="user.city" required />
<label igxLabel for ="city" id ="city" > City</label >
</igx-input-group >
<igx-input-group >
<input igxInput name ="street" type ="text" [(ngModel )]="user.street" required />
<label igxLabel for ="street" id ="street" > Street</label >
</igx-input-group >
</form >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.next()"
[disabled ]="!form2.form.valid && stepper.linear" > Next</button >
</div >
</div >
</igx-step >
<igx-step #step3 [optional ]="true" >
<span igxStepTitle > Billing address</span >
<span igxStepSubTitle > (optional)</span >
<div igxStepContent >
<form #form3 ="ngForm" >
<igx-input-group >
<input igxInput name ="bil-city" type ="text" [(ngModel )]="user.city2" />
<label igxLabel for ="bil-city" id ="bil-city" > City</label >
</igx-input-group >
<igx-input-group >
<input igxInput name ="bil-street" type ="text" [(ngModel )]="user.street2" />
<label igxLabel for ="bil-street" id ="bil-street" > Street</label >
</igx-input-group >
</form >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.next()" > Next</button >
</div >
</div >
</igx-step >
<igx-step #step4 [isValid ]="user.payment" >
<span igxStepTitle > Payment</span >
<div igxStepContent >
<igx-radio-group [(ngModel )]="user.payment" alignment ="vertical" required >
<igx-radio *ngFor ="let paymentType of paymentTypes" value ="paymentType" >
{{ paymentType }}
</igx-radio >
</igx-radio-group >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.next()" > Submit</button >
</div >
</div >
</igx-step >
<igx-step #step5 >
<span igxStepTitle > Delivery status</span >
<div igxStepContent >
<p > Your order is on its way. Expect delivery on 25th September 2021. Delivery address: San Jose, CA 94243.
</p >
<div class ="sample-step-actions" >
<button igxButton ="raised" (click )="stepper.prev()" > Previous</button >
<button igxButton ="raised" (click )="stepper.reset()" > Reset</button >
</div >
</div >
</igx-step >
</igx-stepper >
html コピー $sample-gap : 20px ;
:host {
display : block;
padding : $sample-gap ;
}
.sample-split ,
.sample-step-actions {
display : flex;
gap: $sample-gap ;
}
.sample-step-actions {
margin-top : $sample-gap * 2 ;
}
.sample-split {
> * {
max-width : 380px ;
flex : 1 ;
}
margin-bottom : $sample-gap ;
}
form {
> * {
margin-bottom : calc(#{$sample-gap } / 2 );
}
margin-bottom : $sample-gap ;
}
igx-radio {
margin-bottom : $sample-gap ;
}
scss コピー
API リファレンス
その他のリソース
コミュニティに参加して新しいアイデアをご提案ください。