🐊 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
Metadata
Release files for croc-ui 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| croc_ui-1.0.3.tar.gz | 27.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| croc_ui-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 55.7 kB
Release files / croc_ui-1.0.3.tar.gz
| Download URL | croc_ui-1.0.3.tar.gz |
|---|---|
| Size | 27.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5def0a78bb92a89137b20472cbd10b75b28d092f5ff5bf8d3f257aaed4fcdfa2
|
|
BLAKE2b-256 checksum How to use checksums |
46f7d5c38be9a66151d49057bae077276196b021656a47c92cae1b05214c724f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.
Transparency logRelease files / croc_ui-1.0.3-py3-none-any.whl
| Download URL | croc_ui-1.0.3-py3-none-any.whl |
|---|---|
| Size | 28.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d63ce90054133a3304e578ef08515d201fe2152354924460a8b7e75a7b942b4d
|
|
BLAKE2b-256 checksum How to use checksums |
dcc7a8783224c175995ad9d689a390ee30a1250468dd29601795fe7f67bb2d71
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.
Transparency logSecurity for croc-ui 1.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for croc_ui-1.0.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.