Skip to content

Replacing the tailwind color palette as documented clobbers non-shades such as "transparent" #10

@firxworx

Description

@firxworx

Awesome work! I stumbled upon your blog post earlier today while reading into oklch + color-mix and I had to try it out!

Issue:

The README states that harmony is a "drop-in replacement for the Tailwind color palette" however it appears to be missing a few key entries like "transparent" and "current" so using it as such will clobber these utilities.

Fix/Workaround:

Add missing entries back in. In a tailwind config or preset:

// heads up if you `import *` your console will fill with deprecation warnings related to past name changes
import { inherit, current, transparent, black, white } from 'tailwindcss/colors'

// @ts-expect-error -- types not accessible w/ app's tsconfig using module esnext
import harmonyPalette from '@evilmartians/harmony/tailwind'

const config = {
  // ...
  theme: {
    colors: Object.assign(
      {
        inherit,
        current,
        transparent,
        black,
        white,
      },
      harmonyPalette,
    ),
  // ...
} satisfies Config

I'm not sure if you would prefer exporting tailwind-specific object that includes these extras or simply updating the README with the above.

Example Use-Case Impacted

nav menu with transparent background in desktop (to show parent header's backdrop blur) and a solid background when conditionally styled as a mobile menu and serving as body of a disclosure/drop-down: bg-P-nav-menu sm:bg-transparent

Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions