-
Notifications
You must be signed in to change notification settings - Fork 424
feat(ui): Add light-dark theme support
#7560
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
alexcarpenter
wants to merge
11
commits into
main
Choose a base branch
from
alexcarpenter/light-dark-theme
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bde2b68
feat(ui): Add `lightDark` theme
alexcarpenter 1bd9ba1
add changeset
alexcarpenter ac9e12a
add changeset
alexcarpenter ccd9a6c
update dark and shadcn themes
alexcarpenter 0501847
remove Webkit prefixes
alexcarpenter 17c6785
feat(ui): Make lightDark theme the default (#7571)
alexcarpenter 52dd989
Merge branch 'main' into alexcarpenter/light-dark-theme
alexcarpenter b6fa1c3
Update packages/ui/src/elements/SocialButtons.tsx
alexcarpenter 41088d9
fix type issues
alexcarpenter 3b50bc9
bump
alexcarpenter 4d84b29
Merge branch 'main' into alexcarpenter/light-dark-theme
alexcarpenter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| --- | ||
| '@clerk/ui': major | ||
| --- | ||
|
|
||
| Changes provider icon rendering from `<Image>` to `<Span>` elements to support customizable icon fills via CSS variables. | ||
|
|
||
| Provider icons for Apple, GitHub, OKX Wallet, and Vercel now use CSS `mask-image` technique with a customizable `--cl-icon-fill` CSS variable, allowing themes to control icon colors. Other provider icons (like Google) continue to render as full-color images using `background-image`. | ||
|
|
||
| You can customize the icon fill color in your theme: | ||
|
|
||
| ```tsx | ||
| import { createTheme } from '@clerk/ui/themes'; | ||
|
|
||
| const myTheme = createTheme({ | ||
| name: 'myTheme', | ||
| elements: { | ||
| providerIcon__apple: { | ||
| '--cl-icon-fill': '#000000', // Custom fill color | ||
| }, | ||
| providerIcon__github: { | ||
| '--cl-icon-fill': 'light-dark(#000000, #ffffff)', // Theme-aware fill | ||
| }, | ||
| }, | ||
| }); | ||
| ``` | ||
|
|
||
| This change enables better theme customization for monochrome provider icons while maintaining full-color support for providers that require it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| '@clerk/ui': minor | ||
| --- | ||
|
|
||
| Adds new `lightDark` theme. | ||
|
|
||
| This theme uses the `light-dark()` CSS function to automatically adapt colors based on the user's system color scheme preference, eliminating the need to manually switch between light and dark themes. | ||
|
|
||
| To enable it, within your project, you can do the following: | ||
|
|
||
| ```tsx | ||
| import { lightDark } from '@clerk/ui/themes'; | ||
| import { ClerkProvider } from '@clerk/nextjs'; | ||
|
|
||
| export default function MyApp({ Component, pageProps }: AppProps) { | ||
| return ( | ||
| <ClerkProvider appearance={{ theme: lightDark }}> | ||
| <Component {...pageProps} /> | ||
| </ClerkProvider> | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| and within your CSS file, add the following to enable automatic light/dark mode switching: | ||
|
|
||
| ```css | ||
| :root { | ||
| color-scheme: light dark; | ||
| } | ||
| ``` | ||
|
|
||
| This will automatically switch between light and dark modes based on the user's system preference. Alternatively, you can use a class-based approach: | ||
|
|
||
| ```css | ||
| :root { | ||
| color-scheme: light; | ||
| } | ||
|
|
||
| .dark { | ||
| color-scheme: dark; | ||
| } | ||
| ``` | ||
|
|
||
| **Note:** The `light-dark()` CSS function requires modern browser support (Chrome 123+, Firefox 120+, Safari 17.4+). For older browsers, consider using the `dark` theme with manual switching. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@clerk/ui': patch | ||
| --- | ||
|
|
||
| Removes provider icon filter invert from elements for both `dark` and `shadcn` themes. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.