npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-simple-stepper

v1.1.1

Published

Stepper component designed to guide users through a multi-step process, like a registration form or setup process. It provides a clear indication of the current, completed, and upcoming steps, and also allows for navigating between these steps.

Downloads

32

Readme

Stepper Component

Stepper component designed to guide users through a multi-step process, like a registration form or setup process. It provides a clear indication of the current, completed, and upcoming steps, and also allows for navigating between these steps.

Features

  • Dynamically renders a specified number of steps based on the steps prop.
  • Keeps track of the current step and which steps have been visited.
  • Allows for customization of the action buttons via slots.
  • Emits events when the user navigates through the steps.
  • Handles step navigation logic, showing and hiding appropriate elements as needed.
  • Lazy loads content components as needed

Installation

Install it from npm

npm install vue-simple-stepper

You need to import the component doing:

import VueSimpleStepper from 'vue-simple-stepper'

And its styles like this:

import "vue-simple-stepper/dist/style.css";

Use

The easiest way to use is to copy and throw this in your code:

<template>
  <vue-simple-stepper
    :steps="state.steps"
    :step="state.step"
    @click:next="nextStep"
    @click:previous="previousStep"
    @click:submit="submitStep"
  >
    <div class="content first">asdfasd</div>
    <div class="content second">asdfasd</div>
    <div class="content third">asdfasd</div>
  </vue-simple-stepper>
</template>

<script setup>
import { reactive } from "vue";

import "vue-simple-stepper/dist/style.css";

import VueSimpleStepper from "vue-simple-stepper";

const state = reactive({
  steps: ["Step 1", "Step 2", "Step 3"],
  step: 1,
});

const nextStep = () => {
  state.step++;
};

const previousStep = () => {
  state.step--;
};

const submitStep = () => {
  console.log("Step submitted");
};
</script>

Any element found in the default slot of the component will be automatically added to the stepper. Notice that the steps data prop number coincides with the number of elements in the stepper.

You can set a default starting point of the component with the step prop. With it you can also control the stepper programmatically.

Any time the actions of the stepper are clicked the events:

  • click:next
  • click:previous
  • click:submit Are going to be emitted in by the stepper on click of the respective action.

One common problem is the customization of the stepper to fit the framework or styles of choice. In that case you can do it by using the CSS variables:

:root {
  --vue-simple-stepper-primary-color: #c724f0;
  --vue-simple-stepper-primary-color-contrast: white;

  --vue-simple-stepper-button-hover-color: #b11dd6;

  --vue-simple-stepper-secondary-color: #d8ceda;
  --vue-simple-stepper-secondary-color-contrast: black;

  --vue-simple-stepper-divider-color: var(--vue-simple-stepper-primary-color);
  --vue-simple-stepper-divider-color-neutral: var(
    --vue-simple-stepper-secondary-color
  );
}

Or in case you want to further customize the buttons you can overwrite or extend these classes:

.vue-simple-stepper-button {
  border-radius: 8px;
  padding: 0.6em 1.2em;
  border: 0;
  font-size: 1em;
  font-weight: 500;
  font-family: inherit;
  background-color: var(--vue-simple-stepper-primary-color);
  cursor: pointer;
  transition: border-color 0.25s;
}
.vue-simple-stepper-button:hover {
  background-color: var(--vue-simple-stepper-button-hover-color);
}

.vue-simple-stepper-button--outlined {
  border: 1px solid var(--vue-simple-stepper-primary-color);
  color: black;
  background-color: transparent;
}

.vue-simple-stepper-button--outlined:hover {
  background-color: transparent;
  border-color: var(--vue-simple-stepper-button-hover-color);
}

.vue-simple-stepper-button:focus,
.vue-simple-stepper-button:focus-visible {
  outline: 4px auto -webkit-focus-ring-color;
}

In case that you need to overwrite completely the action buttons do it by using the actions slot like so:

<template>
  <vue-simple-stepper
    :steps="state.steps"
    :step="state.step"
    @click:next="nextStep"
    @click:previous="previousStep"
    @click:submit="submitStep"
  >
    <div class="content first">asdfasd</div>
    <div class="content second">asdfasd</div>
    <div class="content third">asdfasd</div>

    <template
      #actions="{
        clickNext,
        clickPrevious,
        clickSubmit,
        isFirstStep,
        isLastStep,
      }"
    >
      <div>
        <button @click="clickPrevious" v-if="!isFirstStep">Previous</button>
        <button @click="clickNext" v-if="!isLastStep">Next</button>
        <button @click="clickSubmit" v-if="isLastStep">Submit</button>
      </div>
    </template>
  </vue-simple-stepper>
</template>

<script setup>
import { reactive } from "vue";

import "vue-simple-stepper/dist/style.css";

import VueSimpleStepper from "vue-simple-stepper";

const state = reactive({
  steps: ["Step 1", "Step 2", "Step 3"],
  step: 1,
});

const nextStep = () => {
  state.step++;
};

const previousStep = () => {
  state.step--;
};

const submitStep = () => {
  console.log("Step submitted");
};
</script>

Props

  • steps: An array that defines the steps in the stepper. The length of the array determines the number of steps. Default is an empty array.
  • step: A number indicating the current step. Starts from 1 and default is 1.

Events

  • click:next: Triggered when the next button is clicked.
  • click:previous: Triggered when the previous button is clicked.
  • click:submit: Triggered when the submit button is clicked.

Slots

  • actions: For customizing the action buttons (next, previous, submit) of the stepper.