progress

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package progress provides constructors and methods for the HTML <progress> element.

The <progress> HTML element displays a visual indicator showing task completion progress, typically rendered as a progress bar. The value attribute indicates current progress, while max defines the target. Used for file uploads, form completion, loading states, and any measurable task progress. Content within the element serves as fallback text for browsers that don't support the element.

Index

Constants

This section is empty.

Variables

View Source
var (
	TagOpen  = []byte("<progress")
	TagClose = []byte("</progress>")

	AttrValue = []byte(" value=\"")
	AttrMax   = []byte(" max=\"")
)

Byte constants for HTML rendering.

Functions

func New

func New(nodes ...node.Node) *element

New creates a new progress element with optional child nodes for fallback content. Example: progress.New() Renders: <progress></progress>

func RawText

func RawText(content string) *element

RawText creates a new progress element with raw fallback text content. Uses text.RawText which is not HTML-escaped. Example: progress.RawText("<span>50%</span>") Renders: <progress><span>50%</span></progress>

func RawTextf

func RawTextf(format string, args ...any) *element

RawTextf creates a new progress element with formatted raw fallback text content. Uses text.RawTextf which is not HTML-escaped. Example: progress.RawTextf("<strong>%d%%</strong>", pct) Renders: <progress><strong>75%</strong></progress>

func Static

func Static(content string) *element

Static creates a new progress element with static fallback text content. Uses text.Static which is not HTML-escaped and is JIT-optimisable. Example: progress.Static("Loading...") Renders: <progress>Loading...</progress>

func Text

func Text(content string) *element

Text creates a new progress element with fallback text content. Uses text.Text which HTML-escapes the output. Example: progress.Text("50% complete") Renders: <progress>50% complete</progress>

func Textf

func Textf(format string, args ...any) *element

Textf creates a new progress element with formatted fallback text content. Uses text.Textf which HTML-escapes the output. Example: progress.Textf("%d%% complete", pct) Renders: <progress>75% complete</progress>

func ValueMax

func ValueMax(value float64, max float64, nodes ...node.Node) *element

ValueMax creates a new progress element with value and max attributes set. Example: progress.ValueMax(75, 100) Renders: <progress value="75" max="100"></progress>

Types

type Element

type Element = element

Element is an exported alias for the private element type

Jump to

Keyboard shortcuts

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