Skip to content

Lucide won't render data-lucide if inside <template> #2635

@dotfrag

Description

@dotfrag

Package

  • lucide
  • lucide-angular
  • lucide-flutter
  • lucide-preact
  • lucide-react
  • lucide-react-native
  • lucide-solid
  • lucide-svelte
  • lucide-vue
  • lucide-vue-next
  • Figma plugin
  • source/main
  • other/not relevant

Version

0.460.0

Can you reproduce this in the latest version?

  • Yes
  • No

Browser

  • Chrome/Chromium
  • Firefox
  • Safari
  • Edge
  • iOS Safari
  • Opera
  • Other/not relevant

Operating system

  • Windows
  • Linux
  • macOS
  • ChromeOS
  • iOS
  • Android
  • Other/not relevant

Description

I'm using the Content Template element (<template>) to render parts of an HTML form that I use as a template (duh) within JavaScript. Elements with data-lucide inside the template tag do not render.

Steps to reproduce

  1. Minimal setup from guide (all icons)
  2. The following input HTML:
    <div>
       <template><i data-lucide="trash-2" class="size-6 stroke-red-600 mx-auto"></i></template>
       <i data-lucide="trash-2" class="size-6 stroke-red-600 mx-auto"></i>
    </div>
  3. Results in:
        <div>
          <template><i data-lucide="trash-2" class="size-6 stroke-red-600 mx-auto"></i></template>
          <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" data-lucide="trash-2" class="lucide lucide-trash-2 size-6 stroke-red-600 mx-auto"><path d="M3 6h18"></path><path d="M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"></path><path d="M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"></path><line x1="10" x2="10" y1="11" y2="17"></line><line x1="14" x2="14" y1="11" y2="17"></line></svg>
    </div>

Checklist

  • I have searched if someone has submitted a similar issue before and there weren't any. (Please make sure to also search closed issues, as this issue might already have been resolved.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    🐛 bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions