trypost/resources/js/components/Icon.vue
2026-01-21 18:42:37 -03:00

38 lines
883 B
Vue

<script setup lang="ts">
import * as icons from '@tabler/icons-vue';
import { computed } from 'vue';
import { cn } from '@/lib/utils';
interface Props {
name: string;
class?: string;
size?: number | string;
color?: string;
strokeWidth?: number | string;
}
const props = withDefaults(defineProps<Props>(), {
class: '',
size: 16,
strokeWidth: 2,
});
const className = computed(() => cn('h-4 w-4', props.class));
const icon = computed(() => {
// Tabler icons are prefixed with 'Icon', e.g., 'IconUser', 'IconSettings'
const iconName = 'Icon' + props.name.charAt(0).toUpperCase() + props.name.slice(1);
return (icons as Record<string, any>)[iconName];
});
</script>
<template>
<component
:is="icon"
:class="className"
:size="size"
:stroke-width="strokeWidth"
:color="color"
/>
</template>