lucide-text-icon
v0.1.0
Published
Deterministic text-to-Lucide icon name mapping for lucide-react-native
Readme
lucide-text-icon
Deterministic text-to-icon mapping for lucide-react-native. This package turns a free-text task title into a Lucide icon name string with a tiny, offline scoring algorithm.
Installation
npm install lucide-text-icon lucide-static lucide-react-nativeUsage
import { getLucideIconNameFromText } from "lucide-text-icon"
import * as Icons from "lucide-react-native"
const iconName = getLucideIconNameFromText("have a walk")
const Icon = Icons[iconName]Options
getLucideIconNameFromText("plan trip", {
fallbackIcon: "circle",
minScore: 6
})How It Works
- A build-time script reads
lucide-static/tags.jsonand creates a token index. - Input text is normalized (lowercase, punctuation removed, stopwords filtered, light stemming).
- Synonyms are expanded and scored against the icon tokens.
Scoring rules:
- Exact token match: +10
- Synonym match: +6
- Partial match (substring): +3
The icon with the highest score is returned. If no icon reaches minScore, the fallbackIcon is returned.
Notes
- This library returns the icon name string only.
- The icon component must come from lucide-react-native.
- No network calls and no heavy NLP dependencies.
Development
npm run test
npm run build