Stoplight Elements provides components that can be used in any React application. This example project demonstrates usage with Gatsby.
Clone the @stoplight/elements-starter-gatsby and install dependencies.
git clone https://github.com/stoplightio/elements-starter-gatsby.git
cd elements-starter-gatsby
yarn
Alternatively install it as a Gatsby starter using gatsby-cli
.
yarn global add gatsby-cli
gatsby new elements-starter-gatsby https://github.com/stoplightio/elements-starter-gatsby
cd elements-starter-gatsby
yarn
If the above was successful, you can launch the example project using yarn start
.
Now if you open your browser and navigate to http://localhost:8000/
as instructed, you will see a page with two links to Stoplight Elements components.
Install Elements and it's peer dependencies:
yarn add @stoplight/elements @stoplight/prism-http mobx
You can import the CSS file directly into your component files
import '@stoplight/elements/styles/elements.min.css';
or into your CSS
@import '~@stoplight/elements/styles/elements.min.css';
Congratulations! At this point, you are ready to use Stoplight Elements in your Gatsby application.