HexagonJS
Edit Page
Stepper
Provides the Stepper component for managing a user workflow with multiple steps.
Examples

HTML

<div id="stepper-controls"></div>
<br />
<div id="stepper"></div>

JavaScript

const stepperDiv = hx.select('#stepper');

const stepper = new hx.Stepper(stepperDiv, [
  'First step title',
  'Second step title',
  'Third step: This has a title that may wrap onto multiple lines',
  'Fourth step title',
]);

hx.select('#stepper-controls')
  .add(hx.div()
    .add(hx.button('hx-btn')
      .text('Set step to 2')
      .on('click', () => stepper.selectedStep(2)))
    .add(hx.button('hx-btn')
      .text('Previous Step')
      .on('click', () => stepper.prevStep()))
    .add(hx.button('hx-btn')
      .text('Next Step')
      .on('click', () => stepper.nextStep()))
    .add(hx.button('hx-btn')
      .text('Toggle Error')
      .on('click', () => stepper.showError(!stepper.showError())))
    .add(hx.button('hx-btn')
      .text('Toggle Titles')
      .on('click', () => stepper.showTitles(!stepper.showTitles()))));
Api
Prototypes
hx.Stepper
A component for managing a user workflow with multiple steps.
Constructors
hx.StepperselectorString / HTMLElement / SelectionstepsArray[String]optionsObject
Creates a Stepper
Arguments
selectorString / HTMLElement / Selection
The selector to create the stepper inside. This should be an empty element.
The array of steps to show. These are the titles to display in the stepper.
In cases where your stepper always has 'showTitles' as false, you can pass an array of any truthy value, although it's generally best to use a unique ID for each step.
options
Properties
selectedStepNumber
The currently selected step. This value is one based (i.e. the first value is 1 as opposed to 0)
showErrorBoolean
Whether the currently selected step has an error
showTitlesBoolean
Whether the titles should be shown
Methods
nextStepStepper
Decrements the selected step.
Analagous to:
stepper.selectedStep(stepper.selectedStep() - 1)
Returns
Stepper
This stepper for chaining
prevStepStepper
Increments the selected step.
Analagous to:
stepper.selectedStep(stepper.selectedStep() + 1)
Returns
Stepper
This stepper for chaining
selectedStepNumber
Gets the selected step index
Returns
The selected step (one based)
selectedStepstepNumberStepper
Sets the selected step index
Arguments
stepNumber
The step to select (one based)
Returns
Stepper
This stepper for chaining
showErrorBoolean
Gets the current value for whether the current step has an error
Returns
Whether the current step has an error
showErrorshowBooleanStepper
Sets the current value for whether the current step has an error
Arguments
whether the current step has an error
Returns
Stepper
This stepper for chaining
showTitlesBoolean
Gets the current value for whether the titles should be shown
Returns
Whether the titles are shown
showTitlesshowBooleanStepper
Sets the current value for whether the titles should be shown
Arguments
Whether the titles should be shown
Returns
Stepper
This stepper for chaining
Gets the current steps
Returns
The currently set steps
stepsstepsArray[String]Stepper
Sets the current steps
Arguments
The steps to set
Returns
Stepper
This stepper for chaining