Develop
Using plain HTML
Render Faifo Design components to HTML strings and enable their interactions.
Install faifo-design and import components from faifo-design/html. Each function accepts
its usual props and returns a string that you can send from a server, write at build time, or
insert into a page. Your application can call these functions from JavaScript or TypeScript
without configuring JSX.
#Render and enhance a component
With a browser bundler that supports CSS imports, put an element with
id="order-controls" and data-faifo-design in the page. Run this module after the element
has loaded:
import { Checkbox } from 'faifo-design/html'
import { attachDesignSystemInteractions } from 'faifo-design/runtime'
import 'faifo-design/styles.css'
const controls = document.querySelector('#order-controls')
controls.innerHTML = Checkbox({
id: 'select-orders',
name: 'all',
label: 'Select all orders',
checked: 'indeterminate',
})
attachDesignSystemInteractions(document)The runtime initializes the checkbox in its mixed state and updates aria-checked after
the reader checks or unchecks it. If you render on the server, serve the stylesheet with
the page and call attachDesignSystemInteractions(document) in the browser when the page
is ready.
#Compose components
Pass text as a string and the renderer will escape it. To place the HTML from one component
inside another, wrap the returned string in htmlFragment:
import { Button, Surface, htmlFragment } from 'faifo-design/html'
const markup = Surface({
title: 'Order details',
body: 'This order is ready to ship.',
actions: htmlFragment(Button({ label: 'Print order' })),
})Use htmlFragment only with HTML produced by a trusted renderer. Pass labels and other
user-supplied text directly as component props so they remain escaped.
#Supported components
The entry tracks the component catalogue and includes the registered static
components. This covers primitives, layouts, forms, and display components such as
DataTable and the server-rendered FaifoTable. The server-rendered table supports links
and displays the state supplied by the application. For DOM behavior, the HTML entry uses
the data-ui runtime. JavaScript callbacks carried by a ketjs-view
template are discarded when the template is rendered to static HTML.
The qrSvg and searchFilterRuleLabel helpers keep their original signatures and return
an SVG string and a plain text label, respectively.
The package's HTML exclusions record the reason for each omitted catalogue export. These include the stateful island controllers and the shell and page components that use KetJS fragments or navigation.