Skip to content

feat(themes): Add shadcn theme #6322

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

Open
wants to merge 19 commits into
base: main
Choose a base branch
from

Conversation

alexcarpenter
Copy link
Member

@alexcarpenter alexcarpenter commented Jul 15, 2025

Description

import { shadcn } from '@clerk/themes'

<ClerkProvider
  appearance={{
    baseTheme: shadcn
  }}
/>

To support this theme, we've added the ability to specify a cssLayerName within a theme - #6344

Resolves USER-2373

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 the "shadcn" theme, now available for use in the themes package.
  • Improvements

    • Navigation buttons now have updated inactive state colors and improved visual consistency.
    • Appearance options are now preprocessed for better theme configuration, including extraction of CSS layer names.
  • Bug Fixes

    • Ensured that CSS layer names are correctly managed and do not remain in theme definitions when not needed.
  • Tests

    • Added comprehensive tests for appearance processing to ensure correct handling of theme properties.
  • Documentation

    • Added a changeset file documenting the minor update for the new theme.

Copy link

changeset-bot bot commented Jul 15, 2025

🦋 Changeset detected

Latest commit: 72eea01

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

This PR includes changesets to release 1 package
Name Type
@clerk/themes Minor

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 Jul 15, 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 18, 2025 7:47pm

Copy link
Member

@nikosdouvlis nikosdouvlis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

@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.9-snapshot.v20250716141613
@clerk/astro 2.10.6-snapshot.v20250716141613
@clerk/backend 2.4.4-snapshot.v20250716141613
@clerk/chrome-extension 2.5.7-snapshot.v20250716141613
@clerk/clerk-js 5.73.1-snapshot.v20250716141613
@clerk/elements 0.23.41-snapshot.v20250716141613
@clerk/clerk-expo 2.14.6-snapshot.v20250716141613
@clerk/expo-passkeys 0.3.18-snapshot.v20250716141613
@clerk/express 1.7.8-snapshot.v20250716141613
@clerk/fastify 2.4.8-snapshot.v20250716141613
@clerk/localizations 3.19.1-snapshot.v20250716141613
@clerk/nextjs 6.25.2-snapshot.v20250716141613
@clerk/nuxt 1.7.9-snapshot.v20250716141613
@clerk/clerk-react 5.35.1-snapshot.v20250716141613
@clerk/react-router 1.8.2-snapshot.v20250716141613
@clerk/remix 4.10.2-snapshot.v20250716141613
@clerk/shared 3.12.2-snapshot.v20250716141613
@clerk/tanstack-react-start 0.20.2-snapshot.v20250716141613
@clerk/testing 1.10.2-snapshot.v20250716141613
@clerk/themes 2.4.0-snapshot.v20250716141613
@clerk/types 4.66.1-snapshot.v20250716141613
@clerk/vue 1.8.16-snapshot.v20250716141613

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

npm i @clerk/agent-toolkit@0.1.9-snapshot.v20250716141613 --save-exact

@clerk/astro

npm i @clerk/astro@2.10.6-snapshot.v20250716141613 --save-exact

@clerk/backend

npm i @clerk/backend@2.4.4-snapshot.v20250716141613 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.5.7-snapshot.v20250716141613 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.73.1-snapshot.v20250716141613 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.41-snapshot.v20250716141613 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.14.6-snapshot.v20250716141613 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.3.18-snapshot.v20250716141613 --save-exact

@clerk/express

npm i @clerk/express@1.7.8-snapshot.v20250716141613 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.4.8-snapshot.v20250716141613 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.19.1-snapshot.v20250716141613 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.25.2-snapshot.v20250716141613 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.7.9-snapshot.v20250716141613 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.35.1-snapshot.v20250716141613 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.8.2-snapshot.v20250716141613 --save-exact

@clerk/remix

npm i @clerk/remix@4.10.2-snapshot.v20250716141613 --save-exact

@clerk/shared

npm i @clerk/shared@3.12.2-snapshot.v20250716141613 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.20.2-snapshot.v20250716141613 --save-exact

@clerk/testing

npm i @clerk/testing@1.10.2-snapshot.v20250716141613 --save-exact

@clerk/themes

npm i @clerk/themes@2.4.0-snapshot.v20250716141613 --save-exact

@clerk/types

npm i @clerk/types@4.66.1-snapshot.v20250716141613 --save-exact

@clerk/vue

npm i @clerk/vue@1.8.16-snapshot.v20250716141613 --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.11-snapshot.v20250716183151
@clerk/astro 2.10.8-snapshot.v20250716183151
@clerk/backend 2.5.0-snapshot.v20250716183151
@clerk/chrome-extension 2.5.9-snapshot.v20250716183151
@clerk/clerk-js 5.73.3-snapshot.v20250716183151
@clerk/elements 0.23.43-snapshot.v20250716183151
@clerk/clerk-expo 2.14.8-snapshot.v20250716183151
@clerk/expo-passkeys 0.3.20-snapshot.v20250716183151
@clerk/express 1.7.10-snapshot.v20250716183151
@clerk/fastify 2.4.10-snapshot.v20250716183151
@clerk/localizations 3.19.3-snapshot.v20250716183151
@clerk/nextjs 6.25.4-snapshot.v20250716183151
@clerk/nuxt 1.7.11-snapshot.v20250716183151
@clerk/clerk-react 5.35.3-snapshot.v20250716183151
@clerk/react-router 1.8.4-snapshot.v20250716183151
@clerk/remix 4.10.4-snapshot.v20250716183151
@clerk/shared 3.12.4-snapshot.v20250716183151
@clerk/tanstack-react-start 0.20.4-snapshot.v20250716183151
@clerk/testing 1.10.4-snapshot.v20250716183151
@clerk/themes 2.4.0-snapshot.v20250716183151
@clerk/types 4.67.1-snapshot.v20250716183151
@clerk/vue 1.8.18-snapshot.v20250716183151

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

npm i @clerk/agent-toolkit@0.1.11-snapshot.v20250716183151 --save-exact

@clerk/astro

npm i @clerk/astro@2.10.8-snapshot.v20250716183151 --save-exact

@clerk/backend

npm i @clerk/backend@2.5.0-snapshot.v20250716183151 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.5.9-snapshot.v20250716183151 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.73.3-snapshot.v20250716183151 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.43-snapshot.v20250716183151 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.14.8-snapshot.v20250716183151 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.3.20-snapshot.v20250716183151 --save-exact

@clerk/express

npm i @clerk/express@1.7.10-snapshot.v20250716183151 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.4.10-snapshot.v20250716183151 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.19.3-snapshot.v20250716183151 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.25.4-snapshot.v20250716183151 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.7.11-snapshot.v20250716183151 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.35.3-snapshot.v20250716183151 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.8.4-snapshot.v20250716183151 --save-exact

@clerk/remix

npm i @clerk/remix@4.10.4-snapshot.v20250716183151 --save-exact

@clerk/shared

npm i @clerk/shared@3.12.4-snapshot.v20250716183151 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.20.4-snapshot.v20250716183151 --save-exact

@clerk/testing

npm i @clerk/testing@1.10.4-snapshot.v20250716183151 --save-exact

@clerk/themes

npm i @clerk/themes@2.4.0-snapshot.v20250716183151 --save-exact

@clerk/types

npm i @clerk/types@4.67.1-snapshot.v20250716183151 --save-exact

@clerk/vue

npm i @clerk/vue@1.8.18-snapshot.v20250716183151 --save-exact

@@ -279,14 +279,13 @@ const NavButton = (props: NavButtonProps) => {
gap: t.space.$3,
justifyContent: 'flex-start',
backgroundColor: isActive ? t.colors.$neutralAlpha100 : undefined,
color: isActive ? t.colors.$primary500 : t.colors.$neutralAlpha600,
color: isActive ? t.colors.$primary500 : t.colors.$colorMutedForeground,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change I think we should make. We have a secondary text color that should be used over the neutralAlpha + opacity which currently doesn't have enough contrast in my opinion. This update looks much better in practice.

BEFORE AFTER
Screenshot 2025-07-16 at 2 50 40 PM Screenshot 2025-07-16 at 2 50 04 PM

@alexcarpenter alexcarpenter marked this pull request as ready for review July 16, 2025 18:51
Copy link
Contributor

coderabbitai bot commented Jul 16, 2025

📝 Walkthrough

Walkthrough

A new theme named "shadcn" was introduced and exported from the @clerk/themes package, mapping Clerk theme variables to shadcn CSS custom properties. The BaseTheme type was updated to include an optional cssLayerName property. A utility function, processCssLayerNameExtraction, was added to extract and consolidate cssLayerName from base themes into the top-level appearance object, with corresponding tests. The Clerk class initialization was updated to use this utility for appearance processing. Minor visual adjustments were made to the NavButton component, and related exports were updated for utility and theme modules.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 80671d6 and 21e4e6d.

📒 Files selected for processing (2)
  • packages/clerk-js/src/core/clerk.ts (2 hunks)
  • packages/clerk-js/src/utils/__tests__/appearance.spec.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/clerk-js/src/utils/tests/appearance.spec.ts
  • packages/clerk-js/src/core/clerk.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (23)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Static analysis
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Analyze (javascript-typescript)

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

pkg-pr-new bot commented Jul 16, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6322

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6322

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6322

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6322

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6322

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6322

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6322

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6322

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6322

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6322

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6322

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6322

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6322

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6322

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6322

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6322

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6322

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6322

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6322

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6322

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6322

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6322

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6322

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6322

commit: 72eea01

@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.11-snapshot.v20250717132356
@clerk/astro 2.10.8-snapshot.v20250717132356
@clerk/backend 2.5.0-snapshot.v20250717132356
@clerk/chrome-extension 2.5.9-snapshot.v20250717132356
@clerk/clerk-js 5.73.3-snapshot.v20250717132356
@clerk/elements 0.23.43-snapshot.v20250717132356
@clerk/clerk-expo 2.14.8-snapshot.v20250717132356
@clerk/expo-passkeys 0.3.20-snapshot.v20250717132356
@clerk/express 1.7.10-snapshot.v20250717132356
@clerk/fastify 2.4.10-snapshot.v20250717132356
@clerk/localizations 3.20.0-snapshot.v20250717132356
@clerk/nextjs 6.25.4-snapshot.v20250717132356
@clerk/nuxt 1.7.11-snapshot.v20250717132356
@clerk/clerk-react 5.35.3-snapshot.v20250717132356
@clerk/react-router 1.8.4-snapshot.v20250717132356
@clerk/remix 4.10.4-snapshot.v20250717132356
@clerk/shared 3.12.4-snapshot.v20250717132356
@clerk/tanstack-react-start 0.20.4-snapshot.v20250717132356
@clerk/testing 1.10.4-snapshot.v20250717132356
@clerk/themes 2.4.0-snapshot.v20250717132356
@clerk/types 4.68.0-snapshot.v20250717132356
@clerk/vue 1.8.18-snapshot.v20250717132356

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

npm i @clerk/agent-toolkit@0.1.11-snapshot.v20250717132356 --save-exact

@clerk/astro

npm i @clerk/astro@2.10.8-snapshot.v20250717132356 --save-exact

@clerk/backend

npm i @clerk/backend@2.5.0-snapshot.v20250717132356 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.5.9-snapshot.v20250717132356 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.73.3-snapshot.v20250717132356 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.43-snapshot.v20250717132356 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.14.8-snapshot.v20250717132356 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.3.20-snapshot.v20250717132356 --save-exact

@clerk/express

npm i @clerk/express@1.7.10-snapshot.v20250717132356 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.4.10-snapshot.v20250717132356 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.20.0-snapshot.v20250717132356 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.25.4-snapshot.v20250717132356 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.7.11-snapshot.v20250717132356 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.35.3-snapshot.v20250717132356 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.8.4-snapshot.v20250717132356 --save-exact

@clerk/remix

npm i @clerk/remix@4.10.4-snapshot.v20250717132356 --save-exact

@clerk/shared

npm i @clerk/shared@3.12.4-snapshot.v20250717132356 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.20.4-snapshot.v20250717132356 --save-exact

@clerk/testing

npm i @clerk/testing@1.10.4-snapshot.v20250717132356 --save-exact

@clerk/themes

npm i @clerk/themes@2.4.0-snapshot.v20250717132356 --save-exact

@clerk/types

npm i @clerk/types@4.68.0-snapshot.v20250717132356 --save-exact

@clerk/vue

npm i @clerk/vue@1.8.18-snapshot.v20250717132356 --save-exact

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
packages/clerk-js/src/utils/appearance.ts (2)

16-20: Minor optimization opportunity in array processing.

The current implementation uses forEach to find the first cssLayerName, but this could be more efficient using find():

-    appearance.baseTheme.forEach((theme: BaseTheme) => {
-      if (!cssLayerNameFromBaseTheme && theme.cssLayerName) {
-        cssLayerNameFromBaseTheme = theme.cssLayerName;
-      }
-    });
+    const themeWithCssLayerName = appearance.baseTheme.find((theme: BaseTheme) => theme.cssLayerName);
+    cssLayerNameFromBaseTheme = themeWithCssLayerName?.cssLayerName;

This approach is more idiomatic and stops at the first match instead of continuing through the entire array.


44-48: Redundant variable assignment in single theme handling.

The variable cssLayerNameFromSingleTheme is unnecessary since we can directly use singleTheme.cssLayerName:

-    let cssLayerNameFromSingleTheme: string | undefined;
-
-    if (singleTheme.cssLayerName) {
-      cssLayerNameFromSingleTheme = singleTheme.cssLayerName;
-    }
+    const cssLayerNameFromSingleTheme = singleTheme.cssLayerName;

This simplification reduces code complexity while maintaining the same functionality.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ed4f6e6 and f6cc7d0.

📒 Files selected for processing (7)
  • packages/clerk-js/src/core/clerk.ts (2 hunks)
  • packages/clerk-js/src/utils/__tests__/appearance.spec.ts (1 hunks)
  • packages/clerk-js/src/utils/appearance.ts (1 hunks)
  • packages/clerk-js/src/utils/index.ts (1 hunks)
  • packages/themes/src/createTheme.ts (1 hunks)
  • packages/themes/src/themes/shadcn.ts (1 hunks)
  • packages/types/src/appearance.ts (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • packages/clerk-js/src/utils/index.ts
  • packages/themes/src/createTheme.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/themes/src/themes/shadcn.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*

Instructions used from:

Sources:
⚙️ CodeRabbit Configuration File

🧬 Code Graph Analysis (3)
packages/clerk-js/src/utils/__tests__/appearance.spec.ts (2)
packages/types/src/appearance.ts (2)
  • Appearance (969-1031)
  • BaseTheme (809-809)
packages/clerk-js/src/utils/appearance.ts (1)
  • processCssLayerNameExtraction (7-67)
packages/clerk-js/src/utils/appearance.ts (1)
packages/types/src/appearance.ts (2)
  • Appearance (969-1031)
  • BaseTheme (809-809)
packages/clerk-js/src/core/clerk.ts (1)
packages/clerk-js/src/utils/appearance.ts (1)
  • processCssLayerNameExtraction (7-67)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (10)
packages/types/src/appearance.ts (1)

809-809: LGTM! Clean type extension for CSS layer support.

The intersection type correctly extends BaseTheme to include the optional cssLayerName property, enabling the new CSS layer functionality while maintaining backward compatibility.

packages/clerk-js/src/core/clerk.ts (1)

115-115: LGTM: Import statement is correct

The import of processCssLayerNameExtraction is properly added and follows the existing import pattern.

packages/clerk-js/src/utils/__tests__/appearance.spec.ts (8)

1-5: LGTM: Test file setup is correct

The imports and test setup are properly structured.


7-23: LGTM: Comprehensive test for single baseTheme extraction

The test properly validates that cssLayerName is extracted from a single baseTheme and moved to the appearance level while preserving other properties.


25-40: LGTM: Precedence test validates correct behavior

The test correctly verifies that appearance-level cssLayerName takes precedence over baseTheme-level values, which is the expected behavior.


42-72: LGTM: Array baseTheme test is comprehensive

The test properly validates the array handling logic, including extraction of the first cssLayerName found and removal from all array items.


74-97: LGTM: Array precedence test validates expected behavior

The test correctly verifies that appearance-level cssLayerName takes precedence even when multiple baseThemes have cssLayerName properties.


99-137: LGTM: Edge cases are properly tested

The tests correctly validate scenarios where no cssLayerName is present in baseThemes, ensuring the function handles these cases gracefully.


139-148: LGTM: No baseTheme test validates edge case

The test correctly verifies that the function handles the case where no baseTheme is provided while preserving existing appearance properties.


150-173: LGTM: Final tests complete comprehensive coverage

The tests for undefined input and property preservation ensure the function is robust and doesn't interfere with other appearance properties.

@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.11-snapshot.v20250718154534
@clerk/astro 2.10.8-snapshot.v20250718154534
@clerk/backend 2.5.0-snapshot.v20250718154534
@clerk/chrome-extension 2.5.9-snapshot.v20250718154534
@clerk/clerk-js 5.73.3-snapshot.v20250718154534
@clerk/elements 0.23.43-snapshot.v20250718154534
@clerk/clerk-expo 2.14.8-snapshot.v20250718154534
@clerk/expo-passkeys 0.3.20-snapshot.v20250718154534
@clerk/express 1.7.10-snapshot.v20250718154534
@clerk/fastify 2.4.10-snapshot.v20250718154534
@clerk/localizations 3.20.0-snapshot.v20250718154534
@clerk/nextjs 6.25.4-snapshot.v20250718154534
@clerk/nuxt 1.7.11-snapshot.v20250718154534
@clerk/clerk-react 5.35.3-snapshot.v20250718154534
@clerk/react-router 1.8.4-snapshot.v20250718154534
@clerk/remix 4.10.4-snapshot.v20250718154534
@clerk/shared 3.12.4-snapshot.v20250718154534
@clerk/tanstack-react-start 0.20.4-snapshot.v20250718154534
@clerk/testing 1.10.4-snapshot.v20250718154534
@clerk/themes 2.4.0-snapshot.v20250718154534
@clerk/types 4.68.0-snapshot.v20250718154534
@clerk/vue 1.8.18-snapshot.v20250718154534

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

npm i @clerk/agent-toolkit@0.1.11-snapshot.v20250718154534 --save-exact

@clerk/astro

npm i @clerk/astro@2.10.8-snapshot.v20250718154534 --save-exact

@clerk/backend

npm i @clerk/backend@2.5.0-snapshot.v20250718154534 --save-exact

@clerk/chrome-extension

npm i @clerk/chrome-extension@2.5.9-snapshot.v20250718154534 --save-exact

@clerk/clerk-js

npm i @clerk/clerk-js@5.73.3-snapshot.v20250718154534 --save-exact

@clerk/elements

npm i @clerk/elements@0.23.43-snapshot.v20250718154534 --save-exact

@clerk/clerk-expo

npm i @clerk/clerk-expo@2.14.8-snapshot.v20250718154534 --save-exact

@clerk/expo-passkeys

npm i @clerk/expo-passkeys@0.3.20-snapshot.v20250718154534 --save-exact

@clerk/express

npm i @clerk/express@1.7.10-snapshot.v20250718154534 --save-exact

@clerk/fastify

npm i @clerk/fastify@2.4.10-snapshot.v20250718154534 --save-exact

@clerk/localizations

npm i @clerk/localizations@3.20.0-snapshot.v20250718154534 --save-exact

@clerk/nextjs

npm i @clerk/nextjs@6.25.4-snapshot.v20250718154534 --save-exact

@clerk/nuxt

npm i @clerk/nuxt@1.7.11-snapshot.v20250718154534 --save-exact

@clerk/clerk-react

npm i @clerk/clerk-react@5.35.3-snapshot.v20250718154534 --save-exact

@clerk/react-router

npm i @clerk/react-router@1.8.4-snapshot.v20250718154534 --save-exact

@clerk/remix

npm i @clerk/remix@4.10.4-snapshot.v20250718154534 --save-exact

@clerk/shared

npm i @clerk/shared@3.12.4-snapshot.v20250718154534 --save-exact

@clerk/tanstack-react-start

npm i @clerk/tanstack-react-start@0.20.4-snapshot.v20250718154534 --save-exact

@clerk/testing

npm i @clerk/testing@1.10.4-snapshot.v20250718154534 --save-exact

@clerk/themes

npm i @clerk/themes@2.4.0-snapshot.v20250718154534 --save-exact

@clerk/types

npm i @clerk/types@4.68.0-snapshot.v20250718154534 --save-exact

@clerk/vue

npm i @clerk/vue@1.8.18-snapshot.v20250718154534 --save-exact


import { processCssLayerNameExtraction } from '../appearance';

describe('processCssLayerNameExtraction', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Awesome that you pulled this out and made it testable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy