TailwindTidy ๐ช๏ธโจ
TailwindTidy is a Python utility that brings structure and consistency to your Tailwind CSS classes. Say goodbye to messy, unorganized utility classes and hello to a clean, standardized ordering system.

โจ Features
- ๐ฏ Automatically organizes Tailwind CSS classes into logical categories
- ๐ Maintains consistent ordering based on best practices
- ๐งน Cleans up messy class strings
- ๐ Simple and fast processing
- ๐ฆ Easy to integrate into existing projects
- ๐ ๏ธ Customizable category patterns
๐ Installation
pip install tailwindtidy
๐ฏ Quick Start
from tailwindtidy import TailwindClassOrganizer
# Create an instance
organizer = TailwindClassOrganizer()
# Your messy Tailwind classes
messy_classes = """
hover:bg-gray-100 flex text-blue-700
justify-center mx-auto p-4 font-bold
"""
# Get organized classes
organized = organizer.organize_classes(messy_classes)
print(organized)
๐จ Class Organization
TailwindTidy organizes classes into the following categories:
- Layout -
flex
, grid
, container
, positioning
- Spacing - margins, padding, width, height
- Typography - font properties, text alignment
- Colors - text colors, background colors
- Borders - borders, rounded corners, shadows
- Effects - opacity, transforms, animations
- Interactivity - hover states, focus states, cursor
๐ ๏ธ Customization
You can customize the category patterns by extending the categories
dictionary:
organizer = TailwindClassOrganizer()
organizer.categories['custom'] = [
r'^your-custom-pattern',
r'^another-pattern'
]
๐ก Use Cases
- Maintaining consistent class ordering across a team
- Cleaning up generated Tailwind classes
- Enforcing style guide conventions
- Improving code readability
- Pre-commit hooks for consistent styling
๐ค Contributing
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature
)
- Commit your changes (
git commit -m 'Add amazing feature'
)
- Push to the branch (
git push origin feature/amazing-feature
)
- Open a Pull Request
๐ Acknowledgments
- Inspired by Tailwind CSS best practices
- Built with love for the Tailwind community
- Thanks to all contributors
Made with โค๏ธ by Praveenstein