CDN and script tags
No build step: one stylesheet and one script give a page every component.
A complete page
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:
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:
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:
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:
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 tag | Bundler (npm install) | |
|---|---|---|
| Loads | Every element, in one file | Only the elements you import |
| Good for | Prototypes, server-rendered pages, CMS themes, documentation | Applications |
| Types and wrappers | None | TypeScript 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.