Skip to content

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

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

Merged
merged 2 commits into from
Jul 11, 2025

Conversation

kzroo
Copy link
Contributor

@kzroo kzroo commented Jul 11, 2025

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