Git Product home page Git Product logo

swift's Introduction

@phosphor-icons/swift

Phosphor is a flexible icon family for interfaces, diagrams, presentations — whatever, really. Explore all our icons at phosphoricons.com.

GitHub Tag

GitHub stars GitHub forks GitHub watchers Follow on GitHub

Installation

Add this repo as a new Package Dependency with File > Add Package Dependencies... and enter this URL in the search bar:

https://github.com/phosphor-icons/swift

Choose appropriate version ranges, or use the main branch for the most recent version.

Usage

All icons are present on the Ph enum as computed properties that return a SwiftUI Image, plus some special sauce. To render an icon, use the computed weight property on the enum member, i.e. Ph.<name>.<weight>:

import SwiftUI
import PhosphorSwift

struct ContentView: View {
    var body: some View {
        HStack {
            Ph.horse.regular
                .color(.accentColor)
                .frame(width: 64, height: 64)
            Ph.heart.fill
                .color(.red)
                .frame(width: 64, height: 64)
            Ph.cube.duotone
                .frame(width: 64, height: 64)
        }   
    }
}

Note

By default, all icon images are .resizable() and rendered with .interpolation(Image.Interpolation.medium) for scalable, antialiased icons at any size, without much overhead. The frame can be sized manually, or an icon will fit the size of its parent frame – though it is recommended to use .aspectRatio(contentMode: .fit) to retain the icon's original (square) aspect ratio in this case.

Color can be applied with the .color(_: Color) modifier, which at present is simply a View extension which applies a ViewModifier to any view, causing a color mask to be applied to that view's non-transparent elements.

If weight is dynamic, you can use the .weight(_: Ph.IconWeight) method to render a weight that is not known at compile time, or to use different weights as states (e.g. active/inactive).

Our Related Projects

Community Projects

If you've made a port of Phosphor and you want to see it here, just open a PR here!

License

MIT © Phosphor Icons

swift's People

Contributors

rektdeckard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.