Skip to content

Fragments

Fragments group multiple sibling nodes without adding an HTML wrapper.

Multiple roots

Write a fragment as <>…</>. Its children render in order with no surrounding tag.

gsx
package views

component Pair(a string, b string) {
	<><span>{ a }</span><span>{ b }</span></>
}

Renders:

html
<span>x</span><span>y</span>

▶ Open in Playground

Use a fragment whenever one markup value needs multiple roots. Fragments do not accept attributes because they have no element of their own.