A Python library for building beautiful static websites using Python โ no HTML/CSS required.
Project description
๐ croc-ui
A Python library for building beautiful static websites using Python โ no HTML/CSS required.
croc-ui lets you build complete, styled static websites entirely in Python. Write Python classes, get beautiful HTML. Run locally with a built-in dev server.
โจ Features
- 30+ UI Components โ Cards, Navbars, Modals, Tabs, Tables, Accordions, Badges, Alerts, Forms, and more
- Fluent Style Builder โ Chain CSS properties with
Style().color("red").font_size("16px") - Theme System โ Built-in presets (
default,dark,ocean,forest) or build your own - Zero Dependencies โ Uses only Python's standard library
- Dev Server โ One-line local server with route registration, static file serving, and browser auto-open
- Page Builder โ Full HTML page with
<head>, Google Fonts, icon libraries, and meta tags
๐ Installation
pip install croc-ui
Or from source:
git clone https://github.com/swarup-kumar-sahoo/croc
cd croc
pip install -e .
โก Quick Start
from croc_ui import App, Page, Navbar, Container, H1, P, Button, Card, Theme
app = App()
@app.route("/")
def home():
page = Page(
title="My Website",
theme=Theme("default"),
fonts=["Inter"],
)
page.add(
Navbar(brand="My Site", links=[("Home", "/"), ("About", "/about")], sticky=True),
Container(
H1("Welcome to My Site"),
P("Built entirely in Python with croc-ui.", style="color: var(--croc-text-muted);"),
Button("Get Started โ", variant="primary"),
),
)
return page
@app.route("/about")
def about():
page = Page(title="About")
page.add(
Container(
H1("About"),
Card(
P("This site was built with croc-ui โ Python-powered web UI."),
title="About croc-ui",
)
)
)
return page
app.run(port=3000)
Run it:
python app.py
Opens at http://localhost:3000 ๐
๐ฆ Component Reference
Layout
| Component | Description |
|---|---|
Container |
Centered max-width wrapper |
Row |
Flexbox row |
Column |
Flex column with optional span |
Section |
<section> block |
Header / Footer |
Semantic header/footer |
Div |
Generic <div> |
Typography
| Component | Description |
|---|---|
H1โH6 |
Headings |
P |
Paragraph |
Span / Text |
Inline text |
Code / Pre |
Code blocks |
Blockquote |
Quoted text |
Label |
Form label with for_ attribute |
Forms
| Component | Description |
|---|---|
Form |
<form> with action/method |
Input |
Text, email, password, number, etc. |
Button |
8 variants, 3 sizes |
Textarea |
Multi-line text input |
Select + Option |
Dropdown |
Checkbox / Radio |
Boolean inputs |
FileInput |
File upload |
Range |
Slider |
Navigation
| Component | Description |
|---|---|
Navbar |
Responsive top nav with brand + links |
Sidebar |
Vertical nav panel |
Breadcrumb |
Path breadcrumbs |
Tabs |
Tabbed content panels |
Pagination |
Page navigation |
UI Components
| Component | Description |
|---|---|
Card |
Content card with header/footer |
Badge |
Inline status badge |
Alert |
Dismissible alert message |
Modal |
Overlay dialog |
Tooltip |
Hover tooltip |
Progress |
Progress bar |
Spinner |
Loading spinner |
Accordion |
Collapsible sections |
Table |
Striped/hover data table |
List |
Ordered/unordered list |
Tag |
Removable filter tag |
Divider |
Horizontal rule with optional label |
Avatar |
Image or initials avatar |
Media
| Component | Description |
|---|---|
Img |
Image with lazy loading |
Video / Audio |
Media elements |
Icon |
Font Awesome / Bootstrap / Material icon |
SVG / Path |
SVG elements |
๐จ Styling
Inline styles (dict or string)
H1("Hello", style={"color": "red", "font_size": "2rem"})
H1("Hello", style="color: red; font-size: 2rem")
Fluent Style builder
from croc_ui import Style
s = Style().color("red").font_size("2rem").padding("1rem").background_color("#f0f0f0")
H1("Hello", style=s)
CSS classes
Div("content", classes="my-class another-class")
Div("content", classes=["my-class", "another-class"])
Extra CSS on the Page
page = Page(extra_css="""
.hero { background: linear-gradient(135deg, #3b82f6, #8b5cf6); }
.hero h1 { color: white; }
""")
๐ญ Themes
from croc_ui import Theme
# Built-in presets: "default", "dark", "ocean", "forest"
theme = Theme("dark")
# Override individual tokens
theme = Theme(
preset="default",
primary="#ff6b35",
font_family="'Playfair Display', serif",
border_radius="12px",
shadow="0 4px 20px rgba(0,0,0,0.15)",
)
page = Page(theme=theme)
๐ App & Routing
from croc_ui import App, Page
app = App(static_dir="./static") # optional static file directory
# Decorator style
@app.route("/")
def home():
return Page(title="Home")
# Programmatic
app.add_route("/about", about_page_fn)
app.add_page("/contact", contact_page_instance)
# Run
app.run(
host="127.0.0.1", # default
port=3000, # default
open_browser=True, # auto-open browser
)
๐ Saving Static HTML
page = Page(title="My Page")
page.add(H1("Hello!"))
page.save("index.html") # saves rendered HTML to file
print(page.render()) # get HTML string
๐ Project Structure
croc-ui/
โโโ croc_ui/
โ โโโ __init__.py # Public API exports
โ โโโ app.py # Dev server (App class)
โ โโโ page.py # Page builder
โ โโโ base.py # Element base classes
โ โโโ components/
โ โ โโโ layout.py # Container, Row, Column, etc.
โ โ โโโ typography.py # H1-H6, P, Code, etc.
โ โ โโโ forms.py # Input, Button, Select, etc.
โ โ โโโ media.py # Img, Video, Icon, SVG
โ โ โโโ navigation.py # Navbar, Tabs, Pagination
โ โ โโโ ui.py # Card, Alert, Modal, Table, etc.
โ โโโ styles/
โ โโโ style.py # Fluent Style builder
โ โโโ theme.py # Theme system
โโโ examples/
โโโ example_app.py # Full showcase app
๐ค Contributing
Issues and PRs welcome at https://github.com/swarup-kumar-sahoo/croc
๐ License
MIT License โ ยฉ Swarup Kumar Sahoo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file croc_ui-1.0.3.tar.gz.
File metadata
- Download URL: croc_ui-1.0.3.tar.gz
- Upload date:
- Size: 27.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5def0a78bb92a89137b20472cbd10b75b28d092f5ff5bf8d3f257aaed4fcdfa2
|
|
| MD5 |
c172909a7844df4bc4d3fa0b345b1597
|
|
| BLAKE2b-256 |
46f7d5c38be9a66151d49057bae077276196b021656a47c92cae1b05214c724f
|
Provenance
The following attestation bundles were made for croc_ui-1.0.3.tar.gz:
Publisher:
publish.yml on swarup-kumar-sahoo/croc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
croc_ui-1.0.3.tar.gz -
Subject digest:
5def0a78bb92a89137b20472cbd10b75b28d092f5ff5bf8d3f257aaed4fcdfa2 - Sigstore transparency entry: 1040988506
- Sigstore integration time:
-
Permalink:
swarup-kumar-sahoo/croc@52dfe4c7089f4546e8c52003b71f92eea775c4a4 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/swarup-kumar-sahoo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52dfe4c7089f4546e8c52003b71f92eea775c4a4 -
Trigger Event:
release
-
Statement type:
File details
Details for the file croc_ui-1.0.3-py3-none-any.whl.
File metadata
- Download URL: croc_ui-1.0.3-py3-none-any.whl
- Upload date:
- Size: 28.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d63ce90054133a3304e578ef08515d201fe2152354924460a8b7e75a7b942b4d
|
|
| MD5 |
2eff6dd98e8b5414b7c87f8f628a1542
|
|
| BLAKE2b-256 |
dcc7a8783224c175995ad9d689a390ee30a1250468dd29601795fe7f67bb2d71
|
Provenance
The following attestation bundles were made for croc_ui-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on swarup-kumar-sahoo/croc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
croc_ui-1.0.3-py3-none-any.whl -
Subject digest:
d63ce90054133a3304e578ef08515d201fe2152354924460a8b7e75a7b942b4d - Sigstore transparency entry: 1040988575
- Sigstore integration time:
-
Permalink:
swarup-kumar-sahoo/croc@52dfe4c7089f4546e8c52003b71f92eea775c4a4 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/swarup-kumar-sahoo
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@52dfe4c7089f4546e8c52003b71f92eea775c4a4 -
Trigger Event:
release
-
Statement type: