Skip to content

Bug: Resolve Tailwind classnames conflicts #671

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

Closed
2 tasks done
LoTerence opened this issue Apr 13, 2025 · 1 comment · Fixed by #679
Closed
2 tasks done

Bug: Resolve Tailwind classnames conflicts #671

LoTerence opened this issue Apr 13, 2025 · 1 comment · Fixed by #679
Assignees
Labels
bug Something isn't working feature: Design System good first issue Good for newcomers javascript Pull requests that update Javascript code P2: Med-high Medium-high priority PBV: dev all issues for engineering roles (devops, backend, frontend, db) role: frontend Pertains to frontend tasks size: 1pt Can be done in 4-6 hours
Milestone

Comments

@LoTerence
Copy link
Member

LoTerence commented Apr 13, 2025

Story

As developer using tailwind with react, we should have predictable css styling results when using conflicting Tailwind classnames.

Overview

Example:

  • The Checkbox component should have "cursor-pointer" tailwind class when enabled, but have "cursor-not-allowed" class when disabled
  • eg. className={clsx("cursor-pointer", disabled && "cursor-not-allowed")}
  • when disabled is true, this gives us a full className string of "cursor-pointer cursor-not-allowed"
  • The expected result is that "cursor-not-allowed" style property would override "cursor-pointer"
  • The actual result is that no matter what order you put the class names in, "cursor-pointer" overrides "cursor-not-allowed". This means it will always be cursor-pointer even when the input is disabled.

This bug would also cause issues when trying to override component styles with className={clsx("original-tw-classnames", props.className)}.

See my comment about it here: Checkbox Component with Tailwind by bzzz-coding · Pull Request #654 · hackforla/CivicTechJobs · GitHub

The solution is to implement tailwind-merge package to resolve conflicting tailwind classnames like so: Understanding the Differences Between clsx, classnames, and twMerge in React and Tailwind CSS

Action Items

  • Create a classname combiner function using clsx and tailwind-merge
  • Implement this new combiner function in every component that passes down props.className to override original styles.

Example components: Checkbox component, Button component, CircleCard component

Resources/Instructions

Resources

@github-project-automation github-project-automation bot moved this to 🆕 New Issue Approval in P: CTJ: Project Board Apr 13, 2025
@LoTerence LoTerence added bug Something isn't working good first issue Good for newcomers role: frontend Pertains to frontend tasks size: 1pt Can be done in 4-6 hours feature: Design System P2: Med-high Medium-high priority javascript Pull requests that update Javascript code PBV: dev all issues for engineering roles (devops, backend, frontend, db) labels Apr 13, 2025
@LoTerence LoTerence added this to the 07 - MVP 1 milestone Apr 13, 2025
@LoTerence LoTerence moved this from 🆕 New Issue Approval to 📋 Prioritized Backlog in P: CTJ: Project Board Apr 13, 2025
@0-GoldenThunder
Copy link

I'm working at this bug. Thank you

0-GoldenThunder added a commit to 0-GoldenThunder/CivicTechJobs that referenced this issue Apr 15, 2025
@bzzz-coding bzzz-coding moved this from 📋 Prioritized Backlog to ❔ For Review / Feedback Needed in P: CTJ: Project Board Apr 21, 2025
@bzzz-coding bzzz-coding moved this from ❔ For Review / Feedback Needed to 🏗 In progress in P: CTJ: Project Board Apr 21, 2025
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in P: CTJ: Project Board Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working feature: Design System good first issue Good for newcomers javascript Pull requests that update Javascript code P2: Med-high Medium-high priority PBV: dev all issues for engineering roles (devops, backend, frontend, db) role: frontend Pertains to frontend tasks size: 1pt Can be done in 4-6 hours
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants