I've been using Heroicons but due to it's lack of icons, I decided to switch to FontAwesome. I set it up and am able to use it like so <font-awesome-icon icon="fa-brands fa-stack-overflow" />
.
However with Heroicons and HeadlessUI tabs I had a setup like this;
<template>
<div>
<TabList class="-mb-px flex space-x-8">
<Tab v-for="tab in type" :key="tab.name" v-slot="{ selected }" class="outline-none">
<button
:class="[
selected
? 'border-violet-500 text-violet-600'
: 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700',
'group inline-flex items-center border-b-2 py-4 px-1 text-sm font-medium',
]"
:aria-current="selected ? 'page' : undefined"
>
<component
:is="tab.icon"
:class="[
selected
? 'text-violet-500'
: 'text-gray-400 group-hover:text-gray-500',
'-ml-0.5 mr-2 h-5 w-5',
]"
/>
<span>{{ tab.name }}</span>
</button>
</Tab>
</TabList>
</div>
</template>
<script setup>
import { TabGroup, TabList, Tab, TabPanels, TabPanel } from '@headlessui/vue'
import { BellIcon, BoltIcon } from '@heroicons/vue/24/outline'
const type = [
{ name: 'Notifications', icon: BellIcon },
{ name: 'Boost', icon: BoltIcon },
]
const selectedTab = ref(0)
function tabsEvent(index) {
selectedTab.value = index
}
</script>
Which would resulted in a list of icons in my tabs.
How can I use FontAwesome the same way or at least in a way that would be a replacement for the way I've been using it with Heroicons?
I believe I need to do something like this but I couldn't quite wrap my head around it;
<template>
<!-- rest of the code related to tabs -->
...
<!-- iconType is like far, fas, fab etc. -->
<font-awesome-icon :icon="tab.iconType + tab.icon" />
...
<!-- rest of the code related to tabs -->
</template>
<script>
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { faBell, faBolt } from '@fortawesome/free-regular-svg-icons'
export default {
name: 'tabIcons',
data() {
return {
myBellIcon: faBell,
myBoltIcon: faBolt,
}
},
components: {
FontAwesomeIcon,
},
}
const type = [
{ name: 'Notifications', icon: myBellIcon, iconType: far },
{ name: 'Boost', icon: myBoltIcon, iconType: far },
]
</script>
I'm quite new to this Vue and stuff and going over my head so pardon my mistakes.
Thanks!