Installing Spark in an HTML Project
Adding Spark Components
Now you’re ready to start writing the HTML to build the structure of the components you’ll be using. Here we’ll cover how to add components for HTML, CSS and JavaScript environments with no JavaScript framework. You can follow along with the code examples in this guide using the sample app found in our starter repository.
This guide is Part 3 in a 3-Part series. You can also check out Part 1 - Setting Up Your Environment and Part 2 - Installation.
For instructions on setting up Spark in other environments, check out the guides for Angular and React development environments.
Navigating to Component HTML
To get started, select the Using Spark tab at the top of this page. This is where you’ll find all the HTML you’ll need for the component variants and configurations you can use.
Underneath the Components section in the left column, find the component you want to add.
For example: Let’s say you’re trying to add a Loading Button. You’d select the Button component.
Click the HTML link to view the HTML documentation.
Navigate to the Docs tab at the top of the screen.
Scroll down until you see the component variant you would like to include in your site.
Click Show code.
Copy the sample code into
index.html
.
For example: If you’re adding a Loading Button, you’d scroll down on the Button page to find Loading Button. Then you’d copy the Loading Button code that looks like this:
<button class="sprk-c-Button" data-sprk-spinner="click">Submit</button>
Note: Make sure you’re including
main.js
after the HTML elements inindex.html
. The<script>
line should be at the bottom of the<body>
tag.
- You should see the component you just installed with all the correct Spark CSS applied.
For example: If you’ve added a Loading Button you’ll see something like this…
You did it!
You’re ready to start building with Spark!
Additional Topics
- The Icon Installation Guide for importing the Spark SVG icon set.
- The Font Installation Guide for instructions on using the Rocket Sans font.