Installation
Add dui's components to a Bun project.
Install the CLI
dui is one binary, for Linux and macOS. This puts it in /usr/local/bin, and running it again upgrades it:
curl -fsSL https://dui.aak.sh/install.sh | shAdd components
Run this in your project. It writes the components to src/ui/, and the JSX runtime and theme they need to src/lib/ (or ui/ and lib/ where there's no src/; pick another folder with --dir).
dui add button carddui list shows every component.
Set up JSX
Point JSX at the runtime in lib/:
// package.json
"imports": { "#jsx/*": "./src/lib/jsx/*.ts" }
// tsconfig.json
"compilerOptions": { "jsx": "react-jsx", "jsxImportSource": "#jsx" }Use them
Each component exports its CSS as text, for the page to inline with the theme's:
import { raw } from './lib/jsx/jsx-runtime.ts'
import theme from './lib/theme.css' with { type: 'text' }
import { Button, BUTTON_CSS } from './ui/button.tsx'
const page = (
<html>
<head>
<style>{raw(theme + BUTTON_CSS)}</style>
<script type="module" src="https://cdn.jsdelivr.net/gh/starfederation/datastar@1.0.4/bundles/datastar.js"></script>
</head>
<body data-signals:count="0">
<Button data-on:click="$count++">Clicked <span data-text="$count"></span> times</Button>
</body>
</html>
)
Bun.serve({ routes: { '/': new Response('<!DOCTYPE html>' + page, { headers: { 'Content-Type': 'text/html' } }) } })