Search the documentation

Type to search page titles, component names and descriptions.

    Develop

    Getting started

    Install the package, load the stylesheet and render a first screen.

    #Install

    npm install faifo-design @ketvietlab/ketjs-view

    Configure TypeScript to compile JSX for ketjs-view:

    {
      "compilerOptions": {
        "jsx": "react-jsx",
        "jsxImportSource": "@ketvietlab/ketjs-view"
      }
    }

    #Load the stylesheet

    Import the stylesheet once, from the CSS your application already bundles:

    @import "faifo-design/styles.css";

    The fonts are embedded in the file, so there is nothing else to serve. If the page sends a content security policy, allow data: in font-src.

    #Mark the root

    Components are styled inside an element that carries data-faifo-design. Put it on the application root:

    import { Button, Stack, Surface, Text } from 'faifo-design'
    
    export const view = () => (
      <main data-faifo-design>
        <Surface
          title="Orders"
          actions={<Button label="Create order" variant="primary" icon="plus" />}
          body={
            <Stack
              items={[
                <Text as="p" variant="bodyMd">
                  Nothing is waiting for you.
                </Text>,
              ]}
            />
          }
        />
      </main>
    )

    #Attach the runtime

    A page that is rendered on the server gets its interactions from one script:

    <script type="module" src="/path/to/faifo-design/runtime/auto.js"></script>

    or, from your own entry module:

    import { attachDesignSystemInteractions } from 'faifo-design/runtime'
    
    attachDesignSystemInteractions(document)

    Without the runtime, links, forms, tabs and tables still work: they are native. What you lose is the enhancement: menus that position themselves, focus management in dialogs, calendars.

    #Choose a theme

    The stylesheet follows the system colour scheme. Pin one with data-theme:

    <html data-theme="dark">

    #Next