Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question]: How to use icons from string? #72

Closed
r-priyam opened this issue Sep 28, 2021 · 2 comments
Closed

[Question]: How to use icons from string? #72

r-priyam opened this issue Sep 28, 2021 · 2 comments

Comments

@r-priyam
Copy link

When using the icons with strings it's not working in component. How to get it working, please? Sample code -

<template>
    <div>
        <nav class="grid gap-y-8">
            <a
		v-for="item in solutions"
		:key="item.name"
		:href="item.href"
		class="-m-3 p-3 flex items-center rounded-md"
	   >
		<component :is="item.icon" class="flex-shrink-0 h-6 w-6 text-black" aria-hidden="true" />
		<span class="ml-3 text-base font-medium text-gray-200">{{ item.name }}</span>
	   </a>
	</nav>
</div>

<script setup lang="ts">

const solutions = [
	{
		name: 'Item',
		description: 'Go to item',
		href: '#',
		icon: 'heroicons-outline:chart-bar',
	},
	{
		name: 'Item',
		description: 'Go to item',
		href: '#',
		icon: 'heroicons-outline:cursor-click',
	},
];

</script>
@antfu
Copy link
Member

antfu commented Oct 1, 2021

#5

As a workaround:

+ import ChartBar from '~icons/heroicons-outline/chart-bar'
+ import CursorClick from '~icons/heroicons-outline/cursor-click'

const solutions = [
	{
		name: 'Item',
		description: 'Go to item',
		href: '#',
-		icon: 'heroicons-outline:chart-bar',
+       icon: ChartBar
	},
	{
		name: 'Item',
		description: 'Go to item',
		href: '#',
-		icon: 'heroicons-outline:cursor-click',
+       icon: CursorClick
	},
];

@antfu antfu closed this as completed Oct 1, 2021
@r-priyam
Copy link
Author

r-priyam commented Oct 2, 2021

That worked, Thank you :)

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

No branches or pull requests

2 participants