Skip to content

@ghs-hazard-pictograms/vue

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

Every pictogram is available as a named Vue component. The component name follows the same PascalCase convention as the React package.

<script setup lang="ts">
import { Ghs01ExplosivesExplodingBomb } from '@ghs-hazard-pictograms/vue';
</script>
<template>
<Ghs01ExplosivesExplodingBomb :width="64" :height="64" title="Explosives" />
</template>

Component names follow the pattern Ghs{nn}{Category}{Name}, e.g.:

Pictogram IDComponent name
ghs01-explosives-exploding-bombGhs01ExplosivesExplodingBomb
ghs02-flammable-flameGhs02FlammableFlame
ghs06-toxic-skull-crossbonesGhs06ToxicSkullCrossbones

Use PictogramById when the pictogram ID is determined at runtime.

<script setup lang="ts">
import { PictogramById } from '@ghs-hazard-pictograms/vue';
const props = defineProps<{ hazardId: string }>();
</script>
<template>
<PictogramById :id="hazardId" :width="64" :height="64" />
</template>
PropTypeRequiredDefaultDescription
widthnumberNo24Width of the SVG in pixels
heightnumberNo24Height of the SVG in pixels
titlestringNopictogram nameAccessible title rendered as <title>
descriptionstringNoAccessible description rendered as <desc>

Use Vue’s :prop binding syntax for dynamic values (e.g. :width="iconSize").

PropTypeRequiredDescription
idstringYesPictogram ID, e.g. ghs01-explosives-exploding-bomb

All components ship with full type declarations. Import the shared Pictogram type from @ghs-hazard-pictograms/core when you need to type pictogram data in your composables or stores.

import type { Pictogram } from '@ghs-hazard-pictograms/core';

Each component renders an inline SVG. Providing title injects a <title> element and sets aria-labelledby on the SVG root. Adding description appends a <desc> element included in the same aria-labelledby value.

Pass aria-hidden="true" for decorative icons to remove them from the accessibility tree.

<Ghs01ExplosivesExplodingBomb aria-hidden="true" :width="24" />