TypeScript Support
List of exported types from the @ycloud-web/icons-vue package. These can be used to type your components when using YCloud icons in a TypeScript Vue project.
YCloudProps
Exports all props that can be passed to an icon component and any other SVG attributes, see: SVG Presentation Attributes on MDN.
interface YCloudProps {
size?: number | string;
color?: string;
strokeWidth?: number;
absoluteStrokeWidth?: boolean;
[key: string]: any; // Any other SVG attributes
}Using YCloudProps
You can use the YCloudProps interface to type props for your custom icon components.
<script lang="ts" setup>
import { type YCloudProps } from '@ycloud-web/icons-vue';
import { Camera } from '@ycloud-web/icons-vue';
defineProps<YCloudProps>();
</script>
<template>
<div>
<Camera v-bind="$props" />
</div>
</template>YCloudIcon
Type for individual icon components, this is use full when you want to type a variable or prop that holds an icon component.
type YCloudIcon = React.FC<YCloudProps>;Using YCloudIcon
You can use the YCloudIcon type when you need to work with icon components directly.
<script lang="ts" setup>
import { type YCloudProps } from '@ycloud-web/icons-vue';
import { Camera } from '@ycloud-web/icons-vue';
defineProps<{
icon: YCloudIcon;
label: string;
}>();
</script>
<template>
<button :aria-label="label">
<component
:is="icon"
:size="16"
/>
</button>
</template>IconNode
Type for the raw SVG structure of an icon. This is an array of SVG elements and their attributes to render the icon. Not commonly used directly in application code. But can be useful for advanced use cases, such as using custom icons or custom rendering utilities.
type IconNode = [elementName: string, attrs: Record<string, string | number>][];Using IconNode
You can use the IconNode type when you need to work with the raw SVG structure of an icon.
<script lang="ts" setup>
import { type IconNode, Icon } from '@ycloud-web/icons-vue';
const customIcon: IconNode = [
['circle', { cx: 12, cy: 12, r: 10 }],
['line', { x1: 12, y1: 8, x2: 12, y2: 12 }],
['line', { x1: 12, y1: 16, x2: 12, y2: 16 }],
];
</script>
<template>
<Icon
:iconNode="customIcon"
size="24"
color="blue"
/>
</template>