Skip to content

feat: support add inline svg icons#2468

Open
zhangfisher wants to merge 1 commit intoshoelace-style:nextfrom
zhangfisher:next
Open

feat: support add inline svg icons#2468
zhangfisher wants to merge 1 commit intoshoelace-style:nextfrom
zhangfisher:next

Conversation

@zhangfisher
Copy link

feat: add custom inline svg icon

import { getIconLibrary } from '@shoelace-style/shoelace'
const defaultIcons = getIconLibrary('default')
defaultIcons.add("phone",`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"><path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"/></svg>`)

Inline icons embedded with SVG data,This can help the application build in icons。

inline svg icon support custom icon library,

import { getIconLibrary } from '@shoelace-style/shoelace'
const customIcons = registerIconLibrary('xxxx',{
     inlineIcons:{
         phone,`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-linecap="round" stroke- linejoin="round"><path d="M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384"/></svg>`
  })

Inline icons have resolver priority and are resolved using custom resolver only when there is no match

@vercel
Copy link

vercel bot commented Jun 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
shoelace ✅ Ready (Inspect) Visit Preview Jun 19, 2025 2:56am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant