Icon

Overview

ct-icon is a smart icon component that automatically detects and renders the correct element based on the name prop:

Input typeExampleRenders
Empty / undefinedβ€”Default fallback (CircleHelp)
Vue Component:name="MyIcon"<component :is>
Emojiname="πŸš€"<span> with font-size
Image URL or pathname="/logo.svg"<NuxtImg> with lazy loading
File extension / namename="js", name="vue"Matched icon via useFileIcon
Lucide icon stringname="lucide:box"Resolved Lucide component
Unresolved stringname="unknown"Default fallback (CircleHelp)

Usage

Lucide Icons

Pass a Lucide icon name using the lucide: prefix or just the kebab-case name directly.

Lucide

File-Type Icons

Pass a file extension or known filename to automatically resolve a technology icon (e.g. TypeScript, Vue, Python).

File Types

JavaScriptVue.jsTypeScriptPythonCSS

Emojis

Pass an emoji string directly. Use the :size prop to control the font size.

Emojis

πŸ˜πŸš€πŸŽ‰

Images (URL or Path)

Pass an image URL or local path. The component renders a <NuxtImg> with lazy loading and explicit width/height for better performance.

URL

Default Fallback

When no name is provided or the name cannot be resolved, a default CircleHelp icon is rendered.

Fallback

Props

namestring | Component
Icon name, emoji, image URL, file extension, or a Vue component. Falls back to CircleHelp when empty or unresolved.
sizenumber
16
Icon size in pixels. Controls both width/height for images and size prop for Lucide icons.
classstring
Additional CSS classes to apply to the rendered element.

Resolution Order

The component resolves the name prop in the following priority:

  1. Empty β†’ renders the default CircleHelp icon.
  2. Vue Component β†’ renders the component directly via <component :is>.
  3. Emoji β†’ renders inside a <span> with matching font size.
  4. Image β†’ renders via <NuxtImg> with lazy loading, explicit width and height.
  5. File-type match β†’ resolves via useFileIcon (supports extensions like js, vue, ts, py, and known filenames like package.json).
  6. Lucide icon β†’ converts the name to PascalCase and looks up the Lucide icon registry.
  7. Unresolved β†’ falls back to the default CircleHelp icon.