Skip to main content

SwiftUI inspired wrapper for FastHTML

Project description

fhswiftui

fhswiftui is a SwiftUI inspired wrapper for FastHTML and tailwind. fhswiftui is built on top of FastHTML and tailwind and will work with all FT components. Tailwind classes and FastHTML features work seamlessly.

FastHTML enables composing HTML apps by nested Python objects and tailwind is a CSS framework that provides standard CSS components. Since tailwind relies heavily on CSS classes to define components as well as include style information, this can quickly become complex and difficult to read.

For example, let’s consider a simple example of a turn in a chat which displays a user’s message with a timestamp. In FastHTML + tailwind, this would look like something:

Section(
    Div(
        Span('04:30:56', cls='text-xs text-muted-foreground'),
        Div('What is the meaning of life?', cls='flex w-max max-w-[75%] flex-col gap-2 rounded-lg px-3 py-2 text-sm border-l-4 border-primary italic'),
        cls='flex gap-2 items-center'
    ),
    cls='space-y-6'
)

fhswiftui provides layout and UI components. It also provides property setters that enable specific styling. The same example above using fhswiftui:

HStack(alignment="center")(
    Text('04:30:56').fg("muted-foreground").font(size="xs"),
    VDivider(border_color),
    Div(t.m).padding(left=3, right=3, top=2, bottom=2).font(size="sm")
)

fhswiftui is built on top of FastHTML and tailwind and will work with all FT components. Tailwind classes and FastHTML features work seamlessly.

Installation

Install latest from pypi

$ pip install fhswiftui

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

fhswiftui-0.0.2.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fhswiftui-0.0.2-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file fhswiftui-0.0.2.tar.gz.

File metadata

  • Download URL: fhswiftui-0.0.2.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fhswiftui-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1c2845fc0a656bf5ea985961975245c3220e00886122f73855fad8227e5e1c64
MD5 1cba1d7bd15966d7a04d8cf63707a74e
BLAKE2b-256 2d78d3dd71861800ad758d55b2a2b556f38c3f466dd5821c039635e34b99b99d

See more details on using hashes here.

File details

Details for the file fhswiftui-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: fhswiftui-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for fhswiftui-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0061c3563fb7a98d9787b2d445fb3d414d6e16c163831b4f0ae9a8c93f07d087
MD5 87c1c8671a71277879addaed275860c3
BLAKE2b-256 2af618fa7c699f43bdac55ba9211aa907c9bdb88aad5e06aed646cb65c50520d

See more details on using hashes here.

Supported by

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