Home >Web Front-end >JS Tutorial >Introducing Your Application with Shepherd
<span>var tour = new Shepherd<span>.Tour</span>({ </span> <span>defaults: { </span> <span>classes: 'shepherd-theme-arrows', </span> <span>scrollTo: true </span> <span>} </span><span>}); </span> tour<span>.addStep('myStep', { </span> <span>title: 'Hi there!', </span> <span>text: 'This would help you get started with this application!', </span> <span>attachTo: '#id_selector bottom', </span> <span>classes: 'shepherd shepherd-open shepherd-theme-arrows shepherd-transparent-text', </span> <span>buttons: [ </span> <span>{ </span> <span>text: 'Exit', </span> <span>classes: 'shepherd-button-secondary', </span> <span>action: function() { </span> <span>return tour.hide(); </span> <span>} </span> <span>} </span> <span>] </span><span>});</span>
<span><span><span><link</span> type<span>="text/css"</span> rel<span>="stylesheet"</span> href<span>="css/shepherd-theme-arrows.css"</span> /></span> </span><span><span><span><script</span> type<span>="text/javascript"</span> src<span>="./shepherd.min.js"</span>></span><span><span></script</span>></span></span>
tour <span>= new Shepherd<span>.Tour</span>({ </span> <span>defaults: { </span> <span>classes: 'shepherd-theme-arrows', </span> <span>scrollTo: true </span> <span>} </span><span>});</span>
tour<span>.addStep('myStep', { </span> <span>title: 'Hi there!', </span> <span>text: 'This would help you get started with this application!', </span> <span>attachTo: '#id_selector bottom', </span> <span>classes: 'shepherd shepherd-open shepherd-theme-arrows shepherd-transparent-text', </span> <span>buttons: [ </span> <span>{ </span> <span>text: 'Exit', </span> <span>classes: 'shepherd-button-secondary', </span> <span>action: function() { </span> <span>return tour.hide(); </span> <span>} </span> <span>} </span> <span>] </span><span>});</span>You can attach an additional button if you plan to have multiple steps. The following is an example of how to use buttons if you have two steps:
tour<span>.addStep('step1', { </span> <span>... </span> <span>buttons: [ </span> <span>{ </span> <span>text: 'Exit', </span> <span>classes: 'shepherd-button-secondary', </span> <span>action: function() { </span> <span>return tour.hide(); </span> <span>} </span> <span>}, { </span> <span>text: 'Next', </span> <span>action: tour.next, </span> <span>classes: 'shepherd-button-example-primary' </span> <span>} </span> <span>] </span><span>}); </span> tour<span>.addStep('step2', { </span> <span>... </span> <span>buttons: [ </span> <span>{ </span> <span>text: 'Back', </span> <span>action: tour.back, </span> <span>classes: 'shepherd-button-example-primary' </span> <span>}, { </span> <span>text: 'Exit', </span> <span>classes: 'shepherd-button-secondary', </span> <span>action: function() { </span> <span>return tour.hide(); </span> <span>} </span> <span>} </span> <span>] </span><span>});</span>
tour<span>.start();</span>
myTour <span>= new Shepherd<span>.Tour</span>({ options })</span>Now, we are going to see how we can work with this instance. steps and defaults are the options of the tour instance. Its methods are described below.
Application Shepherd is a JavaScript library that guides users through your app. It’s different from Shepherd.js in that it’s designed to be more user-friendly and easier to implement. While Shepherd.js is a powerful tool, it requires a deeper understanding of JavaScript to use effectively. Application Shepherd, on the other hand, is designed to be accessible to developers of all skill levels, with a simple API and clear documentation.
Installing Application Shepherd is straightforward. You can install it via npm using the command npm install application-shepherd. Once installed, you can import it into your project using import Shepherd from 'application-shepherd'.
Yes, Application Shepherd allows for extensive customization. You can change the color, size, position, and more of the guide elements. This allows you to create guides that match the look and feel of your app, providing a seamless user experience.
Application Shepherd is designed to handle complex guides with ease. You can create multi-step guides that guide users through a series of tasks. Each step can have its own text, position, and actions, allowing you to create detailed, interactive guides.
Absolutely. Application Shepherd is designed to be easy to integrate with existing codebases. It’s a standalone library, so it doesn’t require any specific framework or technology to use. You can simply import it into your project and start creating guides.
Application Shepherd stands out for its ease of use and flexibility. While other libraries may require more technical knowledge to use effectively, Application Shepherd is designed to be accessible to developers of all skill levels. It also offers extensive customization options, allowing you to create guides that match the look and feel of your app.
Yes, Application Shepherd is designed to work well on both desktop and mobile devices. The guides automatically adjust to fit the screen size, ensuring a great user experience on all devices.
Yes, Application Shepherd is an excellent tool for onboarding new users. You can create detailed, step-by-step guides that walk new users through your app, helping them understand how to use it effectively.
Updating or modifying guides is easy with Application Shepherd. You can simply change the properties of the guide steps in your code, and the changes will be reflected in the guide. This allows you to keep your guides up-to-date as your app evolves.
While there isn’t a dedicated community or support network for Application Shepherd, you can find help and advice on general JavaScript and web development forums and communities. The documentation for Application Shepherd is also a great resource for learning how to use the library effectively.
The above is the detailed content of Introducing Your Application with Shepherd. For more information, please follow other related articles on the PHP Chinese website!