Tw_htmlSourceHTML documents styled with Tailwind utilities.
Tw_html builds HTML elements and attributes as typed values. Each element carries the Tw.t utilities given through ~tw, so a page generates exactly the CSS its markup uses.
The abstract type for an HTML node.
The abstract type for an HTML attribute.
raw html is a node that writes html as given, unescaped.
Warning. html reaches the document verbatim: escape untrusted text with escape first.
to_string ~doctype t is t rendered as HTML, preceded by the HTML5 doctype declaration if doctype is true (defaults to false).
to_tw t are the utilities of every element in t: those given through ~tw and the names of class attributes that are utilities.
unknown_classes t lists, in document order, every name in the tree's class attributes that Tw.of_classes did not recognise as a utility.
Such a name is rendered as given - a framework hook or a JS selector belongs in a class attribute - so this is how a typo among them is found.
has_forms t is true iff t contains a form element (<input>, <select>, <textarea>) that the forms plugin base styles.
map_attrs f t is t with the attributes of each element replaced by f name attrs, name and attrs as fold_attrs gives them. A class attribute f changes is read as one given through ~at is: to_tw and unknown_classes report the names it carries. Markup given to raw is left as it is.
The type for complete HTML documents and the CSS generated from the utilities they use. It is abstract so that the CSS holds exactly the styles the HTML needs.
val page :
?lang:string ->
?meta:(string * string) list ->
?title:string ->
?charset:string ->
?tw_css:tw_css ->
?forms:bool ->
?prelude:t list ->
?theme:Tw.Scheme.t ->
t list ->
t list ->
pagepage ?lang ?meta ?title ?charset ?tw_css ?forms ?prelude ?theme head body is a complete HTML page and the CSS its utilities need, with:
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).prelude (default []) goes first in the head, right after the character set and before the meta tags, the title and the stylesheet: where a content security policy has to stand to cover them, and where a script that sets the theme runs before the stylesheet applies.theme (default Tw.Scheme.default) is the theme the CSS is generated with, as Tw.to_css takes it: its Tw.Scheme.t.dark, for one, decides what Tw.dark writes.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.
versioned path ~contents is path?v=h, where h is the first eight hex digits of the MD5 digest of contents. A <link> or <script> that names a file this way is fetched again whenever the file changes, as a page names its stylesheet.
css page is the CSS filename and stylesheet of page. The filename is Some file when the page links to an external stylesheet (Link file) and None when the CSS is inlined (Inline).
Live reloading during development.
el name ?at ?tw children is the element name, built as the named constructors below build theirs, for a tag they do not cover. It always has an end tag: a void element such as br has its own constructor.
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.
style ?at ?tw css is a style element holding css. <style> is a raw-text element, so css is written as given, unescaped.
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.
caption ?at ?tw children is a table caption 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 is an SVG root element.
circle ?at ?tw children is a circle element.
rect ?at ?tw children is a rectangle element.
path ?at ?tw children is a path element.
line ?at ?tw children is a line element.
text ?at ?tw children is a text element.
tspan ?at ?tw children is a tspan element, a run of text inside text.
desc ?at ?tw children is a desc element, the text description of its parent.
defs ?at ?tw children is a defs element, holding elements drawn only where they are referenced.
pattern ?at ?tw children is a pattern element, a tile a fill or a stroke can repeat.