Skip to main content

Python CSS toolkit — generate gradients, shadows, borders, flexbox, grid, animations, transforms, and 7 more CSS utilities. Zero dependencies.

Project description

peasy-css

PyPI Python License: MIT Zero Dependencies

Pure Python CSS generator — gradients, shadows, flexbox, grid, animations, transforms, filters, glassmorphism, and more. Zero dependencies, type-safe, with CLI, MCP server, and REST API client.

Built from PeasyCSS, the interactive CSS tools platform with 200+ generators and references.

Try the interactive tools at peasycss.comGradient Generator, Box Shadow, Flexbox, Grid, Glassmorphism

Table of Contents

Install

# Core library (zero dependencies)
pip install peasy-css

# With CLI
pip install "peasy-css[cli]"

# With MCP server for AI assistants
pip install "peasy-css[mcp]"

# With REST API client
pip install "peasy-css[api]"

# Everything
pip install "peasy-css[all]"

Quick Start

from peasy_css import gradient, box_shadow, Shadow, flexbox, glassmorphism

# Generate a linear gradient
css = gradient(["#ff6b35", "#f7c948", "#2ec4b6"])
# → "linear-gradient(to right, #ff6b35, #f7c948, #2ec4b6)"

# Create a box shadow
shadow = Shadow(x="0px", y="4px", blur="12px", color="rgba(0,0,0,0.15)")
css = box_shadow(shadow)
# → "0px 4px 12px 0px rgba(0,0,0,0.15)"

# Flexbox layout
css = flexbox(direction="row", justify="center", align="center", gap="1rem")
# → "display: flex;\nflex-direction: row;\njustify-content: center;\nalign-items: center;\ngap: 1rem;"

# Glassmorphism effect
css = glassmorphism(blur="20px", background="rgba(255,255,255,0.1)")
# → backdrop-filter, background, border — frosted glass effect

What You Can Do

Gradients

CSS gradients create smooth color transitions — linear (directional), radial (circular), and conic (angular). The gradient() function supports all three types with optional repeating patterns and precise color stops.

Type CSS Function Use Case
Linear linear-gradient() Backgrounds, buttons, headers
Radial radial-gradient() Spotlight effects, circular highlights
Conic conic-gradient() Pie charts, color wheels
Repeating repeating-*-gradient() Striped patterns, progress bars
from peasy_css import gradient, gradient_css, ColorStop

# Linear gradient with direction
gradient(["#e66465", "#9198e5"], direction="to bottom")
# → "linear-gradient(to bottom, #e66465, #9198e5)"

# Radial gradient
gradient(["#fff", "#000"], gradient_type="radial")
# → "radial-gradient(circle, #fff, #000)"

# Precise color stops
stops = [ColorStop("red", "0%"), ColorStop("yellow", "50%"), ColorStop("green", "100%")]
gradient(stops)
# → "linear-gradient(to right, red 0%, yellow 50%, green 100%)"

# Complete CSS rule
gradient_css(".hero", ["#667eea", "#764ba2"])
# → ".hero {\n  background: linear-gradient(to right, #667eea, #764ba2);\n}"

Learn more: Gradient Generator · CSS Gradients Guide

Box Shadows

Box shadows add depth and elevation to elements. Multiple shadows can be layered for complex effects like material design elevation or neumorphism.

from peasy_css import box_shadow, box_shadow_css, Shadow

# Single shadow
s = Shadow(x="0px", y="4px", blur="6px", spread="0px", color="rgba(0,0,0,0.1)")
box_shadow(s)
# → "0px 4px 6px 0px rgba(0,0,0,0.1)"

# Inset shadow (inner shadow)
s = Shadow(x="0px", y="2px", blur="4px", color="rgba(0,0,0,0.2)", inset=True)
box_shadow(s)
# → "inset 0px 2px 4px 0px rgba(0,0,0,0.2)"

# Multiple layered shadows
s1 = Shadow(y="2px", blur="4px", color="rgba(0,0,0,0.1)")
s2 = Shadow(y="8px", blur="16px", color="rgba(0,0,0,0.1)")
box_shadow(s1, s2)
# → "0px 2px 4px 0px rgba(0,0,0,0.1), 0px 8px 16px 0px rgba(0,0,0,0.1)"

Learn more: Box Shadow Generator · CSS Shadows Guide

Flexbox Layouts

Flexbox is a one-dimensional layout model for distributing space and aligning items. It handles both horizontal (row) and vertical (column) layouts with powerful alignment controls.

Property Values Default
direction row, row-reverse, column, column-reverse row
wrap nowrap, wrap, wrap-reverse nowrap
justify flex-start, flex-end, center, space-between, space-around, space-evenly flex-start
align stretch, flex-start, flex-end, center, baseline stretch
from peasy_css import flexbox, flexbox_css

# Centered content
flexbox(justify="center", align="center")

# Responsive card layout
flexbox(wrap="wrap", gap="1.5rem", justify="space-between")

# Complete CSS rule
flexbox_css(".navbar", direction="row", justify="space-between", align="center")
# → ".navbar {\n  display: flex;\n  flex-direction: row;\n  ..."

Learn more: Flexbox Generator · Flexbox Guide

CSS Grid

CSS Grid is a two-dimensional layout system for rows and columns simultaneously. It excels at complex page layouts, card grids, and dashboard designs.

from peasy_css import grid, grid_css, GridTemplate

# Default 3-column grid
grid()
# → "display: grid;\ngrid-template-columns: 1fr 1fr 1fr;\ngap: 1rem;"

# Custom grid template
t = GridTemplate(columns="repeat(4, 1fr)", rows="auto 1fr auto", gap="2rem")
grid(t)

# Dense auto-flow (fill gaps automatically)
t = GridTemplate(columns="repeat(auto-fill, minmax(250px, 1fr))", auto_flow="dense")
grid(t)

Learn more: Grid Generator · CSS Grid Guide

Animations & Keyframes

CSS animations bring elements to life with multi-step transitions. The animation() function generates the shorthand property, while keyframes() creates @keyframes rules.

from peasy_css import animation, animation_css, keyframes, Keyframe

# Animation shorthand
animation("fadeIn", "0.5s", "ease-in")
# → "fadeIn 0.5s ease-in 0s 1 normal none"

# Keyframes definition
frames = [
    Keyframe("from", {"opacity": "0", "transform": "translateY(-20px)"}),
    Keyframe("to", {"opacity": "1", "transform": "translateY(0)"}),
]
keyframes("fadeIn", frames)
# → "@keyframes fadeIn {\n  from { opacity: 0; transform: translateY(-20px); }\n  to { ... }\n}"

Learn more: Animation Generator · CSS Animation Guide

Transforms

CSS transforms modify the visual rendering of elements — translate, rotate, scale, and skew without affecting document flow.

from peasy_css import transform, transform_css

# Single transform
transform(rotate="45deg")
# → "rotate(45deg)"

# Combined transforms
transform(translate_x="10px", translate_y="20px", rotate="45deg", scale_x="1.5")
# → "translate(10px, 20px) rotate(45deg) scale(1.5, 1)"

# No transforms applied
transform()
# → "none"

Learn more: Transform Generator · CSS Transform Guide

CSS Filters

CSS filters apply graphical effects like blur, brightness, contrast, and grayscale to elements — commonly used for image effects and hover states.

from peasy_css import css_filter, filter_css

# Single filter
css_filter(blur="5px")
# → "blur(5px)"

# Multiple filters
css_filter(blur="2px", brightness="120%", grayscale="50%")
# → "blur(2px) brightness(120%) grayscale(50%)"

Learn more: Filter Generator · CSS Filter Guide

Glassmorphism

Glassmorphism creates a frosted glass effect using backdrop-filter, semi-transparent backgrounds, and subtle borders. It's widely used in modern UI design (iOS, Windows 11).

from peasy_css import glassmorphism, glassmorphism_css

# Default glassmorphism
glassmorphism()
# → "backdrop-filter: blur(10px);\n-webkit-backdrop-filter: blur(10px);\nbackground: rgba(255, 255, 255, 0.25);\nborder: 1px solid rgba(255, 255, 255, 0.18);"

# Custom glass effect
glassmorphism(blur="20px", background="rgba(0, 0, 0, 0.3)")

# Complete CSS rule
glassmorphism_css(".modal", blur="15px")

Learn more: Glassmorphism Generator · Glassmorphism Guide

Fluid Typography

CSS clamp() enables fluid typography that scales smoothly between viewport sizes — replacing complex media query breakpoints with a single declaration.

from peasy_css import clamp, clamp_font_css

# Fluid value
clamp("1rem", "2.5vw", "3rem")
# → "clamp(1rem, 2.5vw, 3rem)"

# Fluid font-size CSS rule
clamp_font_css("h1", "1.5rem", "4vw", "3rem")
# → "h1 {\n  font-size: clamp(1.5rem, 4vw, 3rem);\n}"

Learn more: Clamp Calculator · CSS Clamp Guide

Media Queries

Media queries enable responsive design by applying CSS rules at specific viewport breakpoints.

from peasy_css import media_query

# Min-width (mobile-first)
media_query("768px", ".sidebar { display: block; }")
# → "@media (min-width: 768px) {\n  .sidebar { display: block; }\n}"

# Max-width (desktop-first)
media_query("480px", "body { font-size: 14px; }", type="max-width")
# → "@media (max-width: 480px) {\n  body { font-size: 14px; }\n}"

Learn more: Media Query Guide

Command-Line Interface

# Generate a gradient
peasy-css gradient --colors "#ff6b35" "#f7c948" "#2ec4b6"

# Box shadow
peasy-css shadow --x 0px --y 4px --blur 12px --color "rgba(0,0,0,0.15)"

# Flexbox layout
peasy-css flexbox --direction row --justify center --align center --gap 1rem

# CSS Grid
peasy-css grid --columns "repeat(3, 1fr)" --gap 2rem

# Glassmorphism
peasy-css glass --blur 20px --background "rgba(255,255,255,0.1)"

# Fluid font size
peasy-css clamp --min 1rem --preferred 2.5vw --max 3rem

MCP Server (Claude, Cursor, Windsurf)

Start the MCP server for AI-assisted CSS generation:

uvx --from "peasy-css[mcp]" python -m peasy_css

Claude Desktop

{
  "mcpServers": {
    "peasy-css": {
      "command": "uvx",
      "args": ["--from", "peasy-css[mcp]", "python", "-m", "peasy_css"]
    }
  }
}

Cursor / Windsurf

{
  "mcpServers": {
    "peasy-css": {
      "command": "uvx",
      "args": ["--from", "peasy-css[mcp]", "python", "-m", "peasy_css"]
    }
  }
}

Available MCP tools: css_gradient, css_box_shadow, css_flexbox, css_grid, css_animation, css_transform, css_glassmorphism, css_clamp_font, css_media_query

REST API Client

from peasy_css.api import PeasyCssAPI

api = PeasyCssAPI()

# List all CSS tools
tools = api.list_tools()

# Get a specific tool
tool = api.get_tool("gradient-generator")

# Search tools and glossary
results = api.search("flexbox")

# OpenAPI specification
spec = api.openapi_spec()

API Reference

CSS Generators

Function Description
gradient(colors, ...) Generate CSS gradient value
gradient_css(selector, colors, ...) Complete gradient CSS rule
box_shadow(*shadows) Generate box-shadow value
box_shadow_css(selector, *shadows) Complete box-shadow CSS rule
text_shadow(x, y, blur, color) Generate text-shadow value
text_shadow_css(selector, ...) Complete text-shadow CSS rule
border_radius(...) Generate border-radius value
border_radius_css(selector, ...) Complete border-radius CSS rule
flexbox(...) Generate flexbox properties
flexbox_css(selector, ...) Complete flexbox CSS rule
grid(template) Generate grid properties
grid_css(selector, template) Complete grid CSS rule
animation(name, duration, timing) Generate animation shorthand
animation_css(selector, name, ...) Complete animation CSS rule
keyframes(name, frames) Generate @keyframes rule
transform(...) Generate transform value
transform_css(selector, ...) Complete transform CSS rule
css_filter(...) Generate filter value
filter_css(selector, ...) Complete filter CSS rule
transition(prop, duration, timing) Generate transition value
transition_css(selector, ...) Complete transition CSS rule
media_query(breakpoint, css, type) Wrap CSS in @media rule
typography(...) Generate typography properties
typography_css(selector, ...) Complete typography CSS rule
aspect_ratio(ratio) Generate aspect-ratio value
aspect_ratio_css(selector, ratio) Complete aspect-ratio CSS rule
clamp(min, preferred, max) Generate clamp() value
clamp_font_css(selector, ...) Complete fluid font-size CSS rule
glassmorphism(...) Generate glassmorphism properties
glassmorphism_css(selector, ...) Complete glassmorphism CSS rule

Types

Type Fields
ColorStop color: str, position: str
Shadow x, y, blur, spread, color, inset
GridTemplate columns, rows, gap, auto_flow
Keyframe selector: str, properties: dict[str, str]

Learn More About CSS

Peasy Developer Tools

Package PyPI Description
peasytext PyPI Text analysis — readability, sentiment, keywords
peasy-pdf PyPI PDF processing — extract, merge, split, metadata
peasy-image PyPI Image ops — resize, crop, filter, watermark
peasy-css PyPI CSS generation — gradients, shadows, flexbox, grid

Part of the Peasy developer tools ecosystem — PeasyCSS · PeasyText · PeasyPDF · PeasyImage

License

MIT

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

peasy_css-0.1.0.tar.gz (78.3 kB view details)

Uploaded Source

Built Distribution

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

peasy_css-0.1.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file peasy_css-0.1.0.tar.gz.

File metadata

  • Download URL: peasy_css-0.1.0.tar.gz
  • Upload date:
  • Size: 78.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for peasy_css-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c434a980cd74fec4fd58690e8a7512bda3402e7442452aa6637884700a43084e
MD5 440fc090e0694a5fc1096c0617c0bf20
BLAKE2b-256 a84791f9b57411107fae118d564de07610a35296b9eb89e4d31c7e26c47a3f14

See more details on using hashes here.

File details

Details for the file peasy_css-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: peasy_css-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for peasy_css-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32d30e773846d00ef3767fa8424538e9b59d7fd0cd51ac82c10fddfeb6235607
MD5 1a51fe56cc92f07d81f5c91e01f7defe
BLAKE2b-256 66ab05f29eb6246b6945e9e90eb5b31c2e0535535cb606f73ca4499e461b1afe

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