gomplements

package module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 7 Imported by: 2

README

Gomplements

GoDoc

Gomplements extends Gomponents, a collection of HTML 5 components in pure Go, by providing an Element interface and its base implementation, as well as specific Class and Styles types.

It is suggested to import Gomplements with the e (meaning "element") alias:

import e "github.com/willoma/gomplements"

Example

Simple example with Gomplements:

component := e.Div(
	Class("my-component"),
	Class("blue"),
	"Hello world",
	e.ImgSrc("http://www.example.com/example.png"),
)

The equivalent using only Gomponents:

component := h.Div(
	Class("my-component blue"),
	g.Text("Hello world"),
	h.Img(
		h.Src("http://www.example.com/example.png")
	),
)

With

The Gomplements Element allows adding children afterwards, using the With method:

component := e.Div(
	Class("my-component"),
	"Hello world",
)

component.With(Class("blue"), e.ImgSrc("http://www.example.com/example.png"))

This makes it easier to build a component while reading some data in a loop, or by adding some children conditionally.

Class and Styles

Option 1: use the Class type in order to add a single CSS class to an element:

errorColor := e.Class("red")
successColor := e.Class("green")

Option 2: use the Classes type in order to add multiple CSS classes to an element:

errorStatus := e.Classes{"red", "bold"}
successStatus := e.Classes{"green", "italic"}

Option 3: implement Classer in order to add a single CSS class to an element:

type color struct {
	success bool
}

func (c *color) Class() e.Class {
	if c.success {
		return e.Class("green")
	} else {
		return e.Class("red")
	}
}

Option 4: implement Classeser in order to add multiple CSS classes to an element:

type status struct {
	success bool
}

func (c *color) Classes() []e.Class {
	if c.success {
		return []e.Class{"green", "italic"}
	} else {
		return []e.Class{"red", "bold"}
	}
}

Option 5: define specific CSS styles with the Styles map:

e.Styles{
	"color": "red",
	"border": "1px solid blue",
}

Please note the Gomplements classes and styles do not work on traditional gomponents.Node elements, only on Gomplements' Element.

Parent modifier

Sometimes, you need to modify a parent element depending on a child. You may implement the ParentModifier interface:

type subcomponent struct {
	success bool
}

func (s *subcomponent) ModifyParent(parent e.Element) {
	parent.With(Class("has-my-subcomponent"))
	if s.success {
		parent.With(successColor)
	}
}

HTML elements

HTML elements are already provided as functions that return Element instances, which means the following are equivalent:

component := e.Elem(html.Span, e.Class("my-component"))

component := e.Span(e.Class("my-component"))

Conditional attributes

In addition to regular attributes from github.com/maragudk/gomponents/html, you may use their equivalent in e, which allow appending a boolean indicating if the attribute must be included. It helps avoiding gomponents.If, the following are equivalent:

component := e.Span(
	e.Class("my-component"),
	html.Disabled(),
	gomponents.If(condition1, html.Selected()),
	gomponents.If(condition2, html.Value("42")),
)

component := e.Span(
	e.Class("my-component"),
	e.Disabled(),
	e.Selected(condition1),
	e.Value("42", condition2),
)

If the condition is false, the attribute is not built and nil is returned.

Conditional element

If you need to add an element conditionally, you may use e.If. If its condition argument is false, the element is not built and nil is returned.

For example:

component := e.Span(
	e.Class("my-component"),
	e.If(condition3, e.Div, e.Class("my-content"), "Something"),
)

Here, e.Div is executed (built) only if condition3 is true.

However, there is a limitation: this function only works if the element builder takes only one any variadic as its argument(s). It would not work with the e.AHref helper, for example.

Conditional classes and styles

If yoyu need to add a class to an element conditionally, call the .If(bool) method on that class. If the condition is false, the class is not added to the element. This method is also available on the Classes and Styles types.

For example:

func myComponent(alert bool) e.Element {
	return e.Div(
		e.Class("my-component"),
		e.Class("alert").If(alert),
	)
}

Helpers

Gomplements also provides some helpers to simplify some common situations, for instance AHref or ImgSrc. Check out the package reference!

ARIA

Gomplements includes a collection of ARIA helpers, directly usable as children on elements in order to define ARIA roles or attributes.

For example:

component := e.Span(
	e.Class("my-component"),
	e.AriaToolbar,
	e.AriaLabel("main tools"),
)

Documentation

Index

Constants

View Source
const (
	AriaBusyTrue  ariaBusy = "true"
	AriaBusyFalse ariaBusy = "false"
)

aria-busy attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-busy

View Source
const (
	AriaLiveOff       ariaLive = "off"
	AriaLiveAssertive ariaLive = "assertive"
	AriaLivePolite    ariaLive = "polite"
)

aria-live attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-live

View Source
const (
	AriaRelevantAdditions     ariaRelevant = "additions"
	AriaRelevantAll           ariaRelevant = "all"
	AriaRelevantRemovals      ariaRelevant = "removals"
	AriaRelevantText          ariaRelevant = "text"
	AriaRelevantAdditionsText ariaRelevant = "additions text"
)

aria-relevant attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-relevant

View Source
const (
	AriaAtomicTrue  ariaAtomic = "true"
	AriaAtomicFalse ariaAtomic = "false"
)

aria-atomic attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-atomic

View Source
const (
	AriaCurrentPage     ariaCurrent = "page"
	AriaCurrentStep     ariaCurrent = "step"
	AriaCurrentLocation ariaCurrent = "location"
	AriaCurrentDate     ariaCurrent = "date"
	AriaCurrentTime     ariaCurrent = "time"
	AriaCurrentTrue     ariaCurrent = "true"
	AriaCurrentFalse    ariaCurrent = "false"
)

aria-current attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-current

View Source
const (
	AriaToolbar      ariaRole = "toolbar"
	AriaTooltip      ariaRole = "tooltip"
	AriaFeed         ariaRole = "feed"
	AriaMath         ariaRole = "math"
	AriaPresentation ariaRole = "presentation"
	AriaNone         ariaRole = "none"
	AriaNote         ariaRole = "note"
)

Document structure ARIA roles

View Source
const (
	AriaApplication  ariaRole = "application"
	AriaArticle      ariaRole = "article"
	AriaCell         ariaRole = "cell"
	AriaColumnHeader ariaRole = "columnheader"
	AriaDefinition   ariaRole = "definition"
	AriaDocument     ariaRole = "document"
	AriaFigure       ariaRole = "figure"
	AriaGroup        ariaRole = "group"
	AriaHeading      ariaRole = "heading"
	AriaImg          ariaRole = "img"
	AriaList         ariaRole = "list"
	AriaListItem     ariaRole = "listitem"
	AriaMeter        ariaRole = "meter"
	AriaRow          ariaRole = "row"
	AriaRowGroup     ariaRole = "rowgroup"
	AriaRowHeader    ariaRole = "rowheader"
	AriaTable        ariaRole = "table"
	AriaTerm         ariaRole = "term"
)

Document structure ARIA roles to avoid

View Source
const (
	AriaAssociationList          ariaRole = "associationlist"
	AriaAssociationListItemKey   ariaRole = "associationlistitemkey"
	AriaAssociationListItemValue ariaRole = "associationlistitemvalue"
	AriaBlockquote               ariaRole = "blockquote"
	AriaCaption                  ariaRole = "caption"
	AriaCode                     ariaRole = "code"
	AriaDeletion                 ariaRole = "deletion"
	AriaEmphasis                 ariaRole = "emphasis"
	AriaInsertion                ariaRole = "insertion"
	AriaParagraph                ariaRole = "paragraph"
	AriaStrong                   ariaRole = "strong"
	AriaSubscription             ariaRole = "subscript"
	AriaSuperscript              ariaRole = "superscript"
	AriaTime                     ariaRole = "time"
)

Document structure ARIA roles rarely, if ever, useful

View Source
const (
	AriaScrollbar  ariaRole = "scrollbar"
	AriaSearchbox  ariaRole = "searchbox"
	AriaSeparator  ariaRole = "separator"
	AriaSlider     ariaRole = "slider"
	AriaSpinButton ariaRole = "spinbutton"
	AriaSwitch     ariaRole = "switch"
	AriaTab        ariaRole = "tab"
	AriaTabPanel   ariaRole = "tabpanel"
	AriaTreeItem   ariaRole = "treeitem"
	AriaComboBox   ariaRole = "combobox"
	AriaMenu       ariaRole = "menu"
	AriaMenuBar    ariaRole = "menubar"
	AriaTabList    ariaRole = "tablist"
	AriaTree       ariaRole = "tree"
	AriaTreeGrid   ariaRole = "treegrid"
)

Widget ARIA roles

View Source
const (
	AriaButton           ariaRole = "button"
	AriaCheckbox         ariaRole = "checkbox"
	AriaGridCell         ariaRole = "gridcell"
	AriaLink             ariaRole = "link"
	AriaMenuItem         ariaRole = "menuitem"
	AriaMenuItemCheckbox ariaRole = "menuitemcheckbox"
	AriaMenuItemRadio    ariaRole = "menuitemradio"
	AriaOption           ariaRole = "option"
	AriaProgressbar      ariaRole = "progressbar"
	AriaRadio            ariaRole = "radio"
	AriaTextbox          ariaRole = "textbox"
	AriaGrid             ariaRole = "grid"
	AriaListbox          ariaRole = "listbox"
	AriaRadioGroup       ariaRole = "radiogroup"
)

Widget ARIA roles to avoid

View Source
const (
	AriaBanner        ariaRole = "banner"
	AriaComplementary ariaRole = "complementary"
	AriaContentInfo   ariaRole = "contentinfo"
	AriaForm          ariaRole = "form"
	AriaMain          ariaRole = "main"
	AriaNavigation    ariaRole = "navigation"
	AriaRegion        ariaRole = "region"
	AriaSearch        ariaRole = "search"
)

Landmark ARIA roles

View Source
const (
	AriaAlert   ariaRole = "alert"
	AriaLog     ariaRole = "log"
	AriaMarquee ariaRole = "marquee"
	AriaStatus  ariaRole = "status"
	AriaTimer   ariaRole = "timer"
)

Live region ARIA roles

View Source
const (
	AriaAlertDialog ariaRole = "alertdialog"
	AriaDialog      ariaRole = "dialog"
)

Window ARIA roles

View Source
const (
	AriaAutocompleteNone ariaAutocomplete = "none"
	AriaAutocompleteList ariaAutocomplete = "list"
	AriaAutocompleteBoth ariaAutocomplete = "both"
)

aria-autocomplete attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-autocomplete

View Source
const (
	AriaCheckedUndefined ariaChecked = "undefined"
	AriaCheckedTrue      ariaChecked = "true"
	AriaCheckedFalse     ariaChecked = "false"
	AriaCheckedMixed     ariaChecked = "mixed"
)

aria-checked attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked

View Source
const (
	AriaDisabledTrue  ariaDisabled = "true"
	AriaDisabledFalse ariaDisabled = "false"
)

aria-disabled attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-disabled

View Source
const (
	AriaExpandedUndefined ariaExpanded = "undefined"
	AriaExpandedTrue      ariaExpanded = "true"
	AriaExpandedFalse     ariaExpanded = "false"
)

aria-expanded attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded

View Source
const (
	AriaHasPopupTrue    ariaHasPopup = "true"
	AriaHasPopupFalse   ariaHasPopup = "false"
	AriaHasPopupMenu    ariaHasPopup = "menu"
	AriaHasPopupListbox ariaHasPopup = "listbox"
	AriaHasPopupTree    ariaHasPopup = "tree"
	AriaHasPopupGrid    ariaHasPopup = "grid"
	AriaHasPopupDialog  ariaHasPopup = "dialog"
)

aria-haspopup attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-haspopup

View Source
const (
	AriaHiddenUndefined ariaHidden = "undefined"
	AriaHiddenTrue      ariaHidden = "true"
	AriaHiddenFalse     ariaHidden = "false"
)

aria-hidden attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden

View Source
const (
	AriaInvalidTrue     ariaInvalid = "true"
	AriaInvalidFalse    ariaInvalid = "false"
	AriaInvalidGrammar  ariaInvalid = "grammar"
	AriaInvalidSpelling ariaInvalid = "spelling"
)

aria-invalid attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-invalid

View Source
const (
	AriaModalTrue  ariaModal = "true"
	AriaModalFalse ariaModal = "false"
)

aria-modal attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-modal

View Source
const (
	AdiaMultilineTrue  ariaMultiline = "true"
	AdiaMultilineFalse ariaMultiline = "false"
)

aria-multiline attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-multiline

View Source
const (
	AdiaMultiselectableTrue  ariaMultiselectable = "true"
	AdiaMultiselectableFalse ariaMultiselectable = "false"
)

aria-multiselectable attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-multiselectable

View Source
const (
	AriaOrientationUndefined  ariaOrientation = "undefined"
	AriaOrientationHorizontal ariaOrientation = "horizontal"
	AriaOrientationVertical   ariaOrientation = "vertical"
)

aria-orientation attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-orientation

View Source
const (
	AriaPressedUndefined ariaPressed = "undefined"
	AriaPressedTrue      ariaPressed = "true"
	AriaPressedFalse     ariaPressed = "false"
	AriaPressedMixed     ariaPressed = "mixed"
)

aria-pressed attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-pressed

View Source
const (
	AriaReadonlyTrue  ariaReadonly = "true"
	AriaReadonlyFalse ariaReadonly = "false"
)

aria-readonly attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-readonly

View Source
const (
	AriaRequiredTrue  ariaRequired = "true"
	AriaRequiredFalse ariaRequired = "false"
)

aria-required attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-required

View Source
const (
	AriaSelectedUndefined ariaSelected = "undefined"
	AriaSelectedTrue      ariaSelected = "true"
	AriaSelectedFalse     ariaSelected = "false"
)

aria-selected attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-selected

View Source
const (
	AriaSortNone       ariaSort = "none"
	AriaSortAscending  ariaSort = "ascending"
	AriaSortDescending ariaSort = "descending"
	AriaSortOther      ariaSort = "other"
)

aria-sort attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-sort

Variables

This section is empty.

Functions

func Accept added in v0.3.0

func Accept(value string, condition ...bool) gomponents.Node

func Action added in v0.3.0

func Action(value string, condition ...bool) gomponents.Node

func Alt added in v0.3.0

func Alt(value string, condition ...bool) gomponents.Node

func AriaControlsID

func AriaControlsID(ids ...string) ariaControlsID

aria-controls attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-controls

func AriaDetailsID

func AriaDetailsID(ids ...string) ariaDetailsID

aria-details attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-details

func AriaFlowToID

func AriaFlowToID(ids ...string) ariaFlowToID

aria-flowto attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-flowto

func AriaKeyShortcuts

func AriaKeyShortcuts(shortcuts ...string) ariaKeyShortcuts

aria-keyshortcuts attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-keyshortcuts

func AriaLabelledByID

func AriaLabelledByID(ids ...string) ariaLabelledByID

aria-labelledby attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-labelledby

func As added in v0.3.0

func As(value string, condition ...bool) gomponents.Node

func Async added in v0.3.0

func Async(condition ...bool) gomponents.Node

func AutoComplete added in v0.3.0

func AutoComplete(value string, condition ...bool) gomponents.Node

func AutoFocus added in v0.3.0

func AutoFocus(condition ...bool) gomponents.Node

func AutoPlay added in v0.3.0

func AutoPlay(condition ...bool) gomponents.Node

func Charset added in v0.3.0

func Charset(value string, condition ...bool) gomponents.Node

func Checked added in v0.3.0

func Checked(condition ...bool) gomponents.Node

func ColSpan added in v0.3.0

func ColSpan(value string, condition ...bool) gomponents.Node

func Cols added in v0.3.0

func Cols(value string, condition ...bool) gomponents.Node

func Content added in v0.3.0

func Content(value string, condition ...bool) gomponents.Node

func DataAttr added in v0.3.0

func DataAttr(name, v string, condition ...bool) gomponents.Node

func Defer added in v0.3.0

func Defer(condition ...bool) gomponents.Node

func Disabled added in v0.3.0

func Disabled(condition ...bool) gomponents.Node

func Elem

func Elem(elemFn func(...gomponents.Node) gomponents.Node, children ...any) *elem

Elem creates a base element. It takes a function that generates a gomponents.Node (these functions are found in the gomponents/html package), and optionally some children.

The children are passed as arguments to the With method.

func EncType added in v0.3.0

func EncType(value string, condition ...bool) gomponents.Node

func For added in v0.3.0

func For(value string, condition ...bool) gomponents.Node

func FormAttr added in v0.3.0

func FormAttr(value string, condition ...bool) gomponents.Node

func Height added in v0.3.0

func Height(value string, condition ...bool) gomponents.Node

func Href added in v0.3.0

func Href(value string, condition ...bool) gomponents.Node

func IsAttribute

func IsAttribute(node any) bool

IsAttribute returns true if the provided node is an attribute according to its gomponents.NodeType.

func Lang added in v0.3.0

func Lang(value string, condition ...bool) gomponents.Node

func Loading added in v0.3.0

func Loading(value string, condition ...bool) gomponents.Node

func Loop added in v0.3.0

func Loop(condition ...bool) gomponents.Node

func Max added in v0.3.0

func Max(value string, condition ...bool) gomponents.Node

func MaxLength added in v0.3.0

func MaxLength(value string, condition ...bool) gomponents.Node

func Method added in v0.3.0

func Method(value string, condition ...bool) gomponents.Node

func Min added in v0.3.0

func Min(value string, condition ...bool) gomponents.Node

func MinLength added in v0.3.0

func MinLength(value string, condition ...bool) gomponents.Node

func Multiple added in v0.3.0

func Multiple(condition ...bool) gomponents.Node

func Muted added in v0.3.0

func Muted(condition ...bool) gomponents.Node

func Name added in v0.3.0

func Name(value string, condition ...bool) gomponents.Node

func On

func On(event, script string) gomponents.Node

On adds a "on<event>" attribute to an element.

func OnClick

func OnClick(script string) gomponents.Node

OnClick adds a "onclick" attribute to an element.

func Pattern added in v0.3.0

func Pattern(value string, condition ...bool) gomponents.Node

func Placeholder added in v0.3.0

func Placeholder(value string, condition ...bool) gomponents.Node

func PlaysInline added in v0.3.0

func PlaysInline(condition ...bool) gomponents.Node

func Poster added in v0.3.0

func Poster(value string, condition ...bool) gomponents.Node

func Preload added in v0.3.0

func Preload(value string, condition ...bool) gomponents.Node

func Prepare

func Prepare(e Element) gomponents.Node

Prepare pre-renders a node in memory for future uses.

func ReadOnly added in v0.3.0

func ReadOnly(condition ...bool) gomponents.Node

func Rel added in v0.3.0

func Rel(value string, condition ...bool) gomponents.Node

func Required added in v0.3.0

func Required(condition ...bool) gomponents.Node

func RowSpan added in v0.3.0

func RowSpan(value string, condition ...bool) gomponents.Node

func Rows added in v0.3.0

func Rows(value string, condition ...bool) gomponents.Node

func Selected added in v0.3.0

func Selected(condition ...bool) gomponents.Node

func Src added in v0.3.0

func Src(value string, condition ...bool) gomponents.Node

func SrcSet added in v0.3.0

func SrcSet(value string, condition ...bool) gomponents.Node

func Step added in v0.3.0

func Step(value string, condition ...bool) gomponents.Node

func TabIndex added in v0.3.0

func TabIndex(value string, condition ...bool) gomponents.Node

func Target added in v0.3.0

func Target(value string, condition ...bool) gomponents.Node

func TitleAttr added in v0.3.0

func TitleAttr(value string, condition ...bool) gomponents.Node

func Type added in v0.3.0

func Type(value string, condition ...bool) gomponents.Node

func Value added in v0.3.0

func Value(value string, condition ...bool) gomponents.Node

func Width added in v0.3.0

func Width(value string, condition ...bool) gomponents.Node

Types

type AriaActiveDescendantID

type AriaActiveDescendantID string

aria-activedescendant attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-activedescendant

func (AriaActiveDescendantID) ModifyParent

func (a AriaActiveDescendantID) ModifyParent(p Element)

type AriaBrailleLabel

type AriaBrailleLabel string

aria-braillelabel attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-braillelabel

func (AriaBrailleLabel) ModifyParent

func (a AriaBrailleLabel) ModifyParent(p Element)

type AriaBrailleRoleDescription

type AriaBrailleRoleDescription string

aria-brailleroledescription attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-brailleroledescription

func (AriaBrailleRoleDescription) ModifyParent

func (a AriaBrailleRoleDescription) ModifyParent(p Element)

type AriaColCount

type AriaColCount int

aria-colcount attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-colcount

func (AriaColCount) ModifyParent

func (a AriaColCount) ModifyParent(p Element)

type AriaColIndex

type AriaColIndex int

aria-colindex attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-colindex

func (AriaColIndex) ModifyParent

func (a AriaColIndex) ModifyParent(p Element)

type AriaColIndexText

type AriaColIndexText string

aria-colindextext attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-colindextext

func (AriaColIndexText) ModifyParent

func (a AriaColIndexText) ModifyParent(p Element)

type AriaColSpan

type AriaColSpan int

aria-colspan attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-colspan

func (AriaColSpan) ModifyParent

func (a AriaColSpan) ModifyParent(p Element)

type AriaDescribedBy

type AriaDescribedBy string

aria-describedby attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby

func (AriaDescribedBy) ModifyParent

func (a AriaDescribedBy) ModifyParent(p Element)

type AriaDescription

type AriaDescription string

aria-description attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-description

func (AriaDescription) ModifyParent

func (a AriaDescription) ModifyParent(p Element)

type AriaErrorMessageID

type AriaErrorMessageID string

aria-errormessage attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-errormessage

func (AriaErrorMessageID) ModifyParent

func (a AriaErrorMessageID) ModifyParent(p Element)

type AriaLabel

type AriaLabel string

aria-label attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label

func (AriaLabel) ModifyParent

func (a AriaLabel) ModifyParent(p Element)

type AriaLevel

type AriaLevel int

aria-level attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-level

func (AriaLevel) ModifyParent

func (a AriaLevel) ModifyParent(p Element)

type AriaPlaceholder

type AriaPlaceholder string

aria-placeholder attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-placeholder

func (AriaPlaceholder) ModifyParent

func (a AriaPlaceholder) ModifyParent(p Element)

type AriaPosInSet

type AriaPosInSet int

aria-posinset attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-posinset

func (AriaPosInSet) ModifyParent

func (a AriaPosInSet) ModifyParent(p Element)

type AriaRoleDescription

type AriaRoleDescription string

aria-roledescription attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-roledescription

func (AriaRoleDescription) ModifyParent

func (a AriaRoleDescription) ModifyParent(p Element)

type AriaRowIndexText

type AriaRowIndexText string

aria-rowindextext attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-rowindextext

func (AriaRowIndexText) ModifyParent

func (a AriaRowIndexText) ModifyParent(p Element)

type AriaValueMax

type AriaValueMax float64

aria-valuemax attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-valuemax

func (AriaValueMax) ModifyParent

func (a AriaValueMax) ModifyParent(p Element)

type AriaValueMin

type AriaValueMin float64

aria-valuemin attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-valuemin

func (AriaValueMin) ModifyParent

func (a AriaValueMin) ModifyParent(p Element)

type AriaValueNow

type AriaValueNow float64

aria-valuenow attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-valuenow

func (AriaValueNow) ModifyParent

func (a AriaValueNow) ModifyParent(p Element)

type AriaValueText

type AriaValueText string

aria-valuetext attribute https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-valuetext

func (AriaValueText) ModifyParent

func (a AriaValueText) ModifyParent(p Element)

type Class

type Class string

Class represents a CSS class, which is applied in the class attribute of a Element.

func (Class) If added in v0.5.0

func (c Class) If(condition bool) Class

If allows to add a CSS class to an Element, only if a condition is met.

type Classer

type Classer interface {
	Class() Class
}

Classer is an interface that allows to add a CSS class to an HTML element.

type Classes

type Classes []Class

Classes contains multiple CSS classes to be applied in the class attribute of an Element.

func (Classes) Classes

func (c Classes) Classes() []Class

Classes implements Classeser.

func (Classes) If added in v0.5.0

func (c Classes) If(cond bool) Classes

If allows to add multiple CSS classes to an Element, only if a condition is met.

type Classeser

type Classeser interface {
	Classes() []Class
}

Classeser is an interface that allows to add multiple CSS classes to an HTML element.

type Element

type Element interface {
	gomponents.Node

	// With adds childs to the element.
	With(...any) Element

	// Clone returns an independent cloned element.
	Clone() Element
}

Element is an element, which implements the gomponents.Node interface with

func A

func A(children ...any) Element

func AHref

func AHref(href string, children ...any) Element

AHref creates an <a> element with the provided href.

func Abbr

func Abbr(children ...any) Element

func Address

func Address(children ...any) Element

func Area

func Area(children ...any) Element

func Article

func Article(children ...any) Element

func Aside

func Aside(children ...any) Element

func Audio

func Audio(children ...any) Element

func B

func B(children ...any) Element

func Base

func Base(children ...any) Element

func BlockQuote

func BlockQuote(children ...any) Element

func Body

func Body(children ...any) Element

func Br

func Br(children ...any) Element

func Button

func Button(children ...any) Element

func Canvas

func Canvas(children ...any) Element

func Caption

func Caption(children ...any) Element

func Cite

func Cite(children ...any) Element

func Code

func Code(children ...any) Element

func Col

func Col(children ...any) Element

func ColGroup

func ColGroup(children ...any) Element

func Data

func Data(children ...any) Element

func DataList

func DataList(children ...any) Element

func Dd

func Dd(children ...any) Element

func Del

func Del(children ...any) Element

func Details

func Details(children ...any) Element

func Dfn

func Dfn(children ...any) Element

func Dialog

func Dialog(children ...any) Element

func Div

func Div(children ...any) Element

func Dl

func Dl(children ...any) Element

func Dt

func Dt(children ...any) Element

func Em

func Em(children ...any) Element

func Embed

func Embed(children ...any) Element

func FieldSet

func FieldSet(children ...any) Element

func FigCaption

func FigCaption(children ...any) Element

func Figure

func Figure(children ...any) Element
func Footer(children ...any) Element

func Form

func Form(children ...any) Element

func H1

func H1(children ...any) Element

func H2

func H2(children ...any) Element

func H3

func H3(children ...any) Element

func H4

func H4(children ...any) Element

func H5

func H5(children ...any) Element

func H6

func H6(children ...any) Element

func HGroup

func HGroup(children ...any) Element

func HTML

func HTML(children ...any) Element
func Head(children ...any) Element
func Header(children ...any) Element

func Hr

func Hr(children ...any) Element

func I

func I(children ...any) Element

func IFrame

func IFrame(children ...any) Element

func If added in v0.4.0

func If(condition bool, builder ElementBuilder, children ...any) Element

If builds the provided element with the provided children, only if the condition is true.

If condition is false, the element is not built and nil is returned.

func Img

func Img(children ...any) Element

func ImgSrc

func ImgSrc(src string, children ...any) Element

ImgSrc creates a <img> element, with the provided src.

func Input

func Input(children ...any) Element

func Kbd

func Kbd(children ...any) Element

func Label

func Label(children ...any) Element

func Legend

func Legend(children ...any) Element

func Li

func Li(children ...any) Element
func Link(children ...any) Element

func Main

func Main(children ...any) Element

func Mark

func Mark(children ...any) Element
func Menu(children ...any) Element

func Meta

func Meta(children ...any) Element

func Meter

func Meter(children ...any) Element
func Nav(children ...any) Element

func NoScript

func NoScript(children ...any) Element

func Object

func Object(children ...any) Element

func Ol

func Ol(children ...any) Element

func OptGroup

func OptGroup(children ...any) Element

func Option

func Option(children ...any) Element

func P

func P(children ...any) Element

func Param

func Param(children ...any) Element

func Picture

func Picture(children ...any) Element

func Pre

func Pre(children ...any) Element

func Progress

func Progress(children ...any) Element

func Q

func Q(children ...any) Element

func S

func S(children ...any) Element

func SVG

func SVG(children ...any) Element

func Samp

func Samp(children ...any) Element

func Script

func Script(children ...any) Element

func Section

func Section(children ...any) Element

func Select

func Select(children ...any) Element

func Small

func Small(children ...any) Element

func Source

func Source(children ...any) Element

func Span

func Span(children ...any) Element

func Strong

func Strong(children ...any) Element

func Style

func Style(children ...any) Element

func Sub

func Sub(children ...any) Element

func Summary

func Summary(children ...any) Element

func Sup

func Sup(children ...any) Element

func TBody

func TBody(children ...any) Element

func TFoot

func TFoot(children ...any) Element

func THead

func THead(children ...any) Element

func Table

func Table(children ...any) Element

func Td

func Td(children ...any) Element

func Textarea

func Textarea(children ...any) Element

func Th

func Th(children ...any) Element

func Time

func Time(children ...any) Element

func Title

func Title(children ...any) Element

func Tr

func Tr(children ...any) Element

func U

func U(children ...any) Element

func Ul

func Ul(children ...any) Element

func Var

func Var(children ...any) Element

func Video

func Video(children ...any) Element

func Wbr

func Wbr(children ...any) Element

type ElementBuilder added in v0.4.0

type ElementBuilder func(...any) Element

type ID

type ID string

ID adds an "id" attribute to an element.

It is useful for some components which need to know that an argument is an ID in order to apply it to the correct element.

type ParentModifier

type ParentModifier interface {
	ModifyParent(parent Element)
}

ParentModifier is an interface for modifying the parent of an element.

type ParentModifierAndNode

type ParentModifierAndNode interface {
	gomponents.Node
	ParentModifier
}

ParentModifierAndNode is an interface for modifying the parent of an element and adding a child.

type Styles

type Styles map[string]string

Styles allows to define CSS styles to apply to an Element.

func (Styles) If added in v0.6.0

func (s Styles) If(cond bool) Styles

If allows to apply CSS styles to an Element, only if a condition is met.

Jump to

Keyboard shortcuts

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