Skip to main content

A collection of utilities for FastHTML projects

Project description

fh_utils

A collection of utilities for FastHTML projects.

Docs

Installation

pip install fh_utils
uv add fh_utils

Tailwindcss and Daisycss

Add Tailwind / Daisy to your app

from fh_utils.tailwind import add_daisy_and_tailwind, add_tailwind, tailwind_compile

app, rt = fast_app(pico=False, static_path="public")

# Usage 1: Add Tailwind CSS
add_tailwind(app)

# Usage 2: Add DaisyUI along with Tailwind CSS
add_daisy_and_tailwind(app)

# Usage 3: Customize Tailwind configuration
add_tailwind(app, cfg=Path("tailwind.config.js").read_text(), css="your custom css")

# Usage 4: Serve via FastHTML's static route
# Note: Don't forget to add public/app.css to your .gitignore
tailwind_compile("public/app.css")
app, rt = fast_app(hdrs=[Link(rel="stylesheet", href="app.css")], pico=False, static_path="public")

The Tailwind CLI is automatically downloaded, and your CSS files are compiled, served, and integrated into your app.

Bonus: Using Tailwind CSS IntelliSense in VSCode

  1. Install the Tailwind CSS IntelliSense extension

  2. Create a tailwind.config.js file at the root of your project and ensure that */.py is included in the content paths:

module.exports = {
  content: ["**/*.py"],
};

See here for a full example of config

  1. Add the following settings to your .vscode/settings.json file to enable IntelliSense support for Tailwind classes in Python:
{
  // ...
  "tailwindCSS.classAttributes": ["class", "cls"],
  "tailwindCSS.includeLanguages": {
    "python": "html"
  }
}

Dev

uv sync
uv run pytest
uv run demo
uv build
uvx twine upload dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fh_utils-0.1.1.tar.gz (59.0 kB view hashes)

Uploaded Source

Built Distribution

fh_utils-0.1.1-py3-none-any.whl (8.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page