
Security News
Meet the Socket Team at RSAC and BSidesSF 2025
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.
@stoplight/elements
Advanced tools
UI components for composing beautiful developer documentation
# latest stable
yarn add @stoplight/elements
import { Page, Provider, TableOfContents } from '@stoplight/elements';
import { Docs } from '@stoplight/elements/components/Docs';
import { TryIt } from '@stoplight/elements/components/TryIt';
<Provider
host="https://stoplight.io/api"
components={{
link: ({ node, children }) => {
// Render a custom link component
return (
<a href={node.url} title={node.title}>
{children}
</a>
);
},
}}
>
<div className="flex">
<TableOfContents srn="gh/stoplightio/studio-demo" />
<Page
className="flex-1"
srn="gh/stoplightio/studio-demo/docs/introduction.md"
tabs={({ node }) => {
const tabs = [{ title: 'Docs', content: <Docs node={node} /> }];
if (node.type === 'http_operation') {
tabs.push({ title: 'Try It', content: <TryIt value={node.data} /> });
}
return tabs;
}}
/>
</div>
</Provider>;
Elements can be used as a plain JS library.
Load the elements library:
Add the following script tag to the head tag of your website, BEFORE other css or script tags.
<head>
<!-- Stoplight Elements -->
<link
rel="stylesheet"
href="https://stoplight.io/static/elements/bundle.v1.css"
media="print"
onload="this.media='all'"
/>
<script async defer src="https://stoplight.io/static/elements/bundle.v1.js" onload="__onElementsLoad()"></script>
<script>
function __onElementsLoad() {
// Let elements know where the Stoplight API is running
SL.config.host = 'https://stoplight.io/api';
// Emit the SL.ready event so that any code that needs SL can start using it
window.dispatchEvent(new Event('SL.ready'));
}
</script>
<!-- End Stoplight Elements -->
<!-- ... other script and css elements -->
</head>
Global "SL" object:
The global variable made available on the page after the elements library has been loaded.
declare namespace SL {
interface IWidget {
srn: string;
render(htmlId: string, srn: string): void;
remove(): void;
}
// React.createElement
const createElement: any;
const config: {
host?: string;
token?: string;
components?: any;
};
const elements: {
hub: IWidget;
page: IWidget;
toc: IWidget;
};
}
Render a table of contents onto the page:
// Takes two arguments - the html element id, and a stoplight SRN for the project table of contents to render.
SL.elements.toc.render('toc-container-element-id', 'gh/stoplightio/studio-demo');
Render a specific page:
// Takes two arguments - the html element id, and a stoplight SRN for the node to render (article, api, model, http operation, etc).
SL.elements.page.render('page-container-element-id', 'gh/stoplightio/studio-demo/docs/introduction.md');
feature/{name}
, chore/{name}
, or fix/{name}
branch.yarn
.yarn test.prod
.yarn commit
. NOTE: Commits that don't follow the conventional format will be rejected. yarn commit
creates this format for you, or you can put it together manually and then do a regular git commit
.git push
.master
branch.FAQs
UI components for composing beautiful developer documentation.
We found that @stoplight/elements demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.
Security News
Biome's v2.0 beta introduces custom plugins, domain-specific linting, and type-aware rules while laying groundwork for HTML support and embedded language features in 2025.
Security News
Next.js has patched a critical vulnerability (CVE-2025-29927) that allowed attackers to bypass middleware-based authorization checks in self-hosted apps.