Bug: Resolve Tailwind classnames conflicts #671
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
Story
As developer using tailwind with react, we should have predictable css styling results when using conflicting Tailwind classnames.
Overview
Example:
"cursor-pointer"
tailwind class when enabled, but have"cursor-not-allowed"
class whendisabled
className={clsx("cursor-pointer", disabled && "cursor-not-allowed")}
disabled
is true, this gives us a full className string of"cursor-pointer cursor-not-allowed"
"cursor-not-allowed"
style property would override"cursor-pointer"
"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 CSSAction Items
clsx
andtailwind-merge
props.className
to override original styles.Example components: Checkbox component, Button component, CircleCard component
Resources/Instructions
Resources
The text was updated successfully, but these errors were encountered: