Skip to content

@ghs-hazard-pictograms/core

Terminal window
npm install @ghs-hazard-pictograms/core

Returns an array of all pictograms.

import { getAllPictograms } from '@ghs-hazard-pictograms/core';
const pictograms = getAllPictograms();
// Pictogram[]

Returns a single pictogram by its ID, or undefined if not found.

import { getPictogram } from '@ghs-hazard-pictograms/core';
const pictogram = getPictogram('ghs01-explosives-exploding-bomb');
// Pictogram | undefined

Returns all pictograms belonging to a given category.

import { getPictogramsByCategory } from '@ghs-hazard-pictograms/core';
const healthHazards = getPictogramsByCategory('health');
// Pictogram[]
interface Pictogram {
id: string; // e.g. 'ghs01-explosives-exploding-bomb'
code: string; // e.g. 'GHS01'
name: string; // e.g. 'Exploding bomb'
description: string; // Human-readable description
category: PictogramCategory;
svg: string; // Inline SVG markup
assets: PictogramAssets;
}
type PictogramCategory = 'physical' | 'health' | 'environmental' | 'transport';
ValueDescription
physicalPhysical hazards (explosives, flammables, etc.)
healthHealth hazards (toxic, corrosive, etc.)
environmentalEnvironmental hazards
transportTransport hazard pictograms
interface PictogramAssets {
svg: string;
png: {
240: string;
512: string;
768: string;
1024: string;
2048: string;
};
}

The values are paths relative to the @ghs-hazard-pictograms/assets package root.

import { getAllPictograms, getPictogramsByCategory } from '@ghs-hazard-pictograms/core';
import type { Pictogram, PictogramCategory } from '@ghs-hazard-pictograms/core';
function listByCategory(category: PictogramCategory): void {
const items = getPictogramsByCategory(category);
items.forEach((p: Pictogram) => {
console.log(`${p.code}${p.name}`);
});
}
listByCategory('physical');