details

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: 22 Imported by: 0

Documentation

Overview

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

The <details> HTML element creates a disclosure widget in which information is visible only when the widget is toggled into an open state. A summary or label must be provided using the <summary> element.

Index

Constants

This section is empty.

Variables

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

	AttrOpen = []byte(" open")
	AttrName = []byte(" name=\"")
)

Byte constants for HTML rendering.

Functions

func Group added in v0.3.0

func Group(name string, nodes ...node.Node) *element

Group creates a details element in a named accordion group. Only one details element with the same name can be open at a time, providing native accordion behaviour without JavaScript. Example: details.Group("faq", summary.Text("Question 1"), p.Text("Answer 1")) Renders: <details name="faq"><summary>Question 1</summary><p>Answer 1</p></details>

func New

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

New creates a new details element with the given child nodes. Example: details.New(summary.Text("Details"), p.Text("Hidden content")) Renders: <details><summary>Details</summary><p>Hidden content</p></details>

func RawText added in v0.3.0

func RawText(content string) *element

RawText creates a new details element with raw text content. Uses text.RawText which is not HTML-escaped. Example: details.RawText("<p>Disclosure content</p>") Renders: <details><p>Disclosure content</p></details>

func RawTextf added in v0.3.0

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

RawTextf creates a new details element with formatted raw text content. Uses text.RawTextf which is not HTML-escaped. Example: details.RawTextf("<p>Section %d</p>", 1) Renders: <details><p>Section 1</p></details>

func Static added in v0.3.0

func Static(content string) *element

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

func Summary added in v0.3.0

func Summary(label string, nodes ...node.Node) *element

Summary creates a details element with a summary label and content. The summary is displayed as the clickable heading; the remaining nodes are revealed when the widget is opened. Example: details.Summary("More info", p.Text("Details here")) Renders: <details><summary>More info</summary><p>Details here</p></details>

func Text added in v0.3.0

func Text(content string) *element

Text creates a new details element with text content. Uses text.Text which HTML-escapes the output. Example: details.Text("Disclosure content") Renders: <details>Disclosure content</details>

func Textf added in v0.3.0

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

Textf creates a new details element with formatted text content. Uses text.Textf which HTML-escapes the output. Example: details.Textf("Section %d", 1) Renders: <details>Section 1</details>

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