Stepper
Use cases:
- Provide a multi-step process or dynamic form that the user can follow.
- Validate step by step before the user can move on through the workflow.
Rapid Stepper requires rapid-stepper-tab
and rapid-stepper-tab-panel
in order to work properly.
The order of the rapid-stepper-tab corresponds to the order of the rapid-stepper-tab-panel.
Example
- Genesis
- React
- Angular
Declaration
<rapid-stepper>
<rapid-stepper-tab>Step 1</rapid-stepper-tab>
<rapid-stepper-tab>Step 2</rapid-stepper-tab>
<rapid-stepper-tab>Step 3</rapid-stepper-tab>
<rapid-stepper-tab-panel>
Tab Panel 1
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 2
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 3
</rapid-stepper-tab-panel>
</rapid-stepper>
Usage
@customElement({
name: 'my-element',
template: html`
<rapid-stepper @submit="${(x) => x.handleSubmit()}">
<rapid-stepper-tab>Step 1</rapid-stepper-tab>
<rapid-stepper-tab>Step 2</rapid-stepper-tab>
<rapid-stepper-tab>Step 3</rapid-stepper-tab>
<rapid-stepper-tab-panel>
Tab Panel 1
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 2
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 3
</rapid-stepper-tab-panel>
</rapid-stepper>
`,
})
export class MyElement extends GenesisElement {
@observable radioValue: string;
handleSubmit() {
console.log('Form submitted');
}
}
Declaration
<rapid-stepper>
<rapid-stepper-tab>Step 1</rapid-stepper-tab>
<rapid-stepper-tab>Step 2</rapid-stepper-tab>
<rapid-stepper-tab>Step 3</rapid-stepper-tab>
<rapid-stepper-tab-panel>
Tab Panel 1
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 2
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 3
</rapid-stepper-tab-panel>
</rapid-stepper>
Usage
export function MyComponent() {
const handleSubmit = (event) => {
console.log('Form submitted');
};
return (
<rapid-stepper onSubmit={handleSubmit}>
<rapid-stepper-tab>Step 1</rapid-stepper-tab>
<rapid-stepper-tab>Step 2</rapid-stepper-tab>
<rapid-stepper-tab>Step 3</rapid-stepper-tab>
<rapid-stepper-tab-panel>
Tab Panel 1
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 2
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 3
</rapid-stepper-tab-panel>
</rapid-stepper>
);
}
Declaration
<rapid-stepper>
<rapid-stepper-tab>Step 1</rapid-stepper-tab>
<rapid-stepper-tab>Step 2</rapid-stepper-tab>
<rapid-stepper-tab>Step 3</rapid-stepper-tab>
<rapid-stepper-tab-panel>
Tab Panel 1
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 2
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 3
</rapid-stepper-tab-panel>
</rapid-stepper>
Usage
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'my-root',
template: `
<rapid-stepper
(submit)="handleSubmit($event)"
>
<rapid-stepper-tab>Step 1</rapid-stepper-tab>
<rapid-stepper-tab>Step 2</rapid-stepper-tab>
<rapid-stepper-tab>Step 3</rapid-stepper-tab>
<rapid-stepper-tab-panel>
Tab Panel 1
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 2
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
Tab Panel 3
</rapid-stepper-tab-panel>
</rapid-stepper>
`,
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class AppComponent {
handleSubmit(event: Event) {
console.log('Form submitted');
}
}
API
Property and attribute binding examples for Genesis Component syntax.
Attributes
Name | Type | Description | Examples |
---|---|---|---|
hide-submit-button | boolean | Hides or shows the submit button |
|
orientation | string | There are two stepper orientations to choose from: vertical and horizontal. |
|
Properties
Name | Type | Description | Examples |
---|---|---|---|
validation |
| If set, the predicate function defined at index x is executed to check whether step x is valid when trying to move onto the subsequent step.
If the predicate returns false the stepper will not move to the next step. See this example. |
|
Slots
Slot |
---|
tab |
tab-panel |
action-buttons |
Parts
Part |
---|
stepper-tab |
stepper-tab-menu |
stepper-tab-progress |
progress-ring |
stepper-tab-panel |
stepper-panel-container |
action-buttons-container |
Events fired
Name | Type | Description | Example |
---|---|---|---|
@submit | void | Enables you to pass the function to be performed in the last step after clicking submit. |
|
Events listened to
This component doesn't listen to any events.
Advanced concepts
Validation
Use the validation field to set the condition for when the stepper permits the user to move forward.
You define the validation attribute as follows:
const template = html`
<rapid-stepper
:validation=${(x) => [
{
isValid: () => x.valid === '123' && x.valid2 === 'abc' && x.valid3 === 'test',
},
{ isValid: () => x.valid4 === 'abc' },
{ isValid: () => x.valid5 === 'finish' },
]}
@submit=${() => alert('You completed form')}
>
<rapid-stepper-tab>Step 1</rapid-stepper-tab>
<rapid-stepper-tab>Step 2</rapid-stepper-tab>
<rapid-stepper-tab>Step 3</rapid-stepper-tab>
<rapid-stepper-tab-panel>
<rapid-text-field style="margin-left: 10px;" value=${sync((x) => x.valid)}>
Must be equal to: 123
</rapid-text-field>
<rapid-text-field style="margin-left: 10px;" value=${sync((x) => x.valid2)}>
Must be equal to: abc
</rapid-text-field>
<rapid-text-field style="margin-left: 10px;" value=${sync((x) => x.valid3)}>
Must be equal to: test
</rapid-text-field>
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
<h5>Must be equal to: abc</h5>
<rapid-select style="margin: 10px 0 0 10px;" :value=${sync((x) => x.valid4)}>
<rapid-option>123</rapid-option>
<rapid-option>abc</rapid-option>
</rapid-select>
</rapid-stepper-tab-panel>
<rapid-stepper-tab-panel>
<rapid-text-field style="margin-left: 10px;" value=${sync((x) => x.valid5)}>
Must be equal to: finish
</rapid-text-field>
</rapid-stepper-tab-panel>
</rapid-stepper>
`;
The index of each array element is related to the corresponding tab position. Index number 1 is related to the first tab of the stepper, index number 2 is related to the second tab of the stepper, and so on.
In the example above, each tab only allows the user to proceed to the next step when the field isValid
receives a true
value.
If you want to perform more complicated logic tests to control how the user can proceed to the next step, you can define the logic in a separate function. Use the @submit
event to call that function.