sfsymbols

package
v0.1.17 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2026 License: MIT Imports: 3 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

sfsymbols

Apple's SF Symbols for Golet apps of native UI on macOS: the symbols the running system has, drawn by AppKit and handed over as an image.

import "github.com/HyperparameterSI/golet/backend/plugins/sfsymbols"

sfsymbols.Symbol(c, "gearshape")
sfsymbols.Symbol(c, "trash").Size(20).Color(t.Accent).Weight(sfsymbols.Semibold).Fill()

See the documentation, and examples/sf-symbols. Nothing of Apple's artwork is in the plugin: the symbols come from the system.

Documentation

Overview

Package sfsymbols draws Apple's SF Symbols, as the running macOS has them, for native UI.

sfsymbols.Symbol(c, "gearshape")
sfsymbols.Symbol(c, "trash").Size(20).Color(t.Accent).Weight(sfsymbols.Semibold).Fill()

Symbol shows one as SwiftUI's Image(systemName:) does; Image gives the bitmap, for drawing with a ui.Painter.

The symbols are read from the system: AppKit draws each with its own design and weight, and the plugin copies the pixels. Nothing of Apple's artwork is in the app or its build. Where the system has no symbol of a name, and on every other OS, Image says so and Symbol draws its Fallback instead.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available() bool

Available reports whether this system draws SF Symbols at all. It does not.

func Image

func Image(name string, px int, col ui.Color, o Options) (ui.ImageSource, bool)

Image returns the SF Symbol named name, drawn px pixels square in col, or false where the system has no such symbol: on another OS, or a macOS without it. Here it never has one.

func Names

func Names() []string

Names returns the names of the SF Symbols this system has. It has none.

Types

type Options

type Options struct {
	// Natural draws the symbol at the size it has beside others of the
	// same point size, rather than filling its box: a cross stays smaller
	// than a wide rectangle, as SF Symbols balance them.
	Natural bool
	// Weight is the weight of the symbol's strokes, Regular by default.
	Weight Weight
}

Options of a symbol's drawing.

type SymbolElement

type SymbolElement struct {
	ui.Element
	// contains filtered or unexported fields
}

SymbolElement is the element Symbol makes: a ui.Element, with the symbol's own modifiers. Each returns the element, so they chain as SwiftUI's do, and the ui.Element's own methods (Margin, Tooltip, ...) are there too.

func Symbol

func Symbol(c *ui.Context, name string) SymbolElement

Symbol shows the SF Symbol named name, as SwiftUI's Image(systemName:): at the theme's font size and in its text color, drawn sharp at the display's scale, and named for assistive technology.

sfsymbols.Symbol(c, "gearshape")
sfsymbols.Symbol(c, "trash").Size(20).Color(t.Accent).Weight(sfsymbols.Semibold).Fill()
sfsymbols.Symbol(c, "sparkles").Fallback(sparkles) // an SVG where the system has none

Where the system has no symbol of that name, on another OS or a macOS without it, it draws its Fallback, or nothing, at the same size.

func (SymbolElement) Color

func (e SymbolElement) Color(col ui.Color) SymbolElement

Color draws the symbol in col rather than the theme's text color, as SwiftUI's foregroundStyle.

func (SymbolElement) Fallback

func (e SymbolElement) Fallback(svg *ui.SVG) SymbolElement

Fallback draws svg, in the symbol's color, where the system has no such symbol.

func (SymbolElement) Fill

func (e SymbolElement) Fill() SymbolElement

Fill draws the symbol's filled variant where it has one ("trash.fill" for "trash"), and the symbol itself where it has none, as SwiftUI's symbolVariant(.fill).

func (SymbolElement) Natural

func (e SymbolElement) Natural() SymbolElement

Natural draws the symbol at the size it has beside others of the same point size, rather than filling its box: see Options.Natural.

func (SymbolElement) Size

func (e SymbolElement) Size(size float32) SymbolElement

Size sets the symbol's box, size DIPs square.

func (SymbolElement) Weight

func (e SymbolElement) Weight(w Weight) SymbolElement

Weight draws the symbol's strokes at w, as SwiftUI's fontWeight.

type Weight

type Weight int

Weight is the weight of a symbol's strokes, as a font's.

const (
	UltraLight Weight = iota - 3
	Thin
	Light
	Regular
	Medium
	Semibold
	Bold
	Heavy
	Black
)

The weights of SF Symbols, from the lightest to the heaviest, in that order; the zero Weight is Regular.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL