uiDisplay

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2026 License: MIT Imports: 10 Imported by: 0

README

Display

Display layer of Infinite UI. It shows content, state, and page chrome. Part of Infinite UI.

Accordion

Collapsible sections built on <details> and <summary>.

@uiDisplay.Accordion(uiDisplay.AccordionSettings{
    Items: []uiDisplay.AccordionItemSettings{
        {Title: "Section 1", Content: AccordionDemoSection1(), Icon: "ph-info"},
        {Title: "Section 2", Content: AccordionDemoSection2()},
    },
})

Each item takes a Title, a Content component, and an optional Icon.

BorderRadius rounds only the outer edges: the first item's top corners and the last item's bottom corners. Middle items stay square.

ContentBackgroundColor sets the color behind an open item's content. The default is neutral-900. Match it to the surface that holds the accordion. The content then reads as a cutout of that surface, with rounded inner edges and padding.

Set IsSingleOpen to keep one item open at a time. The component groups the items under a shared name, so opening one closes the rest.

TextCase accepts a uiToolset.TextCase* value and transforms the item titles. The default, TextCaseNone, leaves them as typed.

Alert

Status message with title, description, and variation presets.

@uiDisplay.Alert(uiDisplay.AlertSettings{
    Title:       "Alert Title",
    Description: "This is an alert message.",
    Variation:   uiDisplay.AlertVariationInfo,
    Size:        uiDisplay.AlertSizeMd,
    IsCloseable: true,
})
  • Variation accepts AlertVariationSuccess, AlertVariationWarning, AlertVariationError, or AlertVariationInfo.
  • ContentHtml replaces the title and description with custom markup.
  • Title and Description render as raw HTML. Pass only trusted content. Never pass request data into these fields.
  • IsCloseable shows a close button. DisplayTimeoutSeconds and OnTimeoutFunc auto-dismiss the alert.
  • Title and description support live state through the *OneWayStatePath fields.

CloakLoading

Full-screen loader that covers the page before CSS and JavaScript load. Place it as the first element in <body>.

@uiDisplay.CloakLoading(uiDisplay.CloakLoadingSettings{
    HideDelaySeconds: "1",
    TextMessage:      "Loading...",
    Icon:             "ph-compass-rose",
})

It uses inline styles on purpose, so it renders before the stylesheet arrives. It hides HideDelaySeconds after Alpine finishes initializing. Icon sizes accept the CloakLoadingIconSize* constants, and animations accept the CloakLoadingAnimationName* constants.

ConfirmationDialog and Presets

Confirmation dialogs over Modal with four presets: ConfirmDialog, WarningDialog, CriticalDialog, and DeleteDialog. Each preset supplies its icon, tone, and confirmation copy. CriticalDialog and DeleteDialog enable the type-to-confirm gate and have no fullscreen mode.

@uiDisplay.DeleteDialog(uiDisplay.ConfirmationDialogSettings{
    IsVisibleTwoWayStatePath: "isDeleteDialogVisible",
    OnConfirmFunc:            "deleteRecord()",

    // OptionalFields
    TargetNameStatePath: "record.name",
    TargetIdStatePath:   "record.id",
})
  • Size accepts ConfirmationDialogSizeXs (40%) through ConfirmationDialogSizeXxl (90%) as viewport percentages on both axes, like Modal. The default is ConfirmationDialogSizeSm (50%). There is no fullscreen size and no resize control. WidthPercent and HeightPercent override the panel box like Modal. The default height hugs the content with an 85% ceiling; set HeightPercent to pin it.
  • The header block carries HeaderTitle, HeaderSubHeading, HeaderTitleOneWayStatePath, HeaderSubHeadingOneWayStatePath, HeaderTitleColor, HeaderSubHeadingColor, HeaderSize, TextCase, and the HeaderIcon* icon controls. ActionsContent adds buttons next to the close button. HeaderContent replaces the whole header block. TextColor sets the dialog text color. Each preset fills the title and icon defaults.
  • HeaderIconPosition defaults to HeaderIconPositionTop, which centers the icon above the title. Set HeaderIconPositionLeft to place it beside the title.
  • TargetNameStatePath and TargetIdStatePath bind live values into the message. The name renders as a dashed chip and the id as #<id>.
  • IsTypeToConfirmEnabled turns on the type-to-confirm gate. CriticalDialog and DeleteDialog set it. The confirm button enables only when the typed value matches the target name (or the target id when no name path is set). An empty or missing target keeps the confirm button disabled. TypeToConfirmValueTwoWayStatePath moves the typed value into your own Alpine state; the default keeps it inside the dialog.
  • Two type-to-confirm dialogs on one page each hold their own typed value, but both fields use the input name typedConfirmationValue. Keep them out of one shared submitted form.
  • Pass state paths from code, never from request data. The component embeds them into client-side expressions.
  • Message replaces the note under the question. MessageContent replaces the whole message block.
  • CancelFunc defaults to closing the dialog. OnConfirmFunc runs as written, so append the close when the action succeeds.
  • The cancel button renders outlined with a light ring. The confirm button carries the preset tone fill, so the eye lands on it first.
  • HeaderTitle, ConfirmButtonLabel, ConfirmButtonIcon, and CancelButtonLabel override the preset copy.

HeaderBlock

Shared header row behind PageHeading, Card, and ConfirmationDialog: icon, heading, sub-heading, and a right-aligned actions slot.

@uiDisplay.HeaderBlock(uiDisplay.HeaderBlockSettings{
    HeaderTitle: "Network",

    // OptionalFields
    HeaderSubHeading:   "Interfaces and routes",
    HeaderIcon:         "ph-globe",
    HeaderIconPosition: uiDisplay.HeaderIconPositionLeft,
    HeadingLevel:       uiDisplay.HeaderBlockHeadingLevelTwo,
})
  • HeadingLevel accepts HeaderBlockHeadingLevelOne or HeaderBlockHeadingLevelTwo; the default is two.
  • HeaderSize accepts HeaderSizeXs through HeaderSizeXl and scales the title, icon, and sub-heading together.
  • The HeaderIcon* fields match HeaderIcon. HeaderIconPosition accepts HeaderIconPositionLeft or HeaderIconPositionTop.
  • HeaderTitleColor, HeaderSubHeadingColor, and TextColor take color tokens.
  • TextCase accepts a uiToolset.TextCase* value and transforms the title and sub-heading. The default, TextCaseNone, leaves them as typed. Card, PageHeading, and ConfirmationDialog forward it.

HeaderIcon

Icon with an optional background chip.

@uiDisplay.HeaderIcon(uiDisplay.HeaderIconSettings{
    Name: "ph-cube",

    // OptionalFields
    Color:           "red-950",
    BackgroundColor: "neutral-300",
    BorderRadius:    uiToolset.BorderRadiusXl,
    PaddingSize:     uiToolset.PaddingSizeLg,
})
  • Color sets the icon text color. BackgroundColor sets the chip behind it. Icon placement (left of the title or above it) belongs to HeaderBlock's HeaderIconPosition.
  • BorderRadius accepts uiToolset.BorderRadiusNone through uiToolset.BorderRadiusFull. PaddingSize accepts uiToolset.PaddingSizeNone through uiToolset.PaddingSizeXl.

LoadingOverlay

Overlay for in-flight requests. It binds to a state path or reacts to the HTMX htmx-request class.

@uiDisplay.LoadingOverlay(uiDisplay.LoadingOverlaySettings{
    IsLoadingOneWayStatePath: "isLoading",
    Icon:                     "ph-compass-rose",
    IconSize:                 uiDisplay.LoadingOverlayIconSizeMd,
    AnimationName:            uiDisplay.LoadingOverlayAnimationNameSpin,
})

Set hx-indicator="#loading-overlay" on HTMX elements, or toggle it with UiToolset.ToggleLoadingOverlay(). Pass Id to give a second overlay its own id.

Modal

Window-style dialog with header, middle, and footer slots.

@uiDisplay.Modal(uiDisplay.ModalSettings{
    MiddleContent:            ModalDemoContent(),
    Title:                    "Modal Title",
    InitialSize:              uiDisplay.ModalSizeMd,
    IsVisibleTwoWayStatePath: "isModalVisible",
})
  • The standard header appears when Title is set and HeaderContent is nil. It carries the enlarge, reduce, and close buttons. A custom HeaderContent still gets the same action cluster beside it.
  • InitialSize sets the panel box as a viewport percentage on both axes: ModalSizeXs (40%), ModalSizeSm (50%), ModalSizeMd (60%), ModalSizeLg (70%), ModalSizeXl (80%), ModalSizeXxl (90%), and ModalSizeFull (100%). Width and height grow together, so the box follows the screen's aspect ratio and a widescreen gets more width than height. ModalSizeXxl is the near-full size for wide content such as a web terminal. InitialSize also scales the header title and padding.
  • WidthPercent and HeightPercent replace the box on that axis with a viewport percentage. Set one to change a single dimension, or both to pin the panel. Values are whole percentages, 1 through 100; 100 renders a full axis. When both are set, the resize controls retire.
  • MinWidthPercent, MaxWidthPercent, MinHeightPercent, and MaxHeightPercent add viewport floors and ceilings on each axis. They combine with the size or percent that sets the box: the panel keeps its base width and height but never renders below a minimum or above a maximum. Same values and rules as WidthPercent.
  • PossibleSizes sets the ordered sizes the panel can take; the default is md, lg, xl, xxl. InitialSize is the first reachable entry: any entry before it is dropped, and an InitialSize outside the list falls to the first entry.
  • CurrentSizeTwoWayStatePath binds the live size so the enlarge and reduce controls can drive it. The modal creates an internal path when the field is empty and the panel is resizable.
  • Enlarge steps up one entry, reduce steps back one. Reduce hides at the initial size and enlarge hides at the largest reachable size.
  • ShouldHeightMatchContent renders the panel at its content height with an 85% ceiling, ignoring the size height. Use it for dialogs that must stay short.
  • IsMiddleContentScrollDisabled stops the middle region from scrolling and lets the content own the overflow, for a full-bleed panel such as a terminal.
  • IsUnresizable and IsUncloseable remove those buttons. The resize controls also retire when the panel holds fewer than two reachable sizes.
  • The close button and a backdrop click set the visibility path to false and run OnCloseFunc. IsUncloseable stops both; the app then closes the modal by setting the visibility path to false.
  • OnResizeFunc runs when either resize control is clicked.

Tag

Composite label with an outer ring and an inner background.

@uiDisplay.Tag(uiDisplay.TagSettings{
    OuterLeftIcon:  "ph-info",
    OuterLeftLabel: "Info",
    InnerIcon:      "ph-warning",
    InnerLabel:     "Warning",
    Size:           uiDisplay.TagSizeXs,
})
  • OuterLeft*, OuterRight*, and Inner* fields take an icon, a static label, or a *OneWayStatePath for live text.
  • InnerValueOneWayStatePath binds a live value in the inner segment without the lowercase transform, for client-side value tags: set a static OuterLeftLabel as the label and the path as the value.
  • Size accepts TagSizeTiny through TagSizeXl; TagSizeTiny renders a dense layout for table cells.
  • TextCase accepts a uiToolset.TextCase* value and transforms the label segments. The default, TextCaseNone, leaves them as typed.
  • Set OnRemoveFunc to render a removable chip. RemoveButtonLabel names the remove button.
  • OuterRadius and InnerRadius accept uiToolset.BorderRadius* values; both default to uiToolset.BorderRadiusMd.
  • OuterBackgroundColor, OuterRingColor, and OuterTextColor accept color tokens, for example "neutral-50/10".

Toast

Notification popup driven by an Alpine global store.

@uiDisplay.Toast(uiDisplay.ToastSettings{
    BackgroundColor:    "neutral-800",
    TextColor:          "neutral-50",
    Size:               uiDisplay.ToastSizeMd,
    AutoDismissSeconds: 10,
})

Render one Toast per page. Then call $store.toast.displayToast(message, type) or $store.toast.displayToastWithApiResponse(apiResponse, httpStatusCode). Call $store.toast.clearToast() to hide it early.

The toast surface takes a translucent tint from its type: success is green, partialSuccess is yellow, and danger is red. Set BackgroundColor to replace that tint with a fixed color.

When HTMX is present, the Toast listens to htmx:afterRequest. A JSON response with a readableMessage, a humanReadableMessage outcome, or a string body displays a toast automatically. The styling follows the HTTP status: 2xx success, 207 partial success, 4xx and above danger. Auto-dismiss defaults to 10 seconds.

Documentation

Overview

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

templ: version: v0.3.1070

Index

Constants

View Source
const (
	AlertVariationSuccess string = "success"
	AlertVariationWarning string = "warning"
	AlertVariationError   string = "error"
	AlertVariationInfo    string = "info"

	AlertSizeXs string = "xs"
	AlertSizeSm string = "sm"
	AlertSizeMd string = "md"
	AlertSizeLg string = "lg"
	AlertSizeXl string = "xl"
)
View Source
const (
	CloakLoadingIconSizeXs string = "2rem"
	CloakLoadingIconSizeSm string = "3rem"
	CloakLoadingIconSizeMd string = "5rem"
	CloakLoadingIconSizeLg string = "7rem"

	CloakLoadingTextSizeXs string = "0.75rem"
	CloakLoadingTextSizeSm string = "1rem"
	CloakLoadingTextSizeMd string = "1.25rem"
	CloakLoadingTextSizeLg string = "1.5rem"

	CloakLoadingAnimationNameBounce string = "bounce"
	CloakLoadingAnimationNamePing   string = "ping"
	CloakLoadingAnimationNamePulse  string = "pulse"
	CloakLoadingAnimationNameSpin   string = "spin"
)
View Source
const (
	ConfirmationDialogSizeXs  string = "xs"
	ConfirmationDialogSizeSm  string = "sm"
	ConfirmationDialogSizeMd  string = "md"
	ConfirmationDialogSizeLg  string = "lg"
	ConfirmationDialogSizeXl  string = "xl"
	ConfirmationDialogSizeXxl string = "xxl"
)
View Source
const (
	HeaderBlockHeadingLevelOne string = "1"
	HeaderBlockHeadingLevelTwo string = "2"

	HeaderSizeXs string = "xs"
	HeaderSizeSm string = "sm"
	HeaderSizeMd string = "md"
	HeaderSizeLg string = "lg"
	HeaderSizeXl string = "xl"
)
View Source
const (
	HeaderIconPositionLeft string = "left"
	HeaderIconPositionTop  string = "top"
)
View Source
const (
	LoadingOverlayIconSizeXs string = "text-2xl"
	LoadingOverlayIconSizeSm string = "text-3xl"
	LoadingOverlayIconSizeMd string = "text-5xl"
	LoadingOverlayIconSizeLg string = "text-7xl"

	LoadingOverlayAnimationNameBounce string = "bounce"
	LoadingOverlayAnimationNamePing   string = "ping"
	LoadingOverlayAnimationNamePulse  string = "pulse"
	LoadingOverlayAnimationNameSpin   string = "spin"
)
View Source
const (
	ModalSizeXs   string = "xs"
	ModalSizeSm   string = "sm"
	ModalSizeMd   string = "md"
	ModalSizeLg   string = "lg"
	ModalSizeXl   string = "xl"
	ModalSizeXxl  string = "xxl"
	ModalSizeFull string = "full"
)
View Source
const (
	TagSizeTiny string = "tiny"
	TagSizeXs   string = "xs"
	TagSizeSm   string = "sm"
	TagSizeMd   string = "md"
	TagSizeLg   string = "lg"
	TagSizeXl   string = "xl"
)
View Source
const (
	ToastSizeXs string = "xs"
	ToastSizeSm string = "sm"
	ToastSizeMd string = "md"
	ToastSizeLg string = "lg"

	ToastAutoDismissSecondsDefault int = 10
)

Variables

This section is empty.

Functions

func Accordion

func Accordion(componentSettings AccordionSettings) templ.Component

func Alert added in v0.1.4

func Alert(componentSettings AlertSettings) templ.Component

func CloakLoading added in v0.0.8

func CloakLoading(componentSettings CloakLoadingSettings) templ.Component

func ConfirmDialog added in v0.2.2

func ConfirmDialog(componentSettings ConfirmationDialogSettings) templ.Component

func CriticalDialog added in v0.2.2

func CriticalDialog(componentSettings ConfirmationDialogSettings) templ.Component

func DeleteDialog added in v0.2.2

func DeleteDialog(componentSettings ConfirmationDialogSettings) templ.Component

func HeaderBlock added in v0.2.2

func HeaderBlock(componentSettings HeaderBlockSettings) templ.Component

func HeaderIcon added in v0.2.2

func HeaderIcon(componentSettings HeaderIconSettings) templ.Component

func LoadingOverlay added in v0.0.6

func LoadingOverlay(componentSettings LoadingOverlaySettings) templ.Component
func Modal(componentSettings ModalSettings) templ.Component

func Tag

func Tag(componentSettings TagSettings) templ.Component

func Toast added in v0.0.5

func Toast(componentSettings ToastSettings) templ.Component

func WarningDialog added in v0.2.2

func WarningDialog(componentSettings ConfirmationDialogSettings) templ.Component

Types

type AccordionItemSettings

type AccordionItemSettings struct {
	Title   string
	Content templ.Component

	// OptionalFields
	Icon string
}

type AccordionSettings

type AccordionSettings struct {
	Items []AccordionItemSettings

	// OptionalFields
	BackgroundColor        string
	BorderColor            string
	BorderRadius           string
	ContentBackgroundColor string
	ContentPaddingSize     string
	IsSingleOpen           bool
	OpenBackgroundColor    string
	PaddingSize            string
	TextCase               string
	TitleColor             string
}

type AlertSettings added in v0.1.4

type AlertSettings struct {
	// OptionalFields
	ContentHtml                         templ.Component
	Title                               string
	TitleOneWayStatePath                string
	TitleLeftIcon                       string
	TitleLeftIconTwoWayStatePath        string
	TitleRightIcon                      string
	TitleRightIconTwoWayStatePath       string
	Description                         string
	DescriptionOneWayStatePath          string
	DescriptionLeftIcon                 string
	DescriptionLeftIconTwoWayStatePath  string
	DescriptionRightIcon                string
	DescriptionRightIconTwoWayStatePath string
	Variation                           string
	Size                                string
	MaxWidth                            string
	BackgroundColor                     string
	TextColor                           string
	TextTitleColor                      string
	TextDescriptionColor                string
	RingColor                           string
	RingThickness                       string
	BorderRadius                        string
	ShadowSize                          string
	IsCloseable                         bool
	IsCloseableOneWayStatePath          string
	CloseIconBackgroundColor            string
	CloseIconTextColor                  string
	OnCloseFunc                         string
	DisplayTimeoutSeconds               int
	OnTimeoutFunc                       string
}

type CloakLoadingSettings added in v0.0.8

type CloakLoadingSettings struct {
	// OptionalFields
	HideDelaySeconds             string
	BackgroundColor              string
	TextMessage                  string
	TextColor                    string
	TextSize                     string
	Icon                         string
	IconSize                     string
	IconColor                    string
	IconAnimationName            string
	IconAnimationDurationSeconds string
}

type ConfirmationDialogSettings added in v0.2.2

type ConfirmationDialogSettings struct {
	IsVisibleTwoWayStatePath string
	OnConfirmFunc            string

	// OptionalFields
	ActionsContent                    templ.Component
	CancelButtonLabel                 string
	CancelFunc                        string
	ConfirmButtonIcon                 string
	ConfirmButtonId                   string
	ConfirmButtonLabel                string
	HeaderContent                     templ.Component
	HeaderIcon                        string
	HeaderIconBackgroundColor         string
	HeaderIconBorderRadius            string
	HeaderIconColor                   string
	HeaderIconPaddingSize             string
	HeaderIconPosition                string
	HeaderSize                        string
	HeaderSubHeading                  string
	HeaderSubHeadingColor             string
	HeaderSubHeadingOneWayStatePath   string
	HeaderTitle                       string
	HeaderTitleColor                  string
	HeaderTitleOneWayStatePath        string
	IsTypeToConfirmEnabled            bool
	IsUncloseable                     bool
	Message                           string
	MessageContent                    templ.Component
	OnCloseFunc                       string
	Size                              string
	TargetIdStatePath                 string
	TargetNameStatePath               string
	TextCase                          string
	TextColor                         string
	TypeToConfirmExpectedValue        string
	TypeToConfirmValueTwoWayStatePath string
	WidthPercent                      int
	HeightPercent                     int
	MinWidthPercent                   int
	MaxWidthPercent                   int
	MinHeightPercent                  int
	MaxHeightPercent                  int
}

type HeaderBlockSettings added in v0.2.2

type HeaderBlockSettings struct {
	// OptionalFields
	ActionsContent                  templ.Component
	HeaderIcon                      string
	HeaderIconBackgroundColor       string
	HeaderIconBorderRadius          string
	HeaderIconColor                 string
	HeaderIconPaddingSize           string
	HeaderIconPosition              string
	HeaderSize                      string
	HeaderSubHeading                string
	HeaderSubHeadingColor           string
	HeaderSubHeadingOneWayStatePath string
	HeaderTitle                     string
	HeaderTitleColor                string
	HeaderTitleOneWayStatePath      string
	HeadingLevel                    string
	TextCase                        string
	TextColor                       string
}

type HeaderIconSettings added in v0.2.2

type HeaderIconSettings struct {
	Name string

	// OptionalFields
	BackgroundColor string
	BorderRadius    string
	Color           string
	PaddingSize     string
}

type LoadingOverlaySettings added in v0.0.6

type LoadingOverlaySettings struct {
	// OptionalFields
	IsLoadingOneWayStatePath string
	BackgroundColor          string
	Icon                     string
	IconSize                 string
	AnimationName            string
	AnimationDurationSeconds string
	Id                       string
}

type ModalSettings added in v0.0.9

type ModalSettings struct {
	MiddleContent templ.Component

	// OptionalFields
	Title                         string
	TitleOneWayStatePath          string
	HeaderContent                 templ.Component
	FooterContent                 templ.Component
	InitialSize                   string
	CurrentSizeTwoWayStatePath    string
	PossibleSizes                 []string
	WidthPercent                  int
	HeightPercent                 int
	MinWidthPercent               int
	MaxWidthPercent               int
	MinHeightPercent              int
	MaxHeightPercent              int
	ShouldHeightMatchContent      bool
	BackdropColor                 string
	BackgroundColor               string
	TextColor                     string
	BorderRadius                  string
	ShadowSize                    string
	RingColor                     string
	RingThickness                 string
	IsVisibleTwoWayStatePath      string
	IsUncloseable                 bool
	IsUnresizable                 bool
	IsMiddleContentScrollDisabled bool
	OnCloseFunc                   string
	OnResizeFunc                  string
}

type TagSettings

type TagSettings struct {
	// OptionalFields
	Size                           string
	TextCase                       string
	OuterRingThickness             string
	OuterRingColor                 string
	OuterBackgroundColor           string
	OuterTextColor                 string
	OuterLeftIcon                  string
	OuterLeftLabel                 string
	OuterLeftLabelOneWayStatePath  string
	OuterLeftOnClickFunc           string
	OuterRightIcon                 string
	OuterRightLabel                string
	OuterRightLabelOneWayStatePath string
	OuterRightOnClickFunc          string
	OuterRadius                    string
	OnRemoveFunc                   string
	RemoveButtonLabel              string
	InnerIcon                      string
	InnerLabel                     string
	InnerLabelOneWayStatePath      string
	InnerValueOneWayStatePath      string
	InnerBackgroundColor           string
	InnerTextColor                 string
	InnerRadius                    string
}

type ToastSettings added in v0.0.5

type ToastSettings struct {
	// OptionalFields
	BackgroundColor    string
	TextColor          string
	Size               string
	RingThickness      string
	RingColor          string
	Radius             string
	AutoDismissSeconds int
}

Jump to

Keyboard shortcuts

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