Skip to content

Fix and features #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 5 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,15 @@ This utility ensures that when you combine multiple strings of Tailwind classes

Using pip:
```bash
pip install tailwind-merge # Assuming this is the package name you'll use
# Or if installing directly from source:
# pip install .
pip install tailwind-merge
```

## Usage

```python
from tailwind_merge import TailwindMerge # Adjust import if your file/package name differs
from tailwind_merge import TailwindMerge

# Initialize the merger (you can reuse the instance)
# Initialize
twm = TailwindMerge()

# --- Basic Merging ---
Expand All @@ -39,14 +37,6 @@ result = twm.merge("pl-4 pr-6") # Left and Right padding coexist
print(result)
# Output: "pl-4 pr-6"

result = twm.merge("p-4 pl-8") # Specific left padding overrides general padding affecting left
print(result)
# Output: "pl-8" # Or potentially "p-4 pl-8" depending on exact conflict rules for p-* vs pl-*

result = twm.merge("pl-8 p-4") # General padding defined later overrides specific padding
print(result)
# Output: "p-4"

# --- Modifier Handling ---
# Modifiers (hover:, focus:, md:, etc.) are handled correctly.
# Conflicts are resolved independently for base classes and each modifier combination.
Expand All @@ -60,13 +50,9 @@ print(result)

# --- Arbitrary Value Support ---
# Classes with arbitrary values are correctly grouped and merged.
result = twm.merge("p-[2px] p-1")
print(result)
# Output: "p-1"

result = twm.merge("m-1 m-[3vh]")
result = twm.merge("p-1", "p-[2px]")
print(result)
# Output: "m-[3vh]"
# Output: "p-[2px]"

# --- Combining Multiple Strings ---
# Pass multiple strings as arguments
Expand Down
2 changes: 1 addition & 1 deletion tailwind_merge/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .core import TailwindMerge

__version__ = "0.1.0"
__version__ = "0.3.0"
__all__ = ["TailwindMerge"]
1 change: 0 additions & 1 deletion tailwind_merge/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ def __init__(self):
('border_width_r', ['border-r', 'border-r-0', 'border-r-2', 'border-r-4', 'border-r-8']),
('border_width_b', ['border-b', 'border-b-0', 'border-b-2', 'border-b-4', 'border-b-8']),
('border_width_l', ['border-l', 'border-l-0', 'border-l-2', 'border-l-4', 'border-l-8']),
# Tailwind also has border-x, border-y but let's keep it simpler for now or add if needed
# --- End Border Width ---

# Border Color (Needs care with opacity potentially)
Expand Down