Last active
September 27, 2022 11:21
-
-
Save Lyokolux/d84f1e320512964da3b2450a8d081187 to your computer and use it in GitHub Desktop.
Integration of an Iconfont (dripicons) in Vue 3 (<3.2)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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