Skip to content

Conversation

@csandman
Copy link
Owner

@csandman csandman commented Mar 25, 2025

This PR changes the values that the selectedOptionColorPalette prop pulls from the theme from specific numeric color values to semantic tokens. Specifically, it is now using colorPalette.solid for the background color and colorPalette.contrast for the text color. This change does somewhat change the styling for the selected option, but it falls more in line with how the chakra theming system works.

This was originally inspired by some thoughts I had around this comment (with my original response). This doesn't actually remove the default value of blue for the selectedOptionColorPalette as suggested, but it does provide a more correct path towards doing so if that's what I end up deciding to do with it. Thanks for bringing it up @saalto-it!

This change also allows for the removal of the useColorModeValue and useColorMode hooks which were essentially copied in from the Chakra template files. Removing the reliance on those styling approaches definitely makes the new approach feel much closer to the way the color tokens were intended to be used.


One other change I implemented along with this is adding a new example for demonstrating all of the built-in selectetOptionColorPalette options that are available. This was done by updating the colorOptions array to include all of the built-in Chakra color palettes. As a bonus, I also added a custom color palette to the demo's theme to give an example for how that can be done. Here's a quick demo of all of the new styles in light and dark mode:

Screen.Recording.2025-03-24.at.10.17.02.PM.mov

@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 25, 2025

Open in Stackblitzchakra-react-select-demo

npm i https://pkg.pr.new/chakra-react-select@364

commit: cab3093

@github-actions
Copy link

github-actions bot commented Mar 25, 2025

📊 Package size report   -0.55%↓

File Before After
dist/index.js 31.0 kB -1.81%↓30.5 kB
dist/index.mjs 29.5 kB -1.87%↓28.9 kB
README.md 47.8 kB 0.6%↑48.1 kB
Total (Includes all files) 151.5 kB -0.55%↓150.7 kB
Tarball size 29.8 kB -0.98%↓29.5 kB
Unchanged files
File Size
dist/index.d.mts 19.6 kB
dist/index.d.ts 19.6 kB
LICENSE.md 1.1 kB
package.json 3.0 kB

🤖 This report was automatically generated by pkg-size-action

Comment on lines +10 to +20
{ value: "gray", label: "Gray" },
{ value: "red", label: "Red" },
{ value: "pink", label: "Pink" },
{ value: "purple", label: "Purple" },
{ value: "cyan", label: "Cyan" },
{ value: "blue", label: "Blue" },
{ value: "teal", label: "Teal" },
{ value: "green", label: "Green" },
{ value: "yellow", label: "Yellow" },
{ value: "orange", label: "Orange" },
{ value: "brand", label: "Brand" },
Copy link
Owner Author

Choose a reason for hiding this comment

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

I added the remaining default color palettes from the "Design Tokens" > "Colors" section of the docs: https://www.chakra-ui.com/docs/theming/colors

As well as one custom palette, brand.

@csandman csandman changed the title feat: Change selectedOptionColorPalette selected values feat: Change selectedOptionColorPalette values pulled from the theme Mar 25, 2025
@csandman csandman merged commit f9e87a0 into main Mar 25, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants