Skip to content

Vanilla JS (CDN)

How to use Plus UI directly in any HTML page with a CDN.

You can use Plus UI in any project without a build step or framework, simply by including our files from a CDN.

Add the component script using a <script type="module"> tag, typically at the end of your <body>. We recommend using jsDelivr as a CDN.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plus UI with Vanilla JS</title>
</head>
<body>
<!-- Your components go here -->
<plus-button>Click Me</plus-button>
<!-- Include the Plus UI component script -->
<script type="module" src="https://cdn.jsdelivr.net/npm/@plusui/core/cdn/components/index.js"></script>
</body>
</html>

You can now use any Plus UI component by adding its HTML tag to your page.

Component properties are set using standard HTML attributes.

<plus-button variant="filled" size="large">
Large Filled Button
</plus-button>

You can listen for events using standard JavaScript addEventListener.

<plus-button id="my-button">Click Me</plus-button>
<script>
const button = document.getElementById('my-button');
button.addEventListener('plus-click', () => {
alert('Button was clicked!');
});
</script>

Here is a complete index.html file that you can use as a starting point.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Plus UI - Vanilla JS Example</title>
<style>
body { padding: 2rem; display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
</style>
</head>
<body>
<h1>Welcome to Plus UI!</h1>
<plus-button variant="secondary" id="secondary-button">
Secondary Button
</plus-button>
<plus-button variant="filled" id="filled-button">
Filled Button
</plus-button>
<script type="module">
import 'https://cdn.jsdelivr.net/npm/@plusui/core/cdn/components/index.js';
document.getElementById('secondary-button').addEventListener('plus-click', () => {
alert('Secondary button clicked!');
});
document.getElementById('filled-button').addEventListener('plus-click', () => {
alert('Filled button clicked!');
});
</script>
</body>
</html>

Join the Community

Plus UI is built by the community. Join us on our platforms to contribute, get help, and stay up to date.