Skip to content

Instantly share code, notes, and snippets.

@Lyokolux
Last active September 27, 2022 11:21
Show Gist options
  • Save Lyokolux/d84f1e320512964da3b2450a8d081187 to your computer and use it in GitHub Desktop.
Save Lyokolux/d84f1e320512964da3b2450a8d081187 to your computer and use it in GitHub Desktop.
Integration of an Iconfont (dripicons) in Vue 3 (<3.2)
<script setup lang="ts">
type Props = {
icon: `dripicons-${string}`
size?: string
alt?: string
}
const props = withDefaults(defineProps<Props>(), {
size: '1rem'
})
</script>
<template>
<span class="webfont iconfont-size" :class="icon" :style="{ '--size': size }">
<span v-if="alt">{{ alt }}</span>
</span>
</template>
<style lang="scss" scoped>
.webfont {
display: inline-block;
span {
font-size: 0; // SR only
}
}
.iconfont-size::before {
font-size: var(--size);
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment