Nucleus
OS integrationIcons

SF Symbols

Typed Kotlin constants for Apple SF Symbols names used by macOS APIs.

View as Markdown

sf-symbols provides Apple's SF Symbols names as typed Kotlin constants. You write SFSymbolObjectsAndTools.SCISSORS instead of "scissors", and the compiler catches typos.

sf-symbolsmacOSGradle plugin: Not neededWindow runtime: Not needed

Add the dependency

build.gradle.kts
dependencies {
    implementation("dev.nucleusframework:nucleus.sf-symbols:3.0.0")
}

menu-macos already brings it.

Reference a symbol

Pick the constant from the category enum that matches its use, and pass it to a macOS API that takes a symbol:

val icon = NsMenuItemImage.SystemSymbol(SFSymbolObjectsAndTools.SCISSORS)

// A name the constants do not cover, such as one from a newer SF Symbols release
val custom = SFSymbol.Custom("bird.fill")

Number symbols take an underscore prefix, since Kotlin identifiers cannot start with a digit: SFSymbolNumbers._0_CIRCLE maps to "0.circle". SF Symbols need macOS 11 or later; the module still compiles and loads on every OS.

API reference

SFSymbol is a sealed interface with 21 category enums plus Custom(symbolName):

CategoryExamples
SFSymbolGeneralGEAR, GEARSHAPE
SFSymbolHumanACCESSIBILITY, BRAIN
SFSymbolShapesAPP, APP_BADGE
SFSymbolArrowsARROW_LEFT, ARROW_CLOCKWISE
SFSymbolTransportationAIRPLANE, AIRPLANE_ARRIVAL
SFSymbolObjectsAndToolsSCISSORS, FOLDER, TRASH
SFSymbolDevicesDESKTOPCOMPUTER, KEYBOARD
SFSymbolNumbers_0_CIRCLE, _0_CIRCLE_FILL
SFSymbolWeatherCLOUD, SUN_MAX, BOLT
SFSymbolStatusCHECKMARK, INFO_CIRCLE
SFSymbolCommerceBAG, BAG_BADGE_PLUS
SFSymbolMediaPLAY, PAUSE, STOP
SFSymbolLettersA_CIRCLE, A_SQUARE
SFSymbolTextFormattingBOLD, CHARACTER
SFSymbolCommunicationENVELOPE, PHONE, MESSAGE
SFSymbolPowerPOWER, POWER_CIRCLE
SFSymbolSecurityKEY, KEY_FILL
SFSymbolHealthALLERGENS, BASEBALL
SFSymbolLocationFLAG, COMPASS_DRAWING
SFSymbolTimeALARM, ALARM_FILL
SFSymbolConnectivityCABLE_COAXIAL, CABLE_CONNECTOR

What's next

Was this page helpful?
Edit on GitHub

Last updated on