Skip to content
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

Please add a "copy" button in this picker #129

Open
AryanJaiswal opened this issue Jul 26, 2019 · 3 comments
Open

Please add a "copy" button in this picker #129

AryanJaiswal opened this issue Jul 26, 2019 · 3 comments
Labels
feature request New feature requested

Comments

@AryanJaiswal
Copy link

Requesting a feature to copy the code in the input box

@AryanJaiswal
Copy link
Author

And also how to change the box size that should be clicked to open the picker

@simonwep
Copy link
Owner

You can style .pcr-button or use useAsButton to create your own :)

@simonwep simonwep added the feature request New feature requested label Jul 26, 2019
@simonwep simonwep added the in consideration Feature, improvement or enhancement is in consideration label Aug 26, 2019
@simonwep simonwep removed the in consideration Feature, improvement or enhancement is in consideration label Dec 10, 2020
@saeed74
Copy link

saeed74 commented Mar 8, 2021

I changed save btn to copy with listeners:

    pickr.on('save', (color, instance) => {

        var data = $('.pcr-result').val();
        copyToClipboard(data);

    });

copyToClipboard function:

function copyToClipboard(text) {
    var $temp = $("<input>");
    $("body").append($temp);
    $temp.val(text).select();
    document.execCommand("copy");
    $temp.remove();
}

you can also change text of SAVE to COPY if you want:

const pickr = Pickr.create({
    el: '.mepickr',
    theme: 'nano',
    swatches: [
        '#F44336',
        '#F9C70E',
        '#2AB3D1',
        '#0C32F5',
        '#D11AFF',
        '#1FD4C3',
        '#15C083'
    ],
    components: {
        preview: true,
        opacity: true,
        hue: true,
        interaction: {
            hex: true,
            rgba: false,
            hsla: false,
            hsva: false,
            cmyk: false,
            input: true,
            clear: false,
            save: true
        }
    },
    i18n: {
       'btn:save': 'Copy'
    }
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature requested
Projects
None yet
Development

No branches or pull requests

3 participants