Repository navigation
CSS resets can no longer restyle the picker; content passed in keeps its own styles (0.2.0) - #4
Merged
Merged
Conversation
…n keeps its own styles - Only the --cs-* theme tokens stay in @layer colorshot; every other rule is unlayered and scoped to [data-colorshot] (scripts/layers.mjs splits the layer at build time and in the playground and site). Tailwind v4's preflight loaded after Colorshot used to flatten the panel, and v3's removed the stop borders. - ColorPicker children and the Vue default slot render in <div data-part="slot"> (display: contents). Element rules skip it; a plain <button> there gets the control look, a button with a class is the app's. - ColorField trigger sets its own line-height; icons are display: block, so the menu checks sit centered. - e2e: Tailwind v3/v4 preflight and global control styles in both load orders across picker states, slot styling in React and Vue. Docs: tokens are set on the picker, not a parent; part overrides load after.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
In 21st.dev's sandbox the picker rendered flat: no panel padding, square gradient stops, no borders. Colorshot's stylesheet loaded before Tailwind's, so
@layer colorshotwas declared first and lost to Tailwind v4's preflight in@layer base. Tailwind v3's preflight is unlayered and stripped the stop borders in any order. Any app that imports Colorshot's CSS before its own hits the same thing.What changed
--cs-*theme tokens stay in@layer colorshot, so app CSS still sets them without!important. Every other rule is unlayered and scoped to[data-colorshot], so element and universal resets cannot override it.packages/styles/scripts/layers.mjs(postcss) does the split at build time, and the playground and site run the same transform, so dev and tests see the published cascade. All 1,077 declarations are preserved.ColorPickerchildren and the Vue default slot render inside<div data-part="slot">(display: contents, layout unchanged). Colorshot's element rules (button/input reset, box-sizing, focus outline, transition locks) skip it via:not(:where(...)), which adds no specificity. A plain<button>there gets Colorshot's control look; a button with any class is styled by the app alone, including Tailwind utilities.display: block, so the format menu check and menu icons sit centered on their labels, as they already did in Tailwind apps.slotpart is documented.Tests
e2e/css-resets.spec.ts: Tailwind v4 and v3 preflight plus global form-control styles, loaded before and after Colorshot, across 9 picker states (solid, gradients, dark, small/inset, ColorField, search open, format menu open, focus ring). Element boxes and visible styles must not change. Also checks that token overrides and layout utilities (margin) still apply. Fails on 0.1.0's CSS in exactly the 5 broken setups.e2e/slot.spec.ts: class-styled children keep their styles (plain CSS and@layer utilities), plain buttons get the control look, Vue slot, layout and focus.styles.cssis 7,964 B gzipped, so its budget moves from 7,925 to 8,000 B.After merge
Publish 0.2.0, then upgrade Orshot (the "Pick from library" button inside the picker gets its own styling back) and update the Orshot Colorshot page copy that says tokens work on any parent.