Tw_htmlSourceA library for building HTML documents programmatically.
This module provides a type-safe and declarative API for creating HTML elements and attributes. It is designed to be used for generating static HTML pages.
The abstract type for an HTML node.
The abstract type for an HTML attribute.
to_string ?doctype element converts HTML element to string representation. If doctype is true (default: false), includes the HTML5 doctype declaration.
has_forms t returns true if the HTML tree contains form elements (input, select, textarea) that benefit from the forms plugin base styles.
Complete HTML page with integrated CSS.
A page value represents a complete, self-contained HTML document with all required CSS automatically generated from the Tailwind utilities used in the HTML structure. This ensures consistency between your markup and styles without manual CSS management.
Design rationale: The type is abstract to enforce the invariant that the CSS contains exactly the styles needed for the HTML content. Direct construction would break this guarantee.
val page :
?lang:string ->
?meta:(string * string) list ->
?title:string ->
?charset:string ->
?tw_css:tw_css ->
?forms:bool ->
t list ->
t list ->
pagepage ?lang ?meta ?title ?charset ?tw_css ?forms head body generates a complete HTML page and its corresponding CSS.
lang defaults to "en"charset defaults to "utf-8"meta is a list of (name, content) pairs for meta tagstitle is the page titletw_css controls how the CSS is delivered (see tw_css). Defaults to Link "tw.css", which references the CSS through a cache-busted <link> tag in the HTML head. Use Inline to embed the CSS in the document and avoid an extra HTTP request.forms explicitly enables the \@tailwindcss/forms plugin base layer, mirroring Tailwind's \@plugin opt-in. When omitted, the forms base is auto-detected from forms utility usage (like prose styling).head is additional content for the head sectionbody is the body contentUse html to get the HTML string and css to get the CSS filename and stylesheet.
css page extracts the CSS filename and stylesheet from a page result. The filename is Some file when the page links to an external stylesheet (Link file) and None when the CSS is inlined (Inline).
span ?at ?tw children is a span element.
a ?at ?tw children is an anchor/link element.
ul ?at ?tw children is an unordered list element.
li ?at ?tw children is a list item element.
nav ?at ?tw children is a navigation element.
section ?at ?tw children is a section element.
article ?at ?tw children is an article element.
header ?at ?tw children is a header element.
footer ?at ?tw children is a footer element.
h1 ?at ?tw children is an h1 heading element.
h2 ?at ?tw children is an h2 heading element.
h3 ?at ?tw children is an h3 heading element.
h4 ?at ?tw children is an h4 heading element.
h5 ?at ?tw children is an h5 heading element.
h6 ?at ?tw children is an h6 heading element.
script ?at ?tw children is a script element.
title ?at ?tw children is a title element.
head ?at ?tw children is a head element.
body ?at ?tw children is a body element.
root ?at ?tw children is the root <html> element of a document.
option ?at ?tw children is an option element.
select ?at ?tw children is a select element.
main ?at ?tw children is a main element.
aside ?at ?tw children is an aside element.
time ?at ?tw children is a time element.
dialog ?at ?tw children is a dialog element.
data ?at ?tw children is a data element.
picture ?at ?tw children is a picture element.
slot ?at ?tw children is a slot element.
template ?at ?tw children is a template element.
form ?at ?tw children is a form element.
textarea ?at ?tw children is a textarea element.
button ?at ?tw children is a button element.
label ?at ?tw children is a label element.
fieldset ?at ?tw children is a fieldset element.
legend ?at ?tw children is a legend element.
details ?at ?tw children is a details element.
summary ?at ?tw children is a summary element.
code ?at ?tw children is a code element.
kbd ?at ?tw children is a keyboard input element.
em ?at ?tw children is an emphasis element.
strong ?at ?tw children is a strong element.
small ?at ?tw children is a small element.
mark ?at ?tw children is a mark element.
hr ?at ?tw () is a hr (horizontal rule) element.
table ?at ?tw children is a table element.
thead ?at ?tw children is a table head element.
tbody ?at ?tw children is a table body element.
tfoot ?at ?tw children is a table footer element.
tr ?at ?tw children is a table row element.
th ?at ?tw children is a table header cell element.
td ?at ?tw children is a table data cell element.
ol ?at ?tw children is an ordered list element.
dl ?at ?tw children is a description list element.
dt ?at ?tw children is a description term element.
dd ?at ?tw children is a description definition element.
blockquote ?at ?tw children is a blockquote element.
figure ?at ?tw children is a figure element.
figcaption ?at ?tw children is a figure caption element.
video ?at ?tw children is a video element.
audio ?at ?tw children is an audio element.
canvas ?at ?tw children is a canvas element.
iframe ?at ?tw children is an iframe element.
svg ?at ?tw children creates an SVG root element.
g ?at ?tw children creates a group element.
circle ?at ?tw children creates a circle element.
rect ?at ?tw children creates a rectangle element.
path ?at ?tw children creates a path element.
line ?at ?tw children creates a line element.