AsterUIDocsv1.0.2

Docs / Component reference

Icon (Lucide)

Render the SVG paths from a Lucide icon definition. Import the individual icons the component uses.

Icon example

Install

sh
npx @fierst/ui@1.0.2 add icon

Registry dependencies: theme. Package dependencies: @lucide/icons.

Exports from ./ui/icon: LucideIconNode, LucideIconData, LucideIconInput, IconProps, Icon, createIcon.

Download the registry source for icon 1.0.2.

API contracts

ts
export type LucideIconNode = readonly [
  tag: string,
  attrs: Readonly<Record<string, string | number | undefined>>,
  children?: readonly LucideIconNode[],
];

export interface LucideIconData {
  readonly name?: string;
  readonly node: readonly LucideIconNode[];
  readonly aliases?: readonly string[];
  readonly size?: number;
  readonly width?: number;
  readonly height?: number;
}

export type LucideIconInput = LucideIconData | readonly LucideIconNode[];

export interface IconProps {
  /** Tree-shaken icon imported from `@lucide/icons` (or a `LucideIconNode[]` tuple array). */
  icon: LucideIconInput;
  /** Icon width & height in px or CSS length (default: 18). */
  size?: number | string;
  /** SVG stroke width (default: 1.75 for AsterUI optical balance). */
  strokeWidth?: number;
  /** Scale stroke width inversely with `size` so lines stay visually consistent at any scale. */
  absoluteStrokeWidth?: boolean;
  /** Override stroke color (defaults to `currentColor`). */
  color?: string;
  /** Animate continuous rotation (ideal for `LoaderCircle`). */
  spin?: boolean;
  /** Accessible label. When omitted, the icon is treated as decorative (`aria-hidden="true"`). */
  label?: string;
  class?: string;
  [key: string]: any;
}

export function Icon({
  icon,
  size = 18,
  strokeWidth = 1.75,
  absoluteStrokeWidth = false,
  color,
  spin = false,
  label,
  class: extraClass,
  ...rest
}: IconProps): SlotView

export function createIcon(
  icon: LucideIconInput,
  defaults: Omit<IconProps, 'icon'> = {},
): (props?: Omit<IconProps, 'icon'>) => SlotView