@odx/pictograms
v7.0.0
Published
A library of pictogram assets for ODX
Readme
@odx/pictograms
A lightweight library for displaying pictograms as custom elements. This package provides flexible imports, allowing you to include only what you need to optimize your project.
Installation
Install using NPM:
npm i @odx/pictogramsInstall using PNPM:
pnpm add @odx/pictogramsUsage
The library provides a custom custom element <odx-pictogram> to display pictograms. You can choose between different sets or import individual pictograms to reduce your bundle size.
We rely on the esm module behavior in order to keep a global state. If you load an asset from a CDN ensure that the same module of @odx/assets-utils is used throughout your application. One common technique is the usage of an import map (
<script type="importmap">).
Import custom element:
import '@odx/pictograms';Import specific pictogram sets
To optimize your bundle, you can import only the specific pictogram set you need:
// All pictogram sets
import '@odx/pictograms/all';
// Default pictograms (default set)
import '@odx/pictograms/symbols';Import individual pictograms
To optimize your bundle, you can import only the specific pictograms you need:
import '@odx/pictograms/symbols/added-value';Element API
Set the CSS font-size property on the element to define a custom size.
Properties
- name: string - Name in the format
set::name
Deprecated
- set: string - Use name property with format
set::nameinstead
Example Usage
HTML Example
<script type="module">
import '@odx/pictograms';
import '@odx/pictograms/symbols';
</script>
<odx-pictogram name="symbols::added-value"></odx-pictogram>JavaScript Example
// Import the symbols pictogram set
import '@odx/pictograms/symbols';
// Create a pictogram dynamically
const pictogram = document.createElement('odx-pictogram');
pictogram.name = 'symbols::added-value';
document.body.appendChild(pictogram);SVG Import (Node.js / Bundler)
import addedValue from '@odx/pictograms/symbols/added-value.svg';Browser Support
This library leverages modern web technologies such as Shadow DOM for encapsulation and CSSStyleSheet.replaceSync() for efficient stylesheet updates. It targets the ES2022 specification, taking advantage of the latest JavaScript features. These technologies are widely supported in most modern browsers.
Supported Browsers:
- Chrome 97+
- Edge 97+
- Firefox 104+
- Safari 16.4+
- Opera 83+
Live demo ⭐
For a overview of all available assets please refer to our Asset Viewer.
