Lucide Icon
Lucide Icon primitive
Install
npx ui8kit add lucide-iconPulls in: compose, kit-icon, recipes, utils
Preview
No static preview for this item: it needs content or a parent that this page cannot supply. The code is below.
Code
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework svelte --dir src --registry-url https://registry.buildy.tw/svelte --strict-cdnnpx ui8kit add lucide-icon<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- LucideIcon: Icon + recipe lucide-icon. -->
<script lang="ts">
import type { ComponentProps, Snippet } from "svelte";
import Prim from "../kit/ui/icon/Icon.svelte";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
let { class: className, children, ...rest }: ComponentProps<typeof Prim> & { class?: string; children?: Snippet } = $props();
const cls = $derived(cn(rc("lucide-icon", { }), className));
</script>
<Prim class={cls} {...rest}>{@render children?.()}</Prim>
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
LucideIcon: a Lucide glyph (ISC license) by kebab-case name (any glyph of the `lucide` package, through ./lucide-icons), inside the Icon primitive
(the kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a `label` is given.
-->
<script lang="ts" module>
export type LucideIconProps = { name: string; size?: number; strokeWidth?: number; label?: string; class?: string };
</script>
<script lang="ts">
import Frame from "../compose/LucideIcon.svelte";
import { lucideNodes } from "./lucide-icons";
let { name, size = 16, strokeWidth = 2, label, class: className }: LucideIconProps = $props();
const nodes = $derived(lucideNodes(name) ?? lucideNodes("circle") ?? []);
</script>
<Frame {label} class={className} data-lucide={name}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width={size} height={size} fill="none" stroke="currentColor"
stroke-width={strokeWidth} stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
{#each nodes as [tag, attrs], i (i)}
<svelte:element this={tag} {...attrs} />
{/each}
</svg>
</Frame>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Lucide icons (ISC license, https://lucide.dev): every glyph of the `lucide` package (1.57.0, a dependency of this package), by kebab-case name.
import { icons } from "lucide";
export type LucideNode = [string, Record<string, string | number>];
const ICONS = icons as unknown as Record<string, LucideNode[] | undefined>;
const pascal = (name: string): string => name.replace(/(^|-)([a-z0-9])/g, (_m: string, _d: string, c: string) => c.toUpperCase());
/** the nodes of a Lucide glyph by kebab-case name (`chef-hat`), undefined for a name Lucide does not have */
export function lucideNodes(name: string): LucideNode[] | undefined {
return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(name) ? ICONS[pascal(name)] : undefined;
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework react --dir src --registry-url https://registry.buildy.tw/react --strict-cdnnpx ui8kit add lucide-icon// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import type { ComponentProps } from "react";
import { Icon as Prim } from "../kit/ui/icon/icon";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type LucideIconProps = Omit<ComponentProps<typeof Prim>, "tag"> & { className?: string };
/** LucideIcon: Icon + recipe lucide-icon. */
export function LucideIcon({ className, ...rest }: LucideIconProps) {
return <Prim className={cn(rc("lucide-icon", { }), className)} {...rest} />;
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* LucideIcon: a Lucide glyph (ISC license) by kebab-case name (any glyph of the `lucide` package, through ./lucide-icons), inside the Icon primitive
* (the kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a `label` is given.
*/
import { createElement } from "react";
import { LucideIcon as Frame } from "../compose";
import { lucideNodes } from "./lucide-icons";
export type LucideIconProps = { name: string; size?: number; strokeWidth?: number; label?: string; className?: string };
export function LucideIcon({ name, size = 16, strokeWidth = 2, label, className }: LucideIconProps) {
const nodes = lucideNodes(name) ?? lucideNodes("circle") ?? [];
return (
<Frame label={label} className={className} data-lucide={name}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width={size} height={size} fill="none" stroke="currentColor"
strokeWidth={strokeWidth} strokeLinecap="round" strokeLinejoin="round" aria-hidden="true">
{nodes.map(([tag, attrs], i) => createElement(tag, { key: i, ...attrs }))}
</svg>
</Frame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Lucide icons (ISC license, https://lucide.dev): every glyph of the `lucide` package (1.57.0, a dependency of this package), by kebab-case name.
import { icons } from "lucide";
export type LucideNode = [string, Record<string, string | number>];
const ICONS = icons as unknown as Record<string, LucideNode[] | undefined>;
const pascal = (name: string): string => name.replace(/(^|-)([a-z0-9])/g, (_m: string, _d: string, c: string) => c.toUpperCase());
/** the nodes of a Lucide glyph by kebab-case name (`chef-hat`), undefined for a name Lucide does not have */
export function lucideNodes(name: string): LucideNode[] | undefined {
return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(name) ? ICONS[pascal(name)] : undefined;
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework vue --dir src --registry-url https://registry.buildy.tw/vue --strict-cdnnpx ui8kit add lucide-icon<!-- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. -->
<!-- LucideIcon: Icon + recipe lucide-icon. -->
<script setup lang="ts">
import { computed, useAttrs } from "vue";
import Prim from "../kit/ui/icon/Icon.vue";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
defineOptions({ name: "LucideIcon", inheritAttrs: false });
const props = defineProps<{ }>();
const attrs = useAttrs();
const rest = computed(() => {
const { class: _class, ...r } = attrs;
return r;
});
const cls = computed(() => cn(rc("lucide-icon", { }), attrs.class as string | undefined));
const tagValue = computed(() => "");
</script>
<template>
<Prim :class="cls" v-bind="rest"><slot /></Prim>
</template>
<!-- Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT. -->
<!--
LucideIcon: a Lucide glyph (ISC license) by kebab-case name (any glyph of the `lucide` package, through ./lucide-icons), inside the Icon primitive
(the kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a `label` is given.
-->
<script lang="ts">
export type LucideIconProps = { name: string; size?: number; strokeWidth?: number; label?: string; class?: string };
</script>
<script setup lang="ts">
import { computed } from "vue";
import Frame from "../compose/LucideIcon.vue";
import { lucideNodes } from "./lucide-icons";
defineOptions({ inheritAttrs: false });
const { name, size = 16, strokeWidth = 2, label, class: className } = defineProps<LucideIconProps>();
const nodes = computed(() => lucideNodes(name) ?? lucideNodes("circle") ?? []);
</script>
<template>
<Frame :label="label" :class="className" :data-lucide="name">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" :width="size" :height="size" fill="none" stroke="currentColor"
:stroke-width="strokeWidth" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<component :is="tag" v-for="([tag, attrs], i) in nodes" :key="i" v-bind="attrs" />
</svg>
</Frame>
</template>
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Lucide icons (ISC license, https://lucide.dev): every glyph of the `lucide` package (1.57.0, a dependency of this package), by kebab-case name.
import { icons } from "lucide";
export type LucideNode = [string, Record<string, string | number>];
const ICONS = icons as unknown as Record<string, LucideNode[] | undefined>;
const pascal = (name: string): string => name.replace(/(^|-)([a-z0-9])/g, (_m: string, _d: string, c: string) => c.toUpperCase());
/** the nodes of a Lucide glyph by kebab-case name (`chef-hat`), undefined for a name Lucide does not have */
export function lucideNodes(name: string): LucideNode[] | undefined {
return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(name) ? ICONS[pascal(name)] : undefined;
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework solid --dir src --registry-url https://registry.buildy.tw/solid --strict-cdnnpx ui8kit add lucide-icon// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
import { splitProps, type ComponentProps } from "solid-js";
import { Icon as Prim } from "../kit/ui/icon/icon.solid";
import { cn } from "../kit/utils";
import { rc } from "./recipes";
export type LucideIconProps = Omit<ComponentProps<typeof Prim>, "tag" | "class" | "className"> & { class?: string; className?: string };
/** LucideIcon: Icon + recipe lucide-icon. */
export function LucideIcon(props: LucideIconProps) {
const [local, rest] = splitProps(props, ["class", "className"]);
return <Prim class={cn(rc("lucide-icon", { }), local.class ?? local.className)} {...rest} />;
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
/**
* LucideIcon: a Lucide glyph (ISC license) by kebab-case name (any glyph of the `lucide` package, through ./lucide-icons), inside the Icon primitive
* (the kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a `label` is given.
*/
import { For, type JSX } from "solid-js";
import { Dynamic } from "solid-js/web";
import { LucideIcon as Frame } from "../compose";
import { lucideNodes } from "./lucide-icons";
export type LucideIconProps = { name: string; size?: number; strokeWidth?: number; label?: string; class?: string };
export function LucideIcon(props: LucideIconProps): JSX.Element {
const nodes = () => lucideNodes(props.name) ?? lucideNodes("circle") ?? [];
return (
<Frame label={props.label} class={props.class} data-lucide={props.name}>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width={props.size ?? 16} height={props.size ?? 16} fill="none" stroke="currentColor"
stroke-width={props.strokeWidth ?? 2} stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
<For each={nodes()}>{([tag, attrs]) => <Dynamic component={tag} {...attrs} />}</For>
</svg>
</Frame>
);
}
// Code generated by packages/kit-compose/src/organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// Lucide icons (ISC license, https://lucide.dev): every glyph of the `lucide` package (1.57.0, a dependency of this package), by kebab-case name.
import { icons } from "lucide";
export type LucideNode = [string, Record<string, string | number>];
const ICONS = icons as unknown as Record<string, LucideNode[] | undefined>;
const pascal = (name: string): string => name.replace(/(^|-)([a-z0-9])/g, (_m: string, _d: string, c: string) => c.toUpperCase());
/** the nodes of a Lucide glyph by kebab-case name (`chef-hat`), undefined for a name Lucide does not have */
export function lucideNodes(name: string): LucideNode[] | undefined {
return /^[a-z0-9]+(-[a-z0-9]+)*$/.test(name) ? ICONS[pascal(name)] : undefined;
}
Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework templ --dir src --registry-url https://registry.buildy.tw/templ --strict-cdnnpx ui8kit add lucide-icon// Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
package compose
import "github.com/ui8kit/codegen/generated/templ/ui/icon"
// LucideIconProps: LucideIcon: Icon + recipe lucide-icon.
type LucideIconProps struct {
icon.IconProps
}
func lucideIconInner(p LucideIconProps) icon.IconProps {
in := p.IconProps
in.Class = Join(Rc("lucide-icon", map[string]string{}), p.IconProps.Class)
return in
}
// LucideIcon renders Icon with the composition classes.
templ LucideIcon(p LucideIconProps) {
@icon.Icon(lucideIconInner(p)) {
{ children... }
}
}
// Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
// LucideIcon: a Lucide glyph (ISC license) by kebab-case name from the registry next to this file (lucide_icons.go), inside
// the Icon primitive (the kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a
// Label is given. Size and StrokeWidth default to 16 and 2.
package icons
import (
"html"
"sort"
"strconv"
"strings"
"github.com/ui8kit/codegen/generated/templ/compose"
"github.com/ui8kit/codegen/generated/templ/ui/icon"
)
// LucideIconProps configures LucideIcon.
type LucideIconProps struct {
Name string
Size int
StrokeWidth int
Label string
Class string
Attrs templ.Attributes
}
func orInt(v, d int) string {
if v == 0 {
return strconv.Itoa(d)
}
return strconv.Itoa(v)
}
// glyph is the inner markup of the icon: its nodes with their attributes in name order, escaped.
func glyph(name string) string {
nodes, ok := lucide[name]
if !ok {
nodes = lucide["circle"]
}
var b strings.Builder
for _, n := range nodes {
keys := make([]string, 0, len(n.Attrs))
for k := range n.Attrs {
keys = append(keys, k)
}
sort.Strings(keys)
b.WriteString("<" + n.Tag)
for _, k := range keys {
b.WriteString(" " + k + "=\"" + html.EscapeString(n.Attrs[k]) + "\"")
}
b.WriteString("></" + n.Tag + ">")
}
return b.String()
}
func frameAttrs(a templ.Attributes, name string) templ.Attributes {
out := templ.Attributes{}
for k, v := range a {
out[k] = v
}
if name != "" {
out["data-lucide"] = name
}
return out
}
// LucideIcon renders the glyph as an inline svg inside the Icon primitive.
templ LucideIcon(p LucideIconProps) {
@compose.LucideIcon(compose.LucideIconProps{IconProps: icon.IconProps{Label: p.Label, Class: p.Class, Attrs: frameAttrs(p.Attrs, p.Name)}}) {
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width={ orInt(p.Size, 16) }
height={ orInt(p.Size, 16) }
fill="none"
stroke="currentColor"
stroke-width={ orInt(p.StrokeWidth, 2) }
stroke-linecap="round"
stroke-linejoin="round"
aria-hidden="true"
>
@templ.Raw(glyph(p.Name))
</svg>
}
}
Not shown here (603 KB of data): the file is in the registry item (JSON)Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework twig --dir src --registry-url https://registry.buildy.tw/twig --strict-cdnnpx ui8kit add lucide-icon{# Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. #}
{# LucideIcon: Icon + recipe lucide-icon. Params: class, attrs + the params of Icon. #}
{% include 'ui/icon/Icon.html.twig' with compose_props('LucideIcon', _context) only %}{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
LucideIcon: a Lucide glyph (ISC license) by kebab-case name from icons/lucide-icons.json, inside the Icon primitive (the
kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a label is given.
Params: name, size (16), strokeWidth (2), label, class, attrs. -#}
{%- set name = name ?? '' -%}
{%- set size = (size ?? 0) ?: 16 -%}
{%- set glyph -%}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="{{ size }}" height="{{ size }}" fill="none" stroke="currentColor" stroke-width="{{ (strokeWidth ?? 0) ?: 2 }}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">{{ og_lucide(name) }}</svg>
{%- endset -%}
{{ include('compose/LucideIcon.html.twig', {'label': label ?? '', 'class': class ?? '', 'attrs': (attrs ?? {})|merge({'data-lucide': name}), 'children': glyph}, with_context = false) }}
Not shown here (429 KB of data): the file is in the registry item (JSON)Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework latte --dir src --registry-url https://registry.buildy.tw/latte --strict-cdnnpx ui8kit add lucide-icon{* Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT. *}
{* LucideIcon: Icon + recipe lucide-icon. *}
{parameters
string $size = '',
string $class = '',
string $label = '',
array $attrs = [],
string $children = '',
}
{include '../ui/icon/Icon.latte', ...\CodegenX\Compose\Latte\Compose::props('LucideIcon', ['size' => $size, 'class' => $class, 'label' => $label, 'attrs' => $attrs, 'children' => $children])}{* Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
LucideIcon: a Lucide glyph (ISC license) by kebab-case name from icons/lucide-icons.json, inside the Icon primitive (the
kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a label is given.
Params: name, size (16), strokeWidth (2), label, class, attrs. *}
{parameters
$name = '',
$size = null,
$strokeWidth = null,
$label = '',
$class = '',
array $attrs = [],
}
{capture $glyph}<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="{$size ?: 16}" height="{$size ?: 16}" fill="none" stroke="currentColor" stroke-width="{$strokeWidth ?: 2}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">{=og_lucide((string) $name)|noescape}</svg>{/capture}
{=og_include('compose/LucideIcon.latte', ['label' => (string) $label, 'class' => (string) $class, 'attrs' => array_merge($attrs, ['data-lucide' => (string) $name]), 'children' => (string) $glyph])|noescape}
Not shown here (429 KB of data): the file is in the registry item (JSON)Point the CLI at this runtime once, then add the item:
npx ui8kit init --yes --framework jinja2 --dir src --registry-url https://registry.buildy.tw/jinja2 --strict-cdnnpx ui8kit add lucide-icon{#- Code generated by packages/kit-compose/src/build.ts from src/map.ts + variants/. DO NOT EDIT.
LucideIcon: Icon + recipe lucide-icon. Props (p): Class, Attrs + the props of Icon. -#}
{%- with p = compose_props('LucideIcon', p) %}{% include 'ui/icon/icon.html.j2' %}{% endwith %}{#- Code generated by packages/kit-compose/src/server-organisms.ts from packages/compose-gen/specs (compose-gen organism emitters on kit-compose). DO NOT EDIT.
LucideIcon: a Lucide glyph (ISC license) by kebab-case name from icons/lucide-icons.json, inside the Icon primitive (the
kit-compose LucideIcon frame: span[data-slot=icon]). Decorative (the frame is aria-hidden) unless a Label is given.
Props (p): Name, Size (16), StrokeWidth (2), Label, Class, Attrs. -#}
{%- set name = ui_def(p['Name'], '') -%}
{%- set size = ui_def(p['Size'], 0) or 16 -%}
{%- set glyph -%}
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="{{ size }}" height="{{ size }}" fill="none" stroke="currentColor" stroke-width="{{ ui_def(p['StrokeWidth'], 0) or 2 }}" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">{{ og_lucide(name) }}</svg>
{%- endset -%}
{{ og_include('compose/lucide-icon.html.j2', {'p': {'Label': ui_def(p['Label'], ''), 'Class': ui_def(p['Class'], ''), 'Attrs': og_merge(ui_def(p['Attrs'], {}), {'data-lucide': name})}, 'children': glyph}) }}
Not shown here (429 KB of data): the file is in the registry item (JSON)Props
Names and types come from the xgen specs of the source. Standard HTML attributes (id, role, tabIndex, aria-*) pass through to the root element; the class prop is className in React.
No props.
Used in
- about-company
- add-icon
- add-qty
- announcement-bar
- auth-card
- before-after
- bento-grid
- bottom-nav
- bulk-bar
- cart-count
- cart-drawer
- cart-list
- cart-table
- category-nav
- checklist
- combo-builder
- compare-mark
- contact-form
- cookie-banner
- cta-proof-items
- cut-cards
- delivery-info
- dish-bento
- dish-showcase
- editor-tab
- empty-state
- faq-cards
- faq-help
- feature-accordion
- feature-cards
- feature-metric-cards
- feature-pairs
- feature-rows
- feature-showcase
- feature-stat-rows
- feature-sticky
- feature-tabs
- file-tree-item
- footer-brand
- footer-card
- footer-channels
- footer-contacts
- footer-group-cards
- footer-points
- footer-signup-card
- footer-sitemap
- grill-builder
- hero-split-extras
- hero-split-media
- icon-wall
- job-cards
- lightbox-gallery
- lightbox-stage
- logo-cloud
- logo-slot
- media-contacts
- media-steps
- media-topics
- mega-menu
- member-row
- metric-row
- notice
- number-field
- offer-media
- page-aside
- page-crumbs
- pager
- payment-options
- photo-gallery
- pill
- post-actions
- post-author
- post-card
- post-feature
- post-outline
- post-overlay-card
- post-showcase
- post-stats
- product-detail
- project-tiles
- prompt-composer
- proof-band
- quick-order
- quote-card
- quote-logo-tiles
- rating
- recipe-kits
- reservation-form
- search-field
- search-palette
- shell-sidebar
- shell-topbar
- shopping-cart
- sidebar-nav
- signup-wizard
- stat-figure
- stat-tile
- stepper
- steps-list
- store-hero
- store-locations
- story-tabs
- support-channels
- sushi-sets
- template-grid
- topic-chips
- usp-strip
- veggie-box
- video-grid
- video-modal