Use daisyUI in a Bun dev server

How to use Tailwind CSS and daisyUI in a Bun dev server

Using Bun 1.2.4+ you can serve HTML and CSS files directly in a dev server. Here’s how to setup daisyUI for it.

1. Create a new Bun project

Create a new Bun project in the current directory

Terminal
bun init -y

2. Install bun-plugin-tailwind and daisyUI

Terminal
npm install bun-plugin-tailwind daisyui@beta

Create a bunfig.toml file at root and add bun-plugin-tailwind as a plugin

bunfig.toml
[serve.static]
plugins = ["bun-plugin-tailwind"]

3. Add HTML and CSS files

Create index.html at root

index.html
<!doctype html>
<html>
  <head>
    <title>daisyUI</title>
    <link rel="stylesheet" href="./style.css" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
  </head>
  <body>
    <button class="btn">daisyUI Button</button>
  </body>
</html>

Create style.css at root, add Tailwind CSS and daisyUI

style.css
@import "tailwindcss";
@plugin "daisyui";

Serve the HTML file

Terminal
bun index.html

Now you can use daisyUI class names!

Do you have a question? Ask on GitHub or Discord server
Do you like daisyUI? Post about it!
Support daisyUI's development: Open Collective
daisyUI store

Official daisyUI
Figma Library

Available on daisyUI store

More details