diff --git a/packages/vue/src/Icon.ts b/packages/vue/src/Icon.ts index 75d85aee4..8d4254460 100644 --- a/packages/vue/src/Icon.ts +++ b/packages/vue/src/Icon.ts @@ -4,15 +4,16 @@ import defaultAttributes from './defaultAttributes'; import { IconNode, LucideProps } from './types'; import { useLucideProps } from './context'; -interface IconProps { - iconNode: IconNode; - name: string; -} +type IconProps = { name: string } & ( + | { iconNode: IconNode; 'icon-node'?: never } + | { 'icon-node': IconNode; iconNode?: never } +); const Icon: FunctionalComponent = ( { name, iconNode, + 'icon-node': iconNodeKebabCase, absoluteStrokeWidth, 'absolute-stroke-width': absoluteStrokeWidthKebabCase, strokeWidth, @@ -71,7 +72,10 @@ const Icon: FunctionalComponent = ( : ['lucide-icon']), ), }, - [...iconNode.map((child) => h(...child)), ...(slots.default ? [slots.default()] : [])], + [ + ...(iconNode ?? iconNodeKebabCase ?? []).map((child) => h(...child)), + ...(slots.default ? [slots.default()] : []), + ], ); }; diff --git a/packages/vue/tests/Icon.spec.ts b/packages/vue/tests/Icon.spec.ts index 968a36d05..d8ec174a8 100644 --- a/packages/vue/tests/Icon.spec.ts +++ b/packages/vue/tests/Icon.spec.ts @@ -19,6 +19,18 @@ describe('Using Icon Component', () => { expect(container.firstChild).toBeDefined(); }); + it('should render when iconNode is passed as the kebab-case icon-node prop', async () => { + const { container } = render(Icon, { + props: { + 'icon-node': airVent, + name: 'AirVent', + }, + }); + + expect(container.firstChild).toBeDefined(); + expect(container.querySelector('svg')).toBeTruthy(); + }); + it('should render icon and match snapshot', async () => { const { container } = render(Icon, { props: {