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
- Host: GitHub
- URL: https://github.com/lucafaggianelli/python-classnames
- Owner: lucafaggianelli
- License: mit
- Created: 2022-11-03T16:56:24.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-04T10:38:14.000Z (about 3 years ago)
- Last Synced: 2025-01-14T11:17:45.723Z (about 1 year ago)
- Topics: classnames, css, css-classes, html, python
- Language: Python
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
# Python classnames
[](https://pypi.org/project/classnames/)
[](https://pypi.org/project/classnames/)
[](https://github.com/lucafaggianelli/python-classnames/actions/workflows/dev.yml)
[](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.