Documentation
¶
Overview ¶
Package ui provides composable templ components, Tailwind styles and optional chart rendering. Applications retain their routes, permissions and live transport.
Index ¶
- func Actions() templ.Component
- func AssetHandler(prefix string) http.Handler
- func Assets() fs.FS
- func AuthStatus(props AuthStatusProps) templ.Component
- func Badge() templ.Component
- func Button(props ButtonProps) templ.Component
- func Dialog(props DialogProps) templ.Component
- func DialogBody() templ.Component
- func DialogHeader(props DialogHeaderProps) templ.Component
- func Field(props FieldProps) templ.Component
- func Head(props HeadProps) templ.Component
- func Input(props InputProps) templ.Component
- func LinkButton(props LinkButtonProps) templ.Component
- func MarshalEChartsOption(option any) (string, error)
- func MetricText(value string) string
- func PageHeader(props PageHeaderProps) templ.Component
- func Select(props SelectProps) templ.Component
- func StatusIndicator(props StatusIndicatorProps) templ.Component
- func Tab(props TabProps) templ.Component
- func Tabs(label string) templ.Component
- func VersionLabel(info versioning.Info) templ.Component
- func Widget(props WidgetProps) templ.Component
- func WidgetChart(props WidgetChartProps) templ.Component
- func WidgetData(label string) templ.Component
- func WidgetEmpty() templ.Component
- func WidgetHeader(props WidgetHeaderProps) templ.Component
- func WidgetMetric(label, value, note string) templ.Component
- func WidgetMetricFrame(props WidgetMetricProps) templ.Component
- func WidgetMetricValue(value, exact string) templ.Component
- type AuthState
- type AuthStatusProps
- type ButtonKind
- type ButtonProps
- type DialogHeaderProps
- type DialogProps
- type EChartsBubbleSize
- type EChartsConfig
- type EChartsConversion
- type EChartsEvents
- type EChartsFormatBinding
- type EChartsMessages
- type EChartsOption
- type EChartsTooltip
- type EChartsTooltipValue
- type EChartsValueFormat
- type FieldProps
- type HeadProps
- type InputProps
- type LinkButtonProps
- type Option
- type PageHeaderProps
- type SelectProps
- type StatusAlpineBindings
- type StatusIndicatorProps
- type StatusPulseStyle
- type StatusTone
- type TabProps
- type WidgetChartProps
- type WidgetElement
- type WidgetHeaderProps
- type WidgetMetricProps
- type WidgetProps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssetHandler ¶ added in v0.7.0
AssetHandler serves the embedded assets below an application-owned URL path. Empty prefix defaults to /assets/ui/; other prefixes are normalized to a local absolute path with a trailing slash, just as in HeadProps. Register the handler at that prefix in the application's router and apply its middleware there. Calling AssetHandler does not register routes or change the default mux.
func Assets ¶
Assets serves ui.css, the official echarts.min.js and first-party echarts-format.js/ui-htmx-charts.js without a repository-layout prefix. Serve with http.FileServer and http.StripPrefix at the application-owned URL. The former echarts-ui.js filename remains an alias to the same controller. v0.6.0's retired chart-schema bundle URLs remain unavailable.
func AuthStatus ¶ added in v0.7.0
func AuthStatus(props AuthStatusProps) templ.Component
AuthStatus renders a closed lock for confirmed sign-in, an open lock for confirmed sign-out, and a neutral question icon for unknown state. All three fragments remain stable; changing data-auth-state switches icon and text together through CSS. The library never infers state from labels or credentials.
func Button ¶
func Button(props ButtonProps) templ.Component
func Dialog ¶
func Dialog(props DialogProps) templ.Component
Dialog supplies the native shell; apps explicitly open it and own close/focus behavior, form submission and authorization. No content is moved or fetched here.
func DialogBody ¶
func DialogHeader ¶
func DialogHeader(props DialogHeaderProps) templ.Component
func Field ¶
func Field(props FieldProps) templ.Component
func Head ¶ added in v0.7.0
Head emits shared assets once in a full page's head, not in HTMX/SSE fragments. It uses external deferred scripts, leaves CSP policy to the application, and does not insert a page shell, inline code, fonts or global routes.
func Input ¶
func Input(props InputProps) templ.Component
func LinkButton ¶
func LinkButton(props LinkButtonProps) templ.Component
func MarshalEChartsOption ¶ added in v0.6.0
MarshalEChartsOption serializes native JSON without generating JavaScript or trusting HTML. Widgets escape the result into an attribute; JS-only clients use JSON.stringify with the same native object. Runtime validation also applies.
func MetricText ¶
Format only numeric metric labels. Keep units, unavailable values, small precise costs and partial-coverage qualifiers in their original form.
func PageHeader ¶
func PageHeader(props PageHeaderProps) templ.Component
func Select ¶
func Select(props SelectProps) templ.Component
func StatusIndicator ¶ added in v0.7.0
func StatusIndicator(props StatusIndicatorProps) templ.Component
StatusIndicator renders a decorative dot and an escaped, visible label. Only the ring animates; the solid core and label remain readable. Connection checks, freshness and transport belong to the caller, which can update data-tone, data-pulse and the label without replacing the component's markup.
func VersionLabel ¶
func VersionLabel(info versioning.Info) templ.Component
func Widget ¶
func Widget(props WidgetProps) templ.Component
Keep the existing root element, classes and live attributes without adding a wrapper: table scrolling, semantic landmarks and DOM patch identity depend on them.
func WidgetChart ¶
func WidgetChart(props WidgetChartProps) templ.Component
The stable native ECharts host and its fallback remain siblings. Preserve the host and engine-owned children during application DOM patches; call update.
func WidgetData ¶
func WidgetEmpty ¶
func WidgetHeader ¶
func WidgetHeader(props WidgetHeaderProps) templ.Component
The children slot holds the view's actions or badges. Counts retain exact tooltips while using the same compact formatter as other numeric widgets.
func WidgetMetric ¶
func WidgetMetricFrame ¶
func WidgetMetricFrame(props WidgetMetricProps) templ.Component
func WidgetMetricValue ¶
Types ¶
type AuthState ¶ added in v0.7.0
type AuthState string
AuthState is an application's explicit authentication observation. Unknown includes checking, unavailable or stale observations; failures do not imply AuthSignedOut, and healthy service status does not imply AuthSignedIn.
type AuthStatusProps ¶ added in v0.7.0
type AuthStatusProps struct {
State AuthState
SignedInLabel, SignedOutLabel, UnknownLabel string
Class, LabelClass string
Attributes templ.Attributes
}
AuthStatusProps configures presentation only. Labels can be localized and are escaped; empty labels use the defaults. Attributes target the stable wrapper, for example an ID, live region or x-bind:data-auth-state expression. The caller must switch State to AuthUnknown when a verified observation becomes stale.
type ButtonKind ¶
type ButtonKind string
const ( Primary ButtonKind = "primary" Secondary ButtonKind = "secondary" Danger ButtonKind = "danger" )
type ButtonProps ¶
type ButtonProps struct {
Type, Class string
Kind ButtonKind
Disabled bool
Attributes templ.Attributes
}
type DialogHeaderProps ¶
type DialogHeaderProps struct{ TitleID, Title, Description string }
type DialogProps ¶
type DialogProps struct {
ID, TitleID, Class string
Attributes templ.Attributes
}
type EChartsBubbleSize ¶ added in v0.6.0
type EChartsBubbleSize struct {
SeriesID string `json:"seriesId,omitempty"`
SeriesIndex *int `json:"seriesIndex,omitempty"`
Dimension int `json:"dimension"`
Min *float64 `json:"min,omitempty"`
Max *float64 `json:"max,omitempty"`
}
EChartsBubbleSize supplies the numeric dimension used by the native scatter symbolSize callback. Min/Max are accepted diameter bounds, not inferred weights.
type EChartsConfig ¶ added in v0.6.0
type EChartsConfig struct {
Locale string `json:"locale,omitempty"`
TimeZone string `json:"timeZone,omitempty"`
Formats []EChartsFormatBinding `json:"formats,omitempty"`
Tooltip []EChartsTooltip `json:"tooltip,omitempty"`
BubbleSizes []EChartsBubbleSize `json:"bubbleSizes,omitempty"`
Events EChartsEvents `json:"events,omitzero"`
Messages EChartsMessages `json:"messages,omitzero"`
Empty bool `json:"empty,omitempty"`
Loading bool `json:"loading,omitempty"`
}
EChartsConfig contains only callbacks JSON cannot encode and shared lifecycle state. Geometry, chart families and data are always native Option fields.
type EChartsConversion ¶ added in v0.6.0
type EChartsEvents ¶ added in v0.6.0
type EChartsFormatBinding ¶ added in v0.6.0
type EChartsFormatBinding struct {
Target string `json:"target"`
Format EChartsValueFormat `json:"format"`
Dimension *int `json:"dimension,omitempty"`
Compact bool `json:"compact,omitempty"`
}
EChartsFormatBinding installs a trusted callback only at a documented native formatter target. Dimension selects a vector coordinate; nil means scalar.
type EChartsMessages ¶ added in v0.6.0
type EChartsOption ¶ added in v0.6.0
EChartsOption is a native ECharts option object. Fields such as series, xAxis, yAxis, legend, grid and dataZoom use the upstream JSON contract directly. It is not a library-specific chart schema. Functions cannot be serialized.
type EChartsTooltip ¶ added in v0.6.0
type EChartsTooltip struct {
SeriesID string `json:"seriesId,omitempty"`
SeriesIndex *int `json:"seriesIndex,omitempty"`
Values []EChartsTooltipValue `json:"values"`
}
type EChartsTooltipValue ¶ added in v0.6.0
type EChartsTooltipValue struct {
Dimension *int `json:"dimension,omitempty"`
Label string `json:"label,omitempty"`
Format EChartsValueFormat `json:"format"`
}
type EChartsValueFormat ¶ added in v0.6.0
type EChartsValueFormat struct {
Unit string `json:"unit,omitempty"`
Precision *int `json:"precision,omitempty"`
Scale string `json:"scale,omitempty"`
InputUnit string `json:"inputUnit,omitempty"`
DisplayUnit string `json:"displayUnit,omitempty"`
Conversion *EChartsConversion `json:"conversion,omitempty"`
}
EChartsValueFormat describes display-only conversion; samples and bounds stay in their native input units. Unit "time" uses Locale/TimeZone, numeric units use the documented bit/byte/rate/custom conversion rules.
type FieldProps ¶
type FieldProps struct {
For, Label, Hint, Class string
Attributes templ.Attributes
}
type HeadProps ¶ added in v0.7.0
HeadProps configures a page's shared stylesheet and optional chart scripts. AssetPrefix is the local URL path registered with AssetHandler; empty uses /assets/ui/. Charts includes the engine, formatter and controller in that order. Nonce is an optional application-supplied CSP nonce for external scripts.
type InputProps ¶
type InputProps struct {
ID, Name, Value, Type, Placeholder, Class string
Required, Disabled bool
Attributes templ.Attributes
}
type LinkButtonProps ¶
type LinkButtonProps struct {
Href, Class string
Kind ButtonKind
Attributes templ.Attributes
}
type PageHeaderProps ¶
type PageHeaderProps struct {
Title, Description, Class string
Attributes templ.Attributes
}
Presentation props accept server-defined attributes for HTMX and other callers. Permissions, CSRF fields and event handlers remain the application's responsibility.
type SelectProps ¶
type SelectProps struct {
ID, Name, Value, Class string
Options []Option
Required, Disabled bool
Attributes templ.Attributes
}
type StatusAlpineBindings ¶ added in v0.7.0
type StatusAlpineBindings struct {
Show, Label, LabelClass, Tone, Pulse string
}
StatusAlpineBindings holds optional, trusted developer-written expressions. The application loads Alpine and owns the state these expressions reference. Empty expressions add no binding. Pulse is converted to a true/false data attribute; LabelClass augments the label's static classes using Alpine rules.
type StatusIndicatorProps ¶ added in v0.7.0
type StatusIndicatorProps struct {
Label, Class string
LabelClass string
Tone StatusTone
Pulse bool
PulseStyle StatusPulseStyle
Alpine *StatusAlpineBindings
Attributes templ.Attributes
LabelAttributes templ.Attributes
}
StatusIndicatorProps configures a dot and visible text label. The zero tone and unrecognized tones render neutral; Pulse is opt-in for every tone. Attributes target the wrapper (for IDs, HTMX, live regions or data bindings); LabelAttributes target the text span (for example, Alpine's x-text). Attributes and classes must be server-defined, as with the other controls.
type StatusPulseStyle ¶ added in v0.7.0
type StatusPulseStyle string
StatusPulseStyle selects the decorative animation without deciding when it should run. StatusRing is the default; StatusPing expands a filled circle.
const ( StatusRing StatusPulseStyle = "ring" StatusPing StatusPulseStyle = "ping" )
type StatusTone ¶ added in v0.7.0
type StatusTone string
StatusTone selects a status indicator's semantic color, independently of its label and animation. Applications decide which observations warrant each tone.
const ( StatusNeutral StatusTone = "neutral" StatusSuccess StatusTone = "success" StatusWarning StatusTone = "warning" StatusDanger StatusTone = "danger" StatusInfo StatusTone = "info" )
type TabProps ¶
type TabProps struct {
Label, Href, Class string
Active bool
Attributes templ.Attributes
}
type WidgetChartProps ¶
type WidgetChartProps struct {
ID, Label string
Option any
Config EChartsConfig
EmptyMessage, ErrorMessage, NoScriptNote string
Compact bool
}
WidgetChartProps accepts native ECharts options and safe callback/lifecycle metadata. Option may be EChartsOption, a JSON-marshallable struct or RawMessage. v0.6.0 intentionally replaces Spec; older pinned releases retain that API.
type WidgetElement ¶
type WidgetElement uint8
WidgetElement preserves the semantic containers used by existing pages. A closed set prevents callers from constructing arbitrary HTML tag names.
const ( WidgetSection WidgetElement = iota WidgetDiv WidgetAside )
type WidgetHeaderProps ¶
type WidgetMetricProps ¶
type WidgetProps ¶
type WidgetProps struct {
Element WidgetElement
Class string
Attributes templ.Attributes
}
WidgetProps contains presentation and trusted, server-defined attributes. Feature views retain responsibility for permission checks, links and data.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
showcase
command
|
|
|
scripts
|
|
|
module-version
command
Command module-version plans conventional library tags with go-versioning's core policy.
|
Command module-version plans conventional library tags with go-versioning's core policy. |