@rbxts/lucide
v0.1.3
Published
Lucide Icons for Roblox
Maintainers
Readme
Lucide Icons Library for Roblox
Library to Use the Lucide Icon Set (https://lucide.dev) in Roblox
Unlike the similar plugin (which uses this library as well!), this exists to serve as a library/package that you can access programmatically at runtime in any other games, applications, plugins etc.
This library was originally made for the intent of use with the Commander project, but stands applicable to anything else as well.
See list of rendered icons and their internal identifiers: md/icon-index.md
⚙️ Installation
There are multiple methods of using the library in your project; you can download the model/script file directly, use the Wally package manager, or get it on Roblox's official Developer Marketplace.
Manual Download
From the releases page, on the latest published release, you can download either lucide-roblox.rbxm, or lucide-roblox.luau (built by the Wax bundler) if you want to use the library from one module. From there, just import into your project/Studio, and you're done!
Via the Wally Package Manager
If you're familiar with Wally, you can also import the latte-soft/lucide-icons package in your wally.toml file:
[dependencies]
Lucide = "latte-soft/[email protected]"Get from the Roblox Developer Marketplace
If you really want to, you could even take the model for your inventory, and import it from Studio's Toolbox etc.
🔨 Usage/API
You must define a Lucide variable mapping to wherever the library's module is located - ReplicatedStorage, Wally's Packages directory, wherever..
For the sake of generalization, here's an example for if the module was under ReplicatedStorage in a standard game/workflow:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lucide = require(ReplicatedStorage.Lucide)From here, you can use any of the API members listed below.
Sections
Constants
Lucide.PackageVersion: stringThe version of the
lucide-robloxlibrary itself (e.g.0.1.0)Lucide.LucideVersion: stringThe version of Lucide Icons itself that's aligned with the current library version (e.g.
0.292.0)Lucide.IconNames: {string}An alphabetically-sorted array of every icon name/identifier accessible
Functions
function Lucide.GetAsset(iconName: string, iconSize: number?): AssetAttempts to retrieve and wrap an asset object from a specified icon name, with an optional target icon size argument, fetching the closest to what's supported
Will throw an error if the icon name provided is invalid/not found
Example:
local Asset = Lucide.GetAsset("server", 48) -- iconSize will default to `256` if not provided assert(Asset, "Failed to fetch asset!") print(Asset.IconName) -- "server" print(Asset.Id) -- 15269177520 print(Asset.Url) -- "rbxassetid://15269177520" print(Asset.ImageRectSize) -- Vector2.new(48, 48) print(Asset.ImageRectOffset) -- Vector2.new(0, 771)function Lucide.GetAllAssets(inputSize: number?): {Asset}Returns a dictionary of every
Assetfrom every icon name inLucide.IconNamesThis could also be useful for, for example, working with a custom asset preloading system via
ContentProvider:PreloadAsync()etcExample:
local AllAssets = Lucide.GetAllAssets(256) -- Also defaults to `256`, just like `Lucide.GetAsset()` for _, Asset in AllAssets do print(Asset.IconName, Asset.Url) endfunction Lucide.ImageLabel(iconName: string, imageSize: number?, propertyOverrides: {[string]: any}?): ImageLabelWrapper around
Lucide.GetAsset()that fetches asset info for the specified icon name and size, anc creates anImageLabelInstance. Accepts an additional optional argument for providing a table of properties to automatically apply after the asset has been applied to saidImageLabelWithout providing any extra property overrides, the icon is colored to its default of #FFFFFF, and theinput from the
imageSizeargument is the offset value ofImageLabel.SizeThrows an error under the same terms as
Lucide.GetAsset()Example:
local PlayerGui = game:GetService("Players").LocalPlayer.PlayerGui local ScreenGui = Instance.new("ScreenGui") Lucide.ImageLabel("server-crash", 256, { AnchorPoint = Vector2.new(0.5, 0.5), Position = UDim2.fromScale(0.5, 0.5), Parent = ScreenGui, }) ScreenGui.Parent = PlayerGui
Types
export type Asset = { IconName: string, -- "icon-name" Id: number, -- 123456789 Url: string, -- "rbxassetid://123456789" ImageRectSize: Vector2, -- Vector2.new(48, 48) ImageRectOffset: Vector2, -- Vector2.new(648, 266) }
License
The lucide-roblox package itself is licensed under the MIT License, while Lucide Icons as a whole is licensed under the ISC License. (Derivatively compatible)
See the complete license notice at LICENSE.md.
