Skip to content
Gx
GitHub

Docs

The Gx docs kit: callouts, tabs, steps, cards, badges, file trees, icons, hero and code blocks.

<docs.Aside kind={docs.Note} title="Note">A note.</docs.Aside>

Installation

Run the command in the app module.

Terminal
gx add docs

The command writes these files.

File Path in the app
Aside.fixtures.go ui/docs/Aside.fixtures.go
Aside.gx ui/docs/Aside.gx
Badge.fixtures.go ui/docs/Badge.fixtures.go
Badge.gx ui/docs/Badge.gx
Card.fixtures.go ui/docs/Card.fixtures.go
Card.gx ui/docs/Card.gx
CardGrid.fixtures.go ui/docs/CardGrid.fixtures.go
CardGrid.gx ui/docs/CardGrid.gx
Code.fixtures.go ui/docs/Code.fixtures.go
Code.gx ui/docs/Code.gx
FileTree.fixtures.go ui/docs/FileTree.fixtures.go
FileTree.gx ui/docs/FileTree.gx
FileTreeItemRow.fixtures.go ui/docs/FileTreeItemRow.fixtures.go
FileTreeItemRow.gx ui/docs/FileTreeItemRow.gx
Hero.fixtures.go ui/docs/Hero.fixtures.go
Hero.gx ui/docs/Hero.gx
Icon.fixtures.go ui/docs/Icon.fixtures.go
Icon.gx ui/docs/Icon.gx
LLMSkip.fixtures.go ui/docs/LLMSkip.fixtures.go
LLMSkip.gx ui/docs/LLMSkip.gx
LinkButton.fixtures.go ui/docs/LinkButton.fixtures.go
LinkButton.gx ui/docs/LinkButton.gx
LinkCard.fixtures.go ui/docs/LinkCard.fixtures.go
LinkCard.gx ui/docs/LinkCard.gx
Steps.fixtures.go ui/docs/Steps.fixtures.go
Steps.gx ui/docs/Steps.gx
TabItem.fixtures.go ui/docs/TabItem.fixtures.go
TabItem.gx ui/docs/TabItem.gx
Tabs.fixtures.go ui/docs/Tabs.fixtures.go
Tabs.gx ui/docs/Tabs.gx
aside.go ui/docs/aside.go
badge.go ui/docs/badge.go
filetree.go ui/docs/filetree.go
linkbutton.go ui/docs/linkbutton.go

Copy each file to its path in the app. Change each import of a registry package to the path of that package in the app.

ui/docs/Aside.fixtures.go
package docs

import "github.com/alternayte/gx"

var AsideFixtures = gx.Fixtures[AsideProps]{
	"Note":    {Kind: Note, Title: "Note", Children: gx.Text("A note.")},
	"Tip":     {Kind: Tip, Children: gx.Text("A tip.")},
	"Caution": {Kind: Caution, Children: gx.Text("Careful.")},
	"Danger":  {Kind: Danger, Title: "Danger", Children: gx.Text("Stop.")},
}
ui/docs/Aside.gx
package docs

props {
  // Kind sets the tone of the callout: Note, Tip, Caution or Danger.
  Kind     Kind = Note
  // Title is the heading of the callout. Empty omits it.
  Title    string = ""
  // Children is the content of the callout.
  Children gx.Node
  // Attrs adds HTML attributes to the root element.
  Attrs    gx.Attrs = nil
}

<aside class={gx.Cx("gx-aside my-4 rounded-lg border border-border bg-muted/40 p-4 text-sm", kindClass[p.Kind])} {...p.Attrs}>
  if p.Title != "" {
    <p class="gx-aside-title m-0 mb-1 font-semibold">{p.Title}</p>
  }
  <div class="gx-aside-body [&>p:first-child]:mt-0 [&>p:last-child]:mb-0">{p.Children}</div>
</aside>
ui/docs/Badge.fixtures.go
package docs

import "github.com/alternayte/gx"

var BadgeFixtures = gx.Fixtures[BadgeProps]{
	"Default":     {Label: "Default"},
	"Secondary":   {Label: "Secondary", Variant: BadgeSecondary},
	"Destructive": {Label: "Destructive", Variant: BadgeDestructive},
	"Outline":     {Label: "Outline", Variant: BadgeOutline},
}
ui/docs/Badge.gx
package docs

props {
  // Label is the text of the badge.
  Label   string
  // Variant sets the visual style: BadgeDefault, BadgeSecondary, BadgeDestructive or
  // BadgeOutline.
  Variant BadgeVariant = BadgeDefault
  // Attrs adds HTML attributes to the root element.
  Attrs   gx.Attrs = nil
}

<span class={gx.Cx("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-medium", badgeClass[p.Variant])} {...p.Attrs}>{p.Label}</span>
ui/docs/Card.fixtures.go
package docs

import "github.com/alternayte/gx"

var CardFixtures = gx.Fixtures[CardProps]{
	"TitleAndBody": {Title: "Card", Description: "A short description.", Children: gx.Text("Body text.")},
	"BodyOnly":     {Children: gx.Text("Body only.")},
	"TitleOnly":    {Title: "Title only"},
}
ui/docs/Card.gx
package docs

props {
  // Title is the heading of the card. Empty omits it.
  Title       string = ""
  // Description is the text below the title. Empty omits it.
  Description string = ""
  // Children is the content of the card. Nil omits the body.
  Children    gx.Node = nil
  // Attrs adds HTML attributes to the root element.
  Attrs       gx.Attrs = nil
}

<div class="gx-card my-4 rounded-xl border border-border bg-card p-6 text-card-foreground shadow-sm" {...p.Attrs}>
  if p.Title != "" {
    <h3 class="m-0 text-base font-semibold leading-none tracking-tight">{p.Title}</h3>
  }
  if p.Description != "" {
    <p class="m-0 mt-1.5 text-sm text-muted-foreground">{p.Description}</p>
  }
  if p.Children != nil {
    <div class="gx-card-body mt-4">{p.Children}</div>
  }
</div>
ui/docs/CardGrid.fixtures.go
package docs

import "github.com/alternayte/gx"

var CardGridFixtures = gx.Fixtures[CardGridProps]{
	"Two": {Children: gx.Frag(
		Card(CardProps{Title: "One", Children: gx.Text("First.")}),
		Card(CardProps{Title: "Two", Children: gx.Text("Second.")}),
	)},
}
ui/docs/CardGrid.gx
package docs

props {
  // Children is the cards of the grid.
  Children gx.Node
  // Attrs adds HTML attributes to the root element.
  Attrs    gx.Attrs = nil
}

<div class="gx-card-grid my-4 grid gap-4 sm:grid-cols-2" {...p.Attrs}>{p.Children}</div>
ui/docs/Code.fixtures.go
package docs

import "github.com/alternayte/gx"

// The fixtures show go.mod, a file every app has: the example code names it
// with gx.CodeFile.
var CodeFixtures = gx.Fixtures[CodeProps]{
	"Go":     {Code: gx.Code{File: "go.mod", Lang: "go", Source: "module app\n\ngo 1.25.0\n"}, Title: "go.mod"},
	"Marked": {Code: gx.Code{File: "go.mod", Lang: "go", Source: "module app\n\ngo 1.25.0\n"}, Marks: []int{1}},
}
ui/docs/Code.gx
package docs

import "github.com/alternayte/gx"
import "github.com/alternayte/gx/content"

props {
  // Code is the source to show. The compiler fills it at build time from a repository file.
  Code  gx.Code
  // Title is the text in the frame bar.
  Title string = ""
  // Wrap wraps long lines.
  Wrap  bool = false
  // Marks holds the 1-based numbers of the lines to highlight.
  Marks []int = nil
  // Ins holds the 1-based numbers of the lines to mark as inserted.
  Ins   []int = nil
  // Del holds the 1-based numbers of the lines to mark as deleted.
  Del   []int = nil
  // Words holds the 1-based numbers of the lines to outline.
  Words []int = nil
}

{content.Code(p.Code, content.CodeOptions{Title: p.Title, Wrap: p.Wrap, Marks: p.Marks, Ins: p.Ins, Del: p.Del, Words: p.Words})}
ui/docs/FileTree.fixtures.go
package docs

import "github.com/alternayte/gx"

var FileTreeFixtures = gx.Fixtures[FileTreeProps]{
	"Tree": {Items: []FileTreeItem{
		{Name: "app", Dir: true, Children: []FileTreeItem{
			{Name: "main.go", Comment: "the app entry"},
			{Name: "theme.css"},
		}},
		{Name: "go.mod"},
	}},
}
ui/docs/FileTree.gx
package docs

props {
  // Items holds the top-level files and directories of the tree.
  Items []FileTreeItem
  // Attrs adds HTML attributes to the root element.
  Attrs gx.Attrs = nil
}

<ul class="gx-file-tree my-4 list-none space-y-1 p-0 text-sm" {...p.Attrs}>
  for _, it := range p.Items {
    <FileTreeItemRow item={it} />
  }
</ul>
ui/docs/FileTreeItemRow.fixtures.go
package docs

import "github.com/alternayte/gx"

var FileTreeItemRowFixtures = gx.Fixtures[FileTreeItemRowProps]{
	"File": {Item: FileTreeItem{Name: "main.go", Comment: "entry"}},
	"Dir": {Item: FileTreeItem{Name: "app", Dir: true, Children: []FileTreeItem{
		{Name: "main.go"},
	}}},
}
ui/docs/FileTreeItemRow.gx
package docs

props {
  // Item is the file or directory of the row. Its children show as a nested list.
  Item FileTreeItem
}

<li class="gx-file-tree-item">
  <span class="flex items-center gap-2">
    if p.Item.Dir {
      <span class="font-medium text-foreground">{p.Item.Name}/</span>
    } else {
      <span>{p.Item.Name}</span>
    }
    if p.Item.Comment != "" {
      <span class="text-muted-foreground">{p.Item.Comment}</span>
    }
  </span>
  if len(p.Item.Children) > 0 {
    <ul class="mt-1 list-none space-y-1 border-l border-border p-0 pl-4">
      for _, child := range p.Item.Children {
        <FileTreeItemRow item={child} />
      }
    </ul>
  }
</li>
ui/docs/Hero.fixtures.go
package docs

import "github.com/alternayte/gx"

var HeroFixtures = gx.Fixtures[HeroProps]{
	"Full":  {Title: "Gx", Tagline: "Server-rendered Go web apps.", Actions: gx.Raw(gx.SafeHTML(`<a href="/start">Get started</a>`))}, //gx:trusted a fixture is repository source (SI-12)
	"Title": {Title: "Title only"},
}
ui/docs/Hero.gx
package docs

props {
  // Title is the heading of the hero.
  Title    string
  // Tagline is the text below the title. Empty omits it.
  Tagline  string = ""
  // Actions is the row of links or buttons below the tagline. Nil omits it.
  Actions  gx.Node = nil
  // Children is the content below the actions. Nil omits it.
  Children gx.Node = nil
  // Attrs adds HTML attributes to the root element.
  Attrs    gx.Attrs = nil
}

<header class="gx-hero my-8 text-center" {...p.Attrs}>
  <h1 class="m-0 text-4xl font-bold tracking-tight">{p.Title}</h1>
  if p.Tagline != "" {
    <p class="mx-auto mt-3 max-w-2xl text-lg text-muted-foreground">{p.Tagline}</p>
  }
  if p.Actions != nil {
    <div class="mt-6 flex flex-wrap items-center justify-center gap-3">{p.Actions}</div>
  }
  if p.Children != nil {
    <div class="gx-hero-body mt-8">{p.Children}</div>
  }
</header>
ui/docs/Icon.fixtures.go
package docs

import "github.com/alternayte/gx"

var IconFixtures = gx.Fixtures[IconProps]{
	"Decorative": {Body: gx.SafeHTML(`<path d="M4 12h16" />`)},
	"Labelled":   {Body: gx.SafeHTML(`<path d="M4 12h16" />`), Label: "A dash"},
}
ui/docs/Icon.gx
package docs

props {
  // Body is the inner markup of the svg, from a pinned icon pack.
  Body  gx.SafeHTML
  // Label is the accessible name of the icon.
  // Empty hides the icon from assistive technology.
  Label string = ""
  // Class adds classes to the root element.
  Class string = ""
}

{gx.Icon(string(p.Body), gx.IconProps{Label: p.Label, Class: gx.Cx("inline-block size-5", p.Class)})}
ui/docs/LLMSkip.fixtures.go
package docs

import "github.com/alternayte/gx"

var LLMSkipFixtures = gx.Fixtures[LLMSkipProps]{
	"Default": {Children: gx.Text("Only for the page.")},
}
ui/docs/LLMSkip.gx
package docs

props {
  // Children is the content of the block. The component renders nothing; the block marks
  // Markdown that stays out of llms.txt.
  Children gx.Node = nil
}
ui/docs/LinkButton.fixtures.go
package docs

import "github.com/alternayte/gx"

var LinkButtonFixtures = gx.Fixtures[LinkButtonProps]{
	"Primary":   {Href: gx.URL("/start"), Children: gx.Text("Get started")},
	"Secondary": {Href: gx.URL("/start"), Variant: ButtonSecondary, Children: gx.Text("Secondary")},
	"Outline":   {Href: gx.URL("/start"), Variant: ButtonOutline, Children: gx.Text("Outline")},
	"Ghost":     {Href: gx.URL("/start"), Variant: ButtonGhost, Children: gx.Text("Ghost")},
}
ui/docs/LinkButton.gx
package docs

props {
  // Href is the link target.
  Href     gx.URL
  // Variant sets the visual style: ButtonPrimary, ButtonSecondary, ButtonOutline or
  // ButtonGhost.
  Variant  ButtonVariant = ButtonPrimary
  // Children is the button label.
  Children gx.Node
  // Attrs adds HTML attributes to the root element.
  Attrs    gx.Attrs = nil
}

<a href={p.Href} class={gx.Cx("gx-link-button my-2 inline-flex items-center rounded-md px-4 py-2 text-sm font-medium no-underline", buttonClass[p.Variant])} {...p.Attrs}>{p.Children}</a>
ui/docs/LinkCard.fixtures.go
package docs

import "github.com/alternayte/gx"

var LinkCardFixtures = gx.Fixtures[LinkCardProps]{
	"Full":  {Href: gx.URL("/errors/GX1000"), Title: "Diagnostics", Description: "Every code has a page.", Children: gx.Text("Read on.")},
	"Short": {Href: gx.URL("/start"), Title: "Start"},
}
ui/docs/LinkCard.gx
package docs

props {
  // Href is the link target.
  Href        gx.URL
  // Title is the heading of the card.
  Title       string
  // Description is the text below the title. Empty omits it.
  Description string = ""
  // Children is the content below the description. Nil omits it.
  Children    gx.Node = nil
  // Attrs adds HTML attributes to the root element.
  Attrs       gx.Attrs = nil
}

<a href={p.Href} class="gx-link-card my-4 block rounded-lg border border-border p-4 no-underline transition-colors hover:bg-accent" {...p.Attrs}>
  <span class="block font-medium text-foreground">{p.Title}</span>
  if p.Description != "" {
    <span class="mt-1 block text-sm text-muted-foreground">{p.Description}</span>
  }
  if p.Children != nil {
    <span class="gx-link-card-body mt-2 block text-sm">{p.Children}</span>
  }
</a>
ui/docs/Steps.fixtures.go
package docs

import "github.com/alternayte/gx"

var StepsFixtures = gx.Fixtures[StepsProps]{
	"Three": {Children: gx.Raw(gx.SafeHTML(`<ol><li>First</li><li>Second</li><li>Third</li></ol>`))}, //gx:trusted a fixture is repository source (SI-12)
}
ui/docs/Steps.gx
package docs

props {
  // Children is the ordered list of steps.
  Children gx.Node
  // Attrs adds HTML attributes to the root element.
  Attrs    gx.Attrs = nil
}

<div class="gx-steps my-4 [&>ol]:m-0 [&>ol]:list-none [&>ol]:space-y-4 [&>ol]:p-0 [&>ol>li]:border-l-2 [&>ol>li]:border-border [&>ol>li]:pl-4" {...p.Attrs}>{p.Children}</div>
ui/docs/TabItem.fixtures.go
package docs

import "github.com/alternayte/gx"

var TabItemFixtures = gx.Fixtures[TabItemProps]{
	"Text": {Label: "Tab", Children: gx.Text("Panel body.")},
}
ui/docs/TabItem.gx
package docs

props {
  // Label is the text of the tab button. It must be unique inside one tab group.
  Label    string
  // Children is the content of the tab panel.
  Children gx.Node
  // Attrs adds HTML attributes to the root element.
  Attrs    gx.Attrs = nil
}

<div class="gx-tab" data-gx-tab-item {...p.Attrs}>
  <button type="button" class="gx-tab-button -mb-px border-b-2 border-transparent px-3 py-1.5 text-sm font-medium text-muted-foreground hover:text-foreground data-[selected=true]:border-foreground data-[selected=true]:text-foreground" data-gx-tab={p.Label} aria-expanded="false">{p.Label}</button>
  <div class="gx-tab-panel pt-4" data-gx-tab-panel>{p.Children}</div>
</div>
ui/docs/Tabs.fixtures.go
package docs

import "github.com/alternayte/gx"

var TabsFixtures = gx.Fixtures[TabsProps]{
	"Two": {Children: gx.Frag(
		TabItem(TabItemProps{Label: "Postgres", Children: gx.Text("Postgres body.")}),
		TabItem(TabItemProps{Label: "SQL Server", Children: gx.Text("SQL Server body.")}),
	)},
	"Synced": {Sync: "db", Children: gx.Frag(
		TabItem(TabItemProps{Label: "Option A", Children: gx.Text("A.")}),
		TabItem(TabItemProps{Label: "Option B", Children: gx.Text("B.")}),
	)},
}
ui/docs/Tabs.gx
package docs

props {
  // Sync is the key that links tab groups. Groups with the same key switch together and
  // remember the chosen tab.
  Sync     string = ""
  // Default is the label of the tab that starts open. Empty opens the first tab.
  Default  string = ""
  // Children is the tab items.
  Children gx.Node
  // Attrs adds HTML attributes to the root element.
  Attrs    gx.Attrs = nil
}

<div class="gx-tabs my-4" data-gx-tabs data-sync={p.Sync} data-default={p.Default} {...p.Attrs}>{p.Children}</div>
ui/docs/aside.go
package docs

import "github.com/alternayte/gx"

// kindClass maps a callout tone to its accent classes (REQ-STY-05).
var kindClass = gx.Enum[Kind]{
	Note:    "",
	Tip:     "gx-aside-tip",
	Caution: "gx-aside-caution",
	Danger:  "gx-aside-danger",
}

// Kind is the tone of a docs callout (REQ-CNT-05).
type Kind string

// The tones of docs.Aside.
const (
	Note    Kind = "note"
	Tip     Kind = "tip"
	Caution Kind = "caution"
	Danger  Kind = "danger"
)
ui/docs/badge.go
package docs

import "github.com/alternayte/gx"

// badgeClass maps a badge variant to its classes (REQ-STY-05).
var badgeClass = gx.Enum[BadgeVariant]{
	BadgeDefault:     "border-transparent bg-primary text-primary-foreground",
	BadgeSecondary:   "border-transparent bg-secondary text-secondary-foreground",
	BadgeDestructive: "border-transparent bg-destructive text-white",
	BadgeOutline:     "text-foreground",
}

// BadgeVariant is the visual style of a docs badge (REQ-CNT-05).
type BadgeVariant string

// The variants of docs.Badge.
const (
	BadgeDefault     BadgeVariant = "default"
	BadgeSecondary   BadgeVariant = "secondary"
	BadgeDestructive BadgeVariant = "destructive"
	BadgeOutline     BadgeVariant = "outline"
)
ui/docs/filetree.go
package docs

// FileTreeItem is one file or directory of docs.FileTree (REQ-CNT-05).
type FileTreeItem struct {
	// Name is the shown base name.
	Name string
	// Dir marks a directory.
	Dir bool
	// Comment adds a short note after the name.
	Comment string
	// Children holds the directory entries.
	Children []FileTreeItem
}
ui/docs/linkbutton.go
package docs

import "github.com/alternayte/gx"

// buttonClass maps a link-button variant to its classes (REQ-STY-05).
var buttonClass = gx.Enum[ButtonVariant]{
	ButtonPrimary:   "bg-primary text-primary-foreground hover:bg-primary/90",
	ButtonSecondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
	ButtonOutline:   "border border-border bg-transparent hover:bg-accent",
	ButtonGhost:     "bg-transparent hover:bg-accent",
}

// ButtonVariant is the visual style of a docs link button (REQ-CNT-05).
type ButtonVariant string

// The variants of docs.LinkButton.
const (
	ButtonPrimary   ButtonVariant = "primary"
	ButtonSecondary ButtonVariant = "secondary"
	ButtonOutline   ButtonVariant = "outline"
	ButtonGhost     ButtonVariant = "ghost"
)

The theme must define these tokens: --background, --foreground, --primary, --primary-foreground, --secondary, --secondary-foreground, --muted, --muted-foreground, --accent, --border, --card, --destructive.

Usage

The Gx docs kit. Copy it into an app and render documentation pages with typed components.

var Docs = gx.Collection[DocMeta]("content/docs").Components(
    docs.Aside, docs.Tabs, docs.TabItem, docs.Steps, docs.Card, docs.CardGrid,
    docs.LinkCard, docs.LinkButton, docs.Badge, docs.FileTree, docs.Code, docs.LLMSkip,
)

In Markdown:

<docs.Steps>
1. Create the page.
2. Mount the route.
</docs.Steps>

<docs.Tabs sync="db">
  <docs.TabItem label="Postgres">...</docs.TabItem>
  <docs.TabItem label="SQL Server">...</docs.TabItem>
</docs.Tabs>

<docs.Code code={gx.CodeFile("main.go", "1-20")} />

<docs.LLMSkip>This section stays out of llms.txt.</docs.LLMSkip>

Examples

Aside: Note

<docs.Aside kind={docs.Note} title="Note">A note.</docs.Aside>

Aside: Tip

<docs.Aside kind={docs.Tip}>A tip.</docs.Aside>

Aside: Caution

<docs.Aside kind={docs.Caution}>Careful.</docs.Aside>

Aside: Danger

<docs.Aside kind={docs.Danger} title="Danger">Stop.</docs.Aside>

Badge: Default

<docs.Badge label="Default" />

Badge: Secondary

<docs.Badge label="Secondary" variant={docs.BadgeSecondary} />

Badge: Destructive

<docs.Badge label="Destructive" variant={docs.BadgeDestructive} />

Badge: Outline

<docs.Badge label="Outline" variant={docs.BadgeOutline} />

Card: Title and body

<docs.Card title="Card" description="A short description.">Body text.</docs.Card>

Card: Body only

<docs.Card>Body only.</docs.Card>

Card: Title only

<docs.Card title="Title only" />

CardGrid: Two

<docs.CardGrid>
  <docs.Card title="One">First.</docs.Card>
  <docs.Card title="Two">Second.</docs.Card>
</docs.CardGrid>

Code: Go

<docs.Code code={gx.CodeFile("go.mod", "")} title="go.mod" />

Code: Marked

<docs.Code code={gx.CodeFile("go.mod", "")} marks={[]int{1}} />

FileTree: Tree

<docs.FileTree items={[]docs.FileTreeItem{
  {Name: "app", Dir: true, Children: []docs.FileTreeItem{
    {Name: "main.go", Comment: "the app entry"},
    {Name: "theme.css"},
  }},
  {Name: "go.mod"},
}} />

FileTreeItemRow: File

<docs.FileTreeItemRow item={docs.FileTreeItem{Name: "main.go", Comment: "entry"}} />

FileTreeItemRow: Dir

<docs.FileTreeItemRow item={docs.FileTreeItem{Name: "app", Dir: true, Children: []docs.FileTreeItem{
  {Name: "main.go"},
}}} />

Hero: Full

<docs.Hero title="Gx" tagline="Server-rendered Go web apps.">
  <:actions>{gx.Raw(gx.SafeHTML(`<a href="/start">Get started</a>`))}</:actions>
</docs.Hero>

Hero: Title

<docs.Hero title="Title only" />

Icon: Decorative

<docs.Icon body={gx.SafeHTML(`<path d="M4 12h16" />`)} />

Icon: Labelled

<docs.Icon body={gx.SafeHTML(`<path d="M4 12h16" />`)} label="A dash" />

LLMSkip: Default

<docs.LLMSkip>Only for the page.</docs.LLMSkip>

LinkButton: Primary

<docs.LinkButton href={gx.URL("/start")}>Get started</docs.LinkButton>

LinkButton: Secondary

<docs.LinkButton href={gx.URL("/start")} variant={docs.ButtonSecondary}>Secondary</docs.LinkButton>

LinkButton: Outline

<docs.LinkButton href={gx.URL("/start")} variant={docs.ButtonOutline}>Outline</docs.LinkButton>

LinkButton: Ghost

<docs.LinkButton href={gx.URL("/start")} variant={docs.ButtonGhost}>Ghost</docs.LinkButton>

LinkCard: Full

<docs.LinkCard href={gx.URL("/errors/GX1000")} title="Diagnostics" description="Every code has a page.">
  Read on.
</docs.LinkCard>

LinkCard: Short

<docs.LinkCard href={gx.URL("/start")} title="Start" />

Steps: Three

<docs.Steps>{gx.Raw(gx.SafeHTML(`<ol><li>First</li><li>Second</li><li>Third</li></ol>`))}</docs.Steps>

TabItem: Text

<docs.TabItem label="Tab">Panel body.</docs.TabItem>

Tabs: Two

<docs.Tabs>
  <docs.TabItem label="Postgres">Postgres body.</docs.TabItem>
  <docs.TabItem label="SQL Server">SQL Server body.</docs.TabItem>
</docs.Tabs>

Tabs: Synced

<docs.Tabs sync="db">
  <docs.TabItem label="Option A">A.</docs.TabItem>
  <docs.TabItem label="Option B">B.</docs.TabItem>
</docs.Tabs>

API reference

A tag sets a prop by its name with a lower-case first letter: Class is class.

docs.Aside

Prop Type Default Description
Kind Kind Note Kind sets the tone of the callout: Note, Tip, Caution or Danger.
Title string "" Title is the heading of the callout. Empty omits it.
Children gx.Node Required Children is the content of the callout.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.Badge

Prop Type Default Description
Label string Required Label is the text of the badge.
Variant BadgeVariant BadgeDefault Variant sets the visual style: BadgeDefault, BadgeSecondary, BadgeDestructive or BadgeOutline.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.Card

Prop Type Default Description
Title string "" Title is the heading of the card. Empty omits it.
Description string "" Description is the text below the title. Empty omits it.
Children gx.Node nil Children is the content of the card. Nil omits the body.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.CardGrid

Prop Type Default Description
Children gx.Node Required Children is the cards of the grid.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.Code

Prop Type Default Description
Code gx.Code Required Code is the source to show. The compiler fills it at build time from a repository file.
Title string "" Title is the text in the frame bar.
Wrap bool false Wrap wraps long lines.
Marks []int nil Marks holds the 1-based numbers of the lines to highlight.
Ins []int nil Ins holds the 1-based numbers of the lines to mark as inserted.
Del []int nil Del holds the 1-based numbers of the lines to mark as deleted.
Words []int nil Words holds the 1-based numbers of the lines to outline.

docs.FileTree

Prop Type Default Description
Items []FileTreeItem Required Items holds the top-level files and directories of the tree.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.FileTreeItemRow

Prop Type Default Description
Item FileTreeItem Required Item is the file or directory of the row. Its children show as a nested list.

docs.Hero

Prop Type Default Description
Title string Required Title is the heading of the hero.
Tagline string "" Tagline is the text below the title. Empty omits it.
Actions gx.Node nil Actions is the row of links or buttons below the tagline. Nil omits it.
Children gx.Node nil Children is the content below the actions. Nil omits it.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.Icon

Prop Type Default Description
Body gx.SafeHTML Required Body is the inner markup of the svg, from a pinned icon pack.
Label string "" Label is the accessible name of the icon. Empty hides the icon from assistive technology.
Class string "" Class adds classes to the root element.

docs.LLMSkip

Prop Type Default Description
Children gx.Node nil Children is the content of the block. The component renders nothing; the block marks Markdown that stays out of llms.txt.

docs.LinkButton

Prop Type Default Description
Href gx.URL Required Href is the link target.
Variant ButtonVariant ButtonPrimary Variant sets the visual style: ButtonPrimary, ButtonSecondary, ButtonOutline or ButtonGhost.
Children gx.Node Required Children is the button label.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.LinkCard

Prop Type Default Description
Href gx.URL Required Href is the link target.
Title string Required Title is the heading of the card.
Description string "" Description is the text below the title. Empty omits it.
Children gx.Node nil Children is the content below the description. Nil omits it.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.Steps

Prop Type Default Description
Children gx.Node Required Children is the ordered list of steps.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.TabItem

Prop Type Default Description
Label string Required Label is the text of the tab button. It must be unique inside one tab group.
Children gx.Node Required Children is the content of the tab panel.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

docs.Tabs

Prop Type Default Description
Sync string "" Sync is the key that links tab groups. Groups with the same key switch together and remember the chosen tab.
Default string "" Default is the label of the tab that starts open. Empty opens the first tab.
Children gx.Node Required Children is the tab items.
Attrs gx.Attrs nil Attrs adds HTML attributes to the root element.

Do and do not

Do

  • Name the sync key when two tab groups must move together.
  • Wrap a section in docs.LLMSkip when agents must not read it.

Don't

  • Do not use docs.Code with a file outside the module.
  • Do not repeat a label inside one tab group.

Keyboard

Key Action
Enter, Space Switches a docs.Tabs tab.
Ctrl/Cmd K Opens the docs-shell search dialog when the shell is present.