This guide shows you how to install and set up the Energy Label in your project.
You can install the Energy Label in different ways. Choose the method that works best for your project:
Install using your preferred package manager:
npm install energy-label@beta
Requirements
- Node.js version 18 or higher
- Any modern package manager (npm, yarn, pnpm, or bun)
After installation, the energy-label package will be available in your node_modules folder.
For quick testing or projects without a build system, you can load the library directly from a CDN:
<script type="module">
import EnergyLabel from 'https://esm.sh/energy-label@beta'
// Your code here
</script>
If you want to build the distribution files yourself:
git clone https://github.com/marcmarine/energy-label.git
cd energy-label
npm install
npm run build
dist folder:<script type="module" src="./dist/index.js"></script>
The library includes TypeScript definitions. No extra packages needed.
import { createEnergyLabel, type SmartphonesAndTabletsData } from 'energy-label'
const labelData: SmartphonesAndTabletsData = {
flagOrigin: 'EU',
supplierOrTrademark: 'Sultana',
modelIdentifier: '92COU8944VK',
energyClass: 'B'
}
const label = createEnergyLabel('smartphones', labelData)
Now you can create your first energy label! Check out these guides: