#Qwik icons as props
8 messages · Page 1 of 1 (latest)
Use the PropFunction type
Aka a QRL contains a closure that renders an element
$(() => <MyIcon />)
well i made a little research and actually Slots are much easier to do this
im gonna test it right now
On I assumed you'd tried slots and wanted to use the prop route 👍
Found a really nice solution without the use of slots
import type { Component } from "@builder.io/qwik";
import type { IconProps } from "@qwikest/icons/*";
import { component$ } from "@builder.io/qwik";
import { Link } from "@builder.io/qwik-city";
export interface SidebarLinkProps {
label: string;
url: string;
Icon: Component<IconProps>;
}
export const SidebarLink = component$<SidebarLinkProps>(
({ label, url, Icon }) => {
return (
<Link href={url}>
<Icon />
{label}
</Link>
);
}
);