Skip to content

react-color-compact: Pass addonBefore and addonAfter props to react-compact#183

Merged
jaywcjlove merged 2 commits into
uiwjs:mainfrom
kzroo:main
Jul 11, 2025
Merged

react-color-compact: Pass addonBefore and addonAfter props to react-compact#183
jaywcjlove merged 2 commits into
uiwjs:mainfrom
kzroo:main

Conversation

@kzroo

@kzroo kzroo commented Jul 11, 2025

Copy link
Copy Markdown
Contributor

The swatch component (react-color/packages/color-swatch), which react-color-compact uses under the hood, has addonBefore and addonAfter props, allowing you to pass custom content to the component.

For some reason, they were excluded from the react-color-compact component.
So I added them back in.

Now you can do something like this:

addonAfter={<ColorPickerCustom />}

(using tailwind:)

export default function ColorPickerCustom() {
    return (
        <div tabIndex={0}
            className="bg-linear-to-br/decreasing from-violet-700 via-lime-300 to-violet-700"
            style={{
                borderRadius: '2px',
                height: '1.25rem',
                width: '1.25rem',
                display: 'flex',
                alignItems: 'center',
                justifyContent: 'center',
                cursor: 'pointer',
                margin: '2px',
                border: '1px solid var(--color-border)',
                position: 'relative',
                outline: 'none',
            }} />
    );
}
Screenshot 2025-07-11 092410

I also added a className to the wrapper div around the editable input (prefixCls-input-wrapper, which defaults to w-color-compact-input-wrapper), so you can override the styles in your css. (By default the wrapper has a margin on it, so now you can change that.)

@jaywcjlove jaywcjlove merged commit b76b9d0 into uiwjs:main Jul 11, 2025
1 check passed
github-actions Bot pushed a commit that referenced this pull request Jul 11, 2025
…compact (#183)

* pass addonBefore and addonAfter props to react-compact

* react-color-compact: add className for editable input b76b9d0
jaywcjlove added a commit that referenced this pull request Jul 11, 2025
github-actions Bot pushed a commit that referenced this pull request Jul 11, 2025
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.

2 participants