In my modern SharePoint, I have a simple webpart and there's scenerio where to allow user to choose colour from custom properties pane configuration.

it can be colour picker

[![enter image description here](https://i.stack.imgur.com/lSoht.png)](https://i.stack.imgur.com/lSoht.png)

or as simple as dropdown options with the background colour.

[![enter image description here](https://i.stack.imgur.com/xHT4y.png)](https://i.stack.imgur.com/xHT4y.png)

How to achieve this in client-webpart?
['https://sharepoint.stackexchange.com/questions/284228', 'https://sharepoint.stackexchange.com', 'https://sharepoint.stackexchange.com/users/92501/']
If you are implementing SPFx you can use PnP controls color picker in prperty pane to allow user select the color value. It's easier to implement than creating custom one.
[PnP Color Picker](https://pnp.github.io/sp-dev-fx-property-controls/controls/PropertyFieldColorPicker/)

[![color picker](https://i.stack.imgur.com/h25sN.png)](https://i.stack.imgur.com/h25sN.png)
[![enter image description here](https://i.stack.imgur.com/3v9s8.gif)](https://i.stack.imgur.com/3v9s8.gif)
Main code:

```
import * as React from 'react';
import * as ReactDom from 'react-dom';
import { Version } from '@microsoft/sp-core-library';
import {
  IPropertyPaneConfiguration,
  PropertyPaneTextField,
  PropertyPaneDropdown
} from '@microsoft/sp-property-pane';
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';

import * as strings from 'ReactSpfxWebPartStrings';
import ReactSpfx from './components/ReactSpfx';
import { IReactSpfxProps } from './components/IReactSpfxProps';

export interface IReactSpfxWebPartProps {
  description: string;
  bgcolor:Array<any>;
  selectedColor:string;
}

export default class ReactSpfxWebPart extends BaseClientSideWebPart<IReactSpfxWebPartProps> {

  public render(): void {
    const element: React.ReactElement<IReactSpfxProps> = React.createElement(
      ReactSpfx,
      {
        description: this.properties.description,
        bgcolor:this.properties.bgcolor,
        selectedColor:this.properties.selectedColor
      }
    );
      console.log(this.properties.bgcolor)
    ReactDom.render(element, this.domElement);
  }

  protected onDispose(): void {
    ReactDom.unmountComponentAtNode(this.domElement);
  }

  protected get dataVersion(): Version {
    return Version.parse('1.0');
  }
  protected onPropertyPaneFieldChanged(propertyPath: string, oldValue: any, newValue: any): void {
    if (propertyPath === 'BGcolor' && newValue) {
      this.properties.selectedColor=newValue;
      // push new list value
      super.onPropertyPaneFieldChanged(propertyPath, oldValue, newValue);
      // refresh the item selector control by repainting the property pane
      this.context.propertyPane.refresh();
      // re-render the web part as clearing the loading indicator removes the web part body
      this.render();      
    }
    else {
      super.onPropertyPaneFieldChanged(propertyPath, oldValue, oldValue);
    }
  }
  protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
    return {
      pages: [
        {
          header: {
            description: strings.PropertyPaneDescription,

          },
          groups: [
            {
              groupName: strings.BasicGroupName,
              groupFields: [
                PropertyPaneTextField('description', {
                  label: strings.DescriptionFieldLabel,

                }),
                PropertyPaneDropdown('BGcolor', {
                  label:'BGcolor',
                  selectedKey:"red",
                  options: this.properties.bgcolor

                })
              ]
            }
          ]
        }
      ]
    };
  }
}

```

You could get the full project here:<https://github.com/Amos-IT/SharePoint-FrameWork-Demos/tree/master/ReactSPFX>