Skip to content

Passing alternative content to dynamically imported SVGs #77

@retroriff

Description

@retroriff

To dynamically import an SVG, we can use the inline require() syntax.

<template>
  <div v-html="require(`../assets/${name}.svg?raw`)" />
</template>

<script>
  export default {
    props: {
      name: { type: String, default: "image" },
    },
  };
</script>

As far as I now, this method does not allow to dynamically pass a title and a description to the inline SVG, which would be great for accessibility on multilanguage sites.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions