An open API service indexing awesome lists of open source software.

https://github.com/lucafaggianelli/python-classnames

Utility to generate CSS class strings from a multitude of inputs without headaches
https://github.com/lucafaggianelli/python-classnames

classnames css css-classes html python

Last synced: 11 months ago
JSON representation

Utility to generate CSS class strings from a multitude of inputs without headaches

Awesome Lists containing this project

README

          

# Python classnames

[![pypi](https://img.shields.io/pypi/v/classnames.svg)](https://pypi.org/project/classnames/)
[![python](https://img.shields.io/pypi/pyversions/classnames.svg)](https://pypi.org/project/classnames/)
[![Build Status](https://github.com/lucafaggianelli/python-classnames/actions/workflows/dev.yml/badge.svg)](https://github.com/lucafaggianelli/python-classnames/actions/workflows/dev.yml)
[![codecov](https://codecov.io/gh/lucafaggianelli/python-classnames/branch/main/graphs/badge.svg)](https://codecov.io/github/lucafaggianelli/python-classnames)

Utility to create CSS class strings from a multitude of values without poking around with string templates and lengthy logic.

This project is a Python porting of the JS library [`classnames`](https://github.com/JedWatson/classnames)

## Show me the code!

```bash
pip install classnames
```

```python
from classnames import class_names

# render_button() -> "btn btn--red"
# render_button(rounded=True) -> "btn btn--rounded btn--red"
def render_button(rounded: bool = False, color = "red"):
class_names("btn", f"btn--{color}", {
"btn--rounded": rounded
})
```

* Documentation:
* GitHub:
* PyPI:

## Features

* TODO

## Credits

This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [waynerv/cookiecutter-pypackage](https://github.com/waynerv/cookiecutter-pypackage) project template.