A starter template for a web app built with
bun create github.com/dazraf/lit-tailwind-daisy-bun <your-directory-name>
cd <your-directory-name>
bun dev
Useful for testing as well as running the Lighthouse report.
bun run build
npx http-server dist -p 5173 -g --proxy http://localhost:5173\?
/
, /contact
and /about
.AppStyledElement.ts
which gives you all the power of Tailwind and Daisy for Lit componentsThe vite app was created with bun create vite my-vue-app --template lit-ts
. Then I added vite-plugin-compression
and vite-plugin-sitemap
to meet best practices as recommended by Lighthouse.
The app uses the packages for Tailwind (including @tailwind/typography
postcss
and autoprefixer
), Daisy, Lit Router, Bootstrap Icons and the URLPatter polyfill.
I've configured Tailwind to include Tailwind's typography package and Daisy UI. As the app demonstrates the use of Daisy's multiple themes, I've also configured the selected list in the config. Unfortunatley, this list has to be replicated in the app itself in ThemeSelector.ts
.
Tailwind is included in the application's index.css
. The build system will use Tailwind to generate a minimal set of CSS definitions as used by the app. The app includes this file in AppStyledElement.ts
import inlineCss from "../index.css?inline";
export const appStyle = unsafeCSS(inlineCss);
This will ensure that we only load the CSS file once to be used by Lit elements. Typically the compiler will error when importing a CSS file and when using the ?inline
parameter, but this is easily dealt with global.d.ts
:
declare module "*.css";
declare module "*.css?inline";
The AppStyledElement
mixin is then used when creating a new Lit component e.g.
@customElement("app-breadcrumbs")
export class Breadcrumbs extends AppStyledElement(LitElement) {
//...
}
The Lit Router is a great lightweight library. In navigation.ts
I've hooked the browser's globalThis.history.pushState
to keep it updated.
I've decided to use Daisy's Theme Controller, wrapping it in a Lit component and altering some of the UX behaviour. I think this one could do with more work to allow for full accesibility via only the keyboard.