PitchHut logo
SwiftUI icons that are pure, vector, and native.
Pitch

Lucide offers over 1,700 icons for SwiftUI, rendered as native shapes without the need for UIKit bindings. Each icon is a SwiftUI.Shape created from pure code, ensuring high quality and zero runtime dependencies. With type-safe options and automatic updates that track upstream releases, Lucide provides a seamless and efficient way to enhance SwiftUI applications.

Description

Lucide icons for SwiftUI offer a comprehensive library of over 1,700 handcrafted icons natively designed for SwiftUI applications. Each icon is implemented as a generated SwiftUI.Shape, avoiding the complexity of SVG libraries, XML parsers, or image assets, ensuring a lightweight and streamlined integration. This library matches the capabilities of SwiftUI, allowing icons to scale seamlessly, adjust coloring via .foregroundStyle, and participate in animations, scaling, and masking operations like any other shape.

Lucide icons rendered natively in SwiftUI

Key Features

  • Pure SwiftUI: Each Lucide icon is a Shape with its path(in:) defined in pure Swift code, compiled at build time, eliminating any runtime parsing overhead.
  • Vector Quality: All icons maintain sharpness at any size and on any display, as they are not dependent on raster formats like PNG or PDF.
  • Zero Runtime Dependencies: The library only utilizes SwiftUI without any additional runtime dependencies.
  • SwiftUI Idiomatic Use: Icons are designed to work intuitively within SwiftUI, enabling straightforward styling with modifiers like .foregroundStyle, .opacity, .rotationEffect, and .animation.
  • Type-Safe Enum: The LucideIcon enum provides autocompletion and compile-time safety, with dynamic lookup capabilities available through Lucide("iconName").
  • Automatic Upstream Tracking: A scheduled workflow monitors the lucide-static npm source and updates the icons appropriately, ensuring compatibility with the latest releases.
  • Memory Efficient: Each icon consumes minimal memory, consisting only of a few hundred bytes of Path commands with no leftover decoded images or SVG document trees.

Usage Example

Integrating an icon into a SwiftUI view is simple and straightforward. Here’s a quick example:

import SwiftUI
import Lucide

struct ContentView: View {
    var body: some View {
        Lucide(.heart)
            .foregroundStyle(.red)
            .frame(width: 24, height: 24)
    }
}

Icons can be customized using their kebab-case names from the Lucide icon gallery, allowing for a seamless mapping to their respective LucideIcon cases. The icons are filled outline geometries, which means there is no stroke width adjustment necessary, as the stroke weights are configured during the generation process.

Development

To facilitate continuous development, Lucide icons can be regenerated easily using provided scripts, which can be run locally or as part of a CI pipeline to sync with upstream changes. For detailed installation and development instructions, please refer to the README in the repository.

0 comments

No comments yet.

Sign in to be the first to comment.