loading

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

loading

The 29 loading indicators of loading.dev for Golet apps of native UI: arcs, rings, dots, bars and blocks that Golet draws itself, as loading.dev's look and move.

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

loading.Arc(c).Label("Saving")
loading.Ring(c, loading.Options{Size: 32, Color: t.Accent, Easing: loading.EaseInOut})

See the documentation, and examples/loading.

The indicators follow loading.dev's SVG and CSS (loading-dev 0.3.5, MIT, © Jakub Krehel; see NOTICE.md): their shapes in the same viewBoxes and fractions of their size, their keyframes, staggers and timing functions, and their poses for reduced motion. Compared with loading-dev rendered by a browser at the same points of their cycles, they differ only where the browser snaps borders to pixels (Atom's rings), in antialiasing, and on macOS in the corners of rounded squares (Blocks, Gather, Morph, Swirl, Flip), which the renderers draw continuous, as macOS does, so that they need no mask rasterized every frame.

Documentation

Overview

Package loading has the 29 loading indicators of loading.dev (https://loading.dev, Jakub Krehel's loading-dev for React) for native UI: arcs, dots, bars and blocks that Golet draws itself, each a ui element that moves as long as it shows.

loading.Arc(c)
loading.Ring(c, loading.Options{Size: 32, Color: t.Accent, Easing: loading.EaseInOut})
ui.Row(c).Gap(8).Children(func() {
	loading.BouncingDots(c, loading.Options{Size: 12})
	ui.Text(c, "Thinking")
})

An indicator is Options.Size DIPs high, 20 unless set, and as wide, or wider for a row of dots; the element's own size, as Size or Fill set it, scales it. It draws in the theme's text color unless Options.Color says otherwise, and runs at loading.dev's pace unless Options.Duration says otherwise. Where the desktop asks for less motion (ui.Preferences.ReduceMotion) it stands still, in loading.dev's pose for reduced motion; Options.Paused stops it where it is.

Assistive technology sees a progress indicator of unknown length; name it with Label.

Index

Constants

View Source
const DefaultSize = 20

DefaultSize is an indicator's height when Options.Size is 0.

Variables

This section is empty.

Functions

func Arc

func Arc(c *ui.Context, o ...Options) ui.Element

Arc creates a single open stroke turning in a circle.

func Atom

func Atom(c *ui.Context, o ...Options) ui.Element

Atom creates three rings tumbling inside a circle.

func Blocks

func Blocks(c *ui.Context, o ...Options) ui.Element

Blocks creates nine blocks shrinking and growing in a sweep across a grid, in the order Options.Sweep says.

func BouncingDots

func BouncingDots(c *ui.Context, o ...Options) ui.Element

BouncingDots creates three staggered dots bouncing up and down, in a row 1.15 times as wide as it is high.

func Cascade

func Cascade(c *ui.Context, o ...Options) ui.Element

Cascade creates three nested arcs fanning into a spiral, then snapping back in line.

func CircularDots

func CircularDots(c *ui.Context, o ...Options) ui.Element

CircularDots creates eight dots in a ring, the brightest going around.

func Classic

func Classic(c *ui.Context, o ...Options) ui.Element

Classic creates twelve fading bars in a radial pattern.

func ClassicV2

func ClassicV2(c *ui.Context, o ...Options) ui.Element

ClassicV2 creates eight ticks in a ring, lit in turn.

func Clock

func Clock(c *ui.Context, o ...Options) ui.Element

Clock creates a clock hand sweeping around a faint face.

func Comet

func Comet(c *ui.Context, o ...Options) ui.Element

Comet creates a full ring fading into its tail.

func Compass

func Compass(c *ui.Context, o ...Options) ui.Element

Compass creates four ticks turning a quarter turn at a time.

func Dual

func Dual(c *ui.Context, o ...Options) ui.Element

Dual creates two arcs turning in opposite directions.

func Eclipse

func Eclipse(c *ui.Context, o ...Options) ui.Element

Eclipse creates two dots trading places, one passing behind the other.

func Flip

func Flip(c *ui.Context, o ...Options) ui.Element

Flip creates a square flipping over one axis, then the other.

func Gather

func Gather(c *ui.Context, o ...Options) ui.Element

Gather creates four blocks pulling together, turning, and pushing apart.

func Leap

func Leap(c *ui.Context, o ...Options) ui.Element

Leap creates three dots in a row, the last one leaping to the front.

func LinearDots

func LinearDots(c *ui.Context, o ...Options) ui.Element

LinearDots creates three dots lighting up in turn from left to right, in a row nearly as wide as it is high.

func Loading

func Loading(c *ui.Context, o ...Options) ui.Element

Loading creates the loading.dev mark, its brightest segment circling the ring.

func Morph

func Morph(c *ui.Context, o ...Options) ui.Element

Morph creates a square rounding into a circle and back as it turns.

func Orbit

func Orbit(c *ui.Context, o ...Options) ui.Element

Orbit creates a fading half ring turning around a dot.

func Pulse

func Pulse(c *ui.Context, o ...Options) ui.Element

Pulse creates a ring rippling outward from a dot.

func Radar

func Radar(c *ui.Context, o ...Options) ui.Element

Radar creates a fading beam sweeping around a faint dish.

func Ring

func Ring(c *ui.Context, o ...Options) ui.Element

Ring creates an arc turning in a faint circle.

func Ripple

func Ripple(c *ui.Context, o ...Options) ui.Element

Ripple creates three rings spreading out from the center, or drawing in to it, as Options.Direction says.

func Slide

func Slide(c *ui.Context, o ...Options) ui.Element

Slide creates three dots sliding into the empty corner of a square.

func Snake

func Snake(c *ui.Context, o ...Options) ui.Element

Snake creates an arc stretching and shrinking as it circles.

func Swirl

func Swirl(c *ui.Context, o ...Options) ui.Element

Swirl creates a bright cell chasing its trail around a square.

func Trace

func Trace(c *ui.Context, o ...Options) ui.Element

Trace creates a dash tracing the outline of a rounded square.

func Wave

func Wave(c *ui.Context, o ...Options) ui.Element

Wave creates five bars rising and falling in a wave, from their middle or their bottom as Options.Origin says.

Types

type Cap

type Cap uint8

Cap is how a stroke ends.

const (
	// RoundCap ends a stroke in a half circle.
	RoundCap Cap = iota
	// FlatCap ends a stroke square, where it ends.
	FlatCap
)

type Easing

type Easing uint8

Easing is how an indicator that turns moves through a turn.

const (
	// Linear turns at one speed.
	Linear Easing = iota
	// EaseInOut starts and ends each turn slowly, as CSS's ease-in-out.
	EaseInOut
	// Stacked adds a turn at one speed and one easing in and out: two
	// turns a cycle, fast in its middle.
	Stacked
)

type Options

type Options struct {
	// Size is the indicator's height in DIPs, 20 if 0. Its width is the
	// same, except for BouncingDots's and LinearDots's rows of dots.
	Size float32
	// Color is what the indicator draws in, the theme's Text if zero.
	Color ui.Color
	// Duration is the time of one cycle of the indicator's motion, its
	// own (as loading.dev's) if 0.
	Duration time.Duration
	// Paused stops the indicator where it is, and it goes on from there
	// once false again, as CSS's paused animation-play-state.
	Paused bool
	// Easing is how the indicators that turn (Arc, Atom, Clock, Comet,
	// Dual, Orbit, Radar, Ring, Snake and Trace) turn: Linear by default.
	Easing Easing
	// Cap is the end of the strokes of Arc, Cascade, Dual, Ring, Snake
	// and Trace: RoundCap by default.
	Cap Cap
	// Sweep is the order in which Blocks's blocks shrink: Diagonal by
	// default.
	Sweep Sweep
	// Direction is where Ripple's rings go: RippleOut by default.
	Direction RippleDirection
	// Origin is where Wave's bars grow from: WaveCenter by default.
	Origin WaveOrigin
}

Options are the settings of an indicator, each meaning loading.dev's default when zero.

type RippleDirection

type RippleDirection uint8

RippleDirection is where Ripple's rings go.

const (
	// RippleOut spreads the rings out from the center.
	RippleOut RippleDirection = iota
	// RippleIn draws the rings in to the center.
	RippleIn
)

type Spinner

type Spinner struct {
	// Name is the indicator's name, as loading.dev's: "Arc", "Bouncing dots".
	Name string
	// New creates the indicator, as the function of its name does.
	New func(c *ui.Context, o ...Options) ui.Element
}

A Spinner is one of the indicators, by name, as a gallery lists them.

func All

func All() []Spinner

All returns the indicators, by name.

type Sweep

type Sweep uint8

Sweep is the order of Blocks's blocks.

const (
	// Diagonal sweeps from the top left corner to the bottom right one.
	Diagonal Sweep = iota
	// Rows sweeps from the top row down.
	Rows
	// Columns sweeps from the left column right.
	Columns
)

type WaveOrigin

type WaveOrigin uint8

WaveOrigin is where Wave's bars grow from.

const (
	// WaveCenter grows the bars up and down from their middle.
	WaveCenter WaveOrigin = iota
	// WaveBottom grows the bars up from the bottom.
	WaveBottom
)

Jump to

Keyboard shortcuts

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