Fine-tune light, shadows, borders, neumorphic
Light and shadows
Borders
Neumorphic

CDN and script tags

No build step: one stylesheet and one script give a page every component.

A complete page

<!doctype html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover" /> <title>My page</title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@prismora/[email protected]/dist/prismora.css" /> <script type="module" src="https://cdn.jsdelivr.net/npm/@prismora/[email protected]/dist/prismora.standalone.js"></script> </head> <body> <main class="pm-container pm-stack"> <pm-card heading="Welcome"> <pm-input label="Email" type="email" required></pm-input> <pm-button slot="footer" id="save">Continue</pm-button> </pm-card> </main> <script type="module"> await customElements.whenDefined('pm-button'); document.getElementById('save').addEventListener('click', () => Prismora.toast({ title: 'Saved', tone: 'success' })); </script> </body> </html>

prismora.css has the tokens, the default theme and every component's styles. prismora.standalone.js registers every element and puts the helpers on window.Prismora: toast, confirm, alert, registerIcons, setMobile and VERSION. The same files are on unpkg: replace cdn.jsdelivr.net/npm with unpkg.com.

Always pin the version

The addresses above name an exact version (0.2.0). Without one, a CDN serves whatever is newest, and a page can change under you. Use the same version for every @prismora/* file on the page.

Icons

Import the icons you use by name, straight from the CDN, and register them once:

<script type="module"> import { bell, check, star } from 'https://cdn.jsdelivr.net/npm/@prismora/[email protected]/dist/index.js'; await customElements.whenDefined('pm-icon'); Prismora.registerIcons([bell, check, star]); </script> <pm-button icon-start="check">Done</pm-button>

Browse the names on the icons page. Your own SVG works too: { name, body } on a 24 by 24 grid.

Your theme and dark mode

Design a theme in the generator, export it as CSS and load it after prismora.css (or build it once with npx @prismora/cli theme import "<link>" -o prismora.theme.css). The 3 KB browser runtime switches light and dark and remembers the choice:

<link rel="stylesheet" href="./prismora.theme.css" /> <!-- after prismora.css --> <script type="module"> import { ThemeController } from 'https://cdn.jsdelivr.net/npm/@prismora/[email protected]/dist/browser.js'; const theme = new ThemeController(); // remembers the choice in localStorage document.getElementById('dark').addEventListener('click', () => theme.set({ mode: theme.resolvedMode === 'dark' ? 'light' : 'dark' })); </script>

To avoid a flash of the wrong mode on load, put the no-flash script in <head>: npx @prismora/cli init --framework html writes a page with it, or copy it from the plain HTML example.

Subresource integrity

With an integrity attribute the browser refuses a file that is not byte for byte the one you checked. Work out the value for the exact version you load:

curl -sL https://cdn.jsdelivr.net/npm/@prismora/[email protected]/dist/prismora.standalone.js | openssl dgst -sha384 -binary | openssl base64 -A <script type="module" crossorigin="anonymous" src="https://cdn.jsdelivr.net/npm/@prismora/[email protected]/dist/prismora.standalone.js" integrity="sha384-…the value the command printed…"></script>

jsDelivr also shows the value for every file under "Copy HTML + SRI" on the package page. Do the same for the stylesheet.

Content Security Policy

A policy for a page that loads Prismora from jsDelivr:

default-src 'self'; script-src 'self' https://cdn.jsdelivr.net; style-src 'self' https://cdn.jsdelivr.net; style-src-attr 'unsafe-inline'; img-src 'self' data:;

Elements load their styles as constructable stylesheets, which a policy does not block. Some components set style attributes for sizes and positions, hence style-src-attr (a style attribute cannot run code). With this policy, scripts written inside the page (like the one in the example above) must move to a file, or be allowed by hash or nonce. More in troubleshooting.

When to use a bundler instead

Script tagBundler (npm install)
LoadsEvery element, in one fileOnly the elements you import
Good forPrototypes, server-rendered pages, CMS themes, documentationApplications
Types and wrappersNoneTypeScript types; React, Vue, Svelte, Solid and Angular components

Moving later is one command: npx @prismora/cli init in a project with a bundler. The markup stays the same.