Home › Forums › ACF PRO › Color Picker Custom Pallete › Reply To: Color Picker Custom Pallete
Hi @toad78
For something like that, I believe using the checkbox or radio fields are the best way to achieve it. But if you still want to use the color picker field, please try the following workaround:
function my_acf_collor_pallete_script() {
?>
<script type="text/javascript">
(function($){
acf.add_filter('color_picker_args', function( args, $field ){
// do something to args
args.palettes = ['#5ee8bf', '#2f353e', '#f55e4f']
console.log(args);
// return
return args;
});
})(jQuery);
</script>
<?php
}
add_action('acf/input/admin_footer', 'my_acf_collor_pallete_script');
function my_acf_collor_pallete_css() {
?>
<style>
.acf-color_picker .iris-picker.iris-border{
width: 200px !important;
height: 10px !important;
}
.acf-color_picker .wp-picker-input-wrap,
.acf-color_picker .iris-picker .iris-slider,
.acf-color_picker .iris-picker .iris-square{
display:none !important;
}
</style>
<?php
}
add_action('acf/input/admin_head', 'my_acf_collor_pallete_css');
This page should give you more idea about it: https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/.
I hope this helps 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.