Skip to content

Conversation

alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Jun 24, 2025

🎨 Add Modern CSS Color-Mix Utilities

Resolves USER-2201

Overview

This PR introduces modern CSS color manipulation utilities that leverage native browser features like color-mix() and relative color syntax when supported, while maintaining backward compatibility with legacy HSLA-based color manipulation.

What's New

Progressive Enhancement Architecture

  • CSS Support Detection: Detects browser support for modern CSS color features
  • Graceful Fallback: Uses modern CSS when available, falls back to legacy JavaScript manipulation
  • Consistent API: Same function signatures work regardless of browser support

Modern CSS Features

  • color-mix() Support: Leverages native CSS color mixing
  • Relative Color Syntax: Uses hsl(from color h s l) syntax when supported
  • Alpha Transparency: Modern color-mix(in srgb, transparent, color X%) for opacity

CSS Variable Support

This enhancement enables CSS custom property support within the appearance.variables object:

appearance: {
  variables: {
    colorPrimary: 'var(--brand-color)',
    colorDanger: 'var(--error-color, #ef4444)',
    colorNeutral: 'var(--neutral, black)'
  }
}

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Summary by CodeRabbit

  • New Features

    • Introduced modern CSS color manipulation utilities with progressive enhancement and automatic fallback for older browsers.
    • Added support for CSS variables in appearance customization, enabling advanced theming options.
    • Enhanced Stripe appearance customization by dynamically resolving computed CSS styles.
  • Bug Fixes

    • Improved compatibility and fallback handling for color customization in environments lacking modern CSS support.
  • Refactor

    • Updated styling across components to use CSS calc() for negative spacing, ensuring more robust and readable CSS.
  • Documentation

    • Added comprehensive documentation for the new color utilities.
  • Tests

    • Introduced extensive test coverage for color utilities, CSS variable handling, and browser feature detection.
  • Chores

    • Cleaned up obsolete utilities and tests, consolidating and modernizing color-related code.

Copy link

changeset-bot bot commented Jun 24, 2025

🦋 Changeset detected

Latest commit: a84db2d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@clerk/clerk-js Minor
@clerk/chrome-extension Patch
@clerk/clerk-expo Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Jun 24, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 7, 2025 5:35pm

- Added custom appearance variables in app.ts for improved styling.
- Introduced a new CSS variable for brand color in template.html.
- Removed unused simpleColorMix function from color utilities in utils.ts.
@alexcarpenter
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @alexcarpenter - the snapshot version command generated the following package versions:

Package Version
@clerk/clerk-expo 2.14.0-snapshot.v20250625145444

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

…hub.com:clerk/javascript into alexcarpenter/user-2201-add-color-mix-utilities
@alexcarpenter
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @alexcarpenter - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.1.5-snapshot.v20250703142444
@clerk/astro 2.10.2-snapshot.v20250703142444
@clerk/backend 2.4.0-snapshot.v20250703142444
@clerk/chrome-extension 2.5.3-snapshot.v20250703142444
@clerk/clerk-js 5.70.0-snapshot.v20250703142444
@clerk/elements 0.23.37-snapshot.v20250703142444
@clerk/clerk-expo 2.14.2-snapshot.v20250703142444
@clerk/expo-passkeys 0.3.14-snapshot.v20250703142444
@clerk/express 1.7.4-snapshot.v20250703142444
@clerk/fastify 2.4.4-snapshot.v20250703142444
@clerk/localizations 3.17.3-snapshot.v20250703142444
@clerk/nextjs 6.23.3-snapshot.v20250703142444
@clerk/nuxt 1.7.5-snapshot.v20250703142444
@clerk/clerk-react 5.32.4-snapshot.v20250703142444
@clerk/react-router 1.6.4-snapshot.v20250703142444
@clerk/remix 4.8.5-snapshot.v20250703142444
@clerk/shared 3.10.2-snapshot.v20250703142444
@clerk/tanstack-react-start 0.18.3-snapshot.v20250703142444
@clerk/testing 1.9.2-snapshot.v20250703142444
@clerk/themes 2.2.54-snapshot.v20250703142444
@clerk/types 4.63.0-snapshot.v20250703142444
@clerk/vue 1.8.12-snapshot.v20250703142444

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-react-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@alexcarpenter
Copy link
Member Author

!snapshot

@clerk-cookie
Copy link
Collaborator

Hey @alexcarpenter - the snapshot version command generated the following package versions:

Package Version
@clerk/agent-toolkit 0.1.6-snapshot.v20250707175819
@clerk/astro 2.10.3-snapshot.v20250707175819
@clerk/backend 2.4.1-snapshot.v20250707175819
@clerk/chrome-extension 2.5.4-snapshot.v20250707175819
@clerk/clerk-js 5.71.0-snapshot.v20250707175819
@clerk/elements 0.23.38-snapshot.v20250707175819
@clerk/clerk-expo 2.14.3-snapshot.v20250707175819
@clerk/expo-passkeys 0.3.15-snapshot.v20250707175819
@clerk/express 1.7.5-snapshot.v20250707175819
@clerk/fastify 2.4.5-snapshot.v20250707175819
@clerk/localizations 3.17.4-snapshot.v20250707175819
@clerk/nextjs 6.24.0-snapshot.v20250707175819
@clerk/nuxt 1.7.6-snapshot.v20250707175819
@clerk/clerk-react 5.33.0-snapshot.v20250707175819
@clerk/react-router 1.7.0-snapshot.v20250707175819
@clerk/remix 4.9.0-snapshot.v20250707175819
@clerk/shared 3.11.0-snapshot.v20250707175819
@clerk/tanstack-react-start 0.19.0-snapshot.v20250707175819
@clerk/testing 1.9.3-snapshot.v20250707175819
@clerk/themes 2.2.55-snapshot.v20250707175819
@clerk/types 4.64.0-snapshot.v20250707175819
@clerk/vue 1.8.13-snapshot.v20250707175819

Tip: Use the snippet copy button below to quickly install the required packages.
@clerk/agent-toolkit

npm i @clerk/[email protected] --save-exact

@clerk/astro

npm i @clerk/[email protected] --save-exact

@clerk/backend

npm i @clerk/[email protected] --save-exact

@clerk/chrome-extension

npm i @clerk/[email protected] --save-exact

@clerk/clerk-js

npm i @clerk/[email protected] --save-exact

@clerk/elements

npm i @clerk/[email protected] --save-exact

@clerk/clerk-expo

npm i @clerk/[email protected] --save-exact

@clerk/expo-passkeys

npm i @clerk/[email protected] --save-exact

@clerk/express

npm i @clerk/[email protected] --save-exact

@clerk/fastify

npm i @clerk/[email protected] --save-exact

@clerk/localizations

npm i @clerk/[email protected] --save-exact

@clerk/nextjs

npm i @clerk/[email protected] --save-exact

@clerk/nuxt

npm i @clerk/[email protected] --save-exact

@clerk/clerk-react

npm i @clerk/[email protected] --save-exact

@clerk/react-router

npm i @clerk/[email protected] --save-exact

@clerk/remix

npm i @clerk/[email protected] --save-exact

@clerk/shared

npm i @clerk/[email protected] --save-exact

@clerk/tanstack-react-start

npm i @clerk/[email protected] --save-exact

@clerk/testing

npm i @clerk/[email protected] --save-exact

@clerk/themes

npm i @clerk/[email protected] --save-exact

@clerk/types

npm i @clerk/[email protected] --save-exact

@clerk/vue

npm i @clerk/[email protected] --save-exact

@alexcarpenter alexcarpenter merged commit 22be9f0 into main Jul 8, 2025
37 checks passed
@alexcarpenter alexcarpenter deleted the alexcarpenter/user-2201-add-color-mix-utilities branch July 8, 2025 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants