Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sf-symbols-typescript

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sf-symbols-typescript

```ts import type { SFSymbol } from 'sf-symbols-typescript'

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

🍏 SF Symbols for TypeScript

import type { SFSymbol } from 'sf-symbols-typescript'

const icon: SFSymbol = 'arrow.up'
Screenshot 2023-03-03 at 3 21 13 PM

A simple TypeScript utility to get the names of SF Symbols. Mainly useful for React Native libraries and apps that utilize SF Symbols.

I made this for Zeego and Burnt.

It has zero dependencies, and zero runtime code.

Installation

yarn add sf-symbols-typescript

Usage

import type { SFSymbol } from 'sf-symbols-typescript'

const icon: SFSymbol = 'arrow.up'

Restricting symbols

By default, this library exposes all available symbols for the current version of SF Symbols.

Depending on the platforms your app targets, you may want to restrict the types to specific versions of SF Symbols.

Globally

You can restrict the SFSymbol type to a specific version of SF Symbols through declaration merging.

This library exposes an interface called Overrides with a property SFSymbolsVersion that can be overidden.

declare module 'sf-symbols-typescript' {
  interface Overrides {
    // globally restrict symbols to those found in SF Symbols 4.2
    SFSymbolsVersion: '4.2'
  }
}

Individually

If you require more granular control, this library also exposes individual type definitions for each version of SF Symbols.

They are named with this pattern: SFSymbols{major}_{minor}

import type { SFSymbols4_2, SFSymbols5_0 } from 'sf-symbols-typescript'

Version Support Table

Here are the platforms supported by each version of SF Symbols:

SFSymbolsiOSmacOStvOSvisionOSwatchOS
1.013.011.013.01.06.0
1.113.111.013.01.06.1
2.014.011.014.01.07.0
2.114.211.014.21.07.1
2.214.511.314.51.07.4
3.015.012.015.01.08.0
3.115.112.015.11.08.1
3.215.212.115.21.08.3
3.315.412.315.41.08.5
4.016.013.016.01.09.0
4.116.113.016.11.09.1
4.216.413.316.41.09.4
5.017.014.017.01.010.0

Contributing

To update this package's icons, you will need Bun installed on your machine.

You will also need a copy of the plist resources from the SF Symbols desktop application.

  • Right click the SF Symbols application in Finder and choose "Show Package Contents"
  • Navigate to ./Contents/Resources/Metadata. The required plist resources are here.

Alternatively, you may be able to find those same resource files in the source code of the unofficial SFSafeSymbols Swift library.

  1. Clone this repo
  2. Copy the SF Symbols plist resource files into the ./src/data directory of the repo
  3. Run bun run build
  4. Push your changes and open a PR

Disclaimer

It is your responsibility to check Apple's rules about when certain icons can be used. You can check the SF Symbols desktop application for more info.

I am purposefully not displaying any icons themselves to avoid violating any licenses. This library isn't associated with Apple, and is only intended to expose the names of the icons themselves.

Credits

This project is based on Apple's SF Symbols

Previous versions of this library used data sourced from the now-defunct SFSymbols.com. Thanks to Noah Sark for your open source contributions.

License

MIT License

FAQs

Package last updated on 16 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc