Angular color input component and color picker (with HSL, HSV, RGB, CMYK, HEX, alpha, eye-dropper, etc)
npm install ngx-input-colorngModel and reactive forms
bash
npm install ngx-input-color
or
yarn add ngx-input-color
or
pnpm add ngx-input-color
`
---
๐ ๏ธ Usage
$3
`typescript
import { NgxInputColorModule } from 'ngx-input-color';
`
$3
#### Color Picker Input
`html
Selected: {{ color }}
`
#### Gradient Picker Input
`html
Selected: {{ gradient }}
`
$3
#### Inline Color Picker
`html
Selected: {{ inlineColor }}
`
#### Inline Gradient Picker
`html
Selected: {{ inlineGradient }}
`
---
๐ API Reference
$3
| Name | Type | Default | Description |
| ----------------------------- | ---------------------- | --------- | ---------------------------------------------- |
| setInputBackgroundColor | boolean | true | Set input background to selected color |
| simpleMode | boolean | false | Compact UI for inline use |
| defaultInspector | ColorInspector enum | Picker | Default inspector (Picker, RGB, HSL, CMYK) |
| [(ngModel)] / formControl | string | | Two-way binding for the selected color |
| change (Output) | EventEmitter | | Emits the color value on change |
#### Supported Color Formats
- HEX (#RRGGBB or #RRGGBBAA)
- RGBA (rgba(255,255,255,1))
- HSLA (hsla(360,100%,100%,1))
- HSVA
- CMYK
---
$3
| Name | Type | Default | Description |
| ----------------------------- | ---------------------- | --------- | ---------------------------------------------- |
| [(ngModel)] / formControl | string | | Two-way binding for the selected gradient |
| change (Output) | EventEmitter | | Emits the gradient value on change |
#### Supported Gradient Formats
- CSS Linear Gradients (e.g. linear-gradient(90deg, #ff0000 0%, #00ff00 100%))
- CSS Radial Gradients (e.g. radial-gradient(circle, #ff0000 0%, #00ff00 100%))
---
โ๏ธ Customization
- visibility, and UI modes are fully customizable via component inputs.
- Works seamlessly with both Template-driven and Reactive Forms.
---
๐งช Testing & Development
- This library includes comprehensive unit tests. Run ng test to verify functionality.
- Contributions are welcome! Please open an issue or submit a pull request.
---
โ FAQ
- Can I programmatically set the color/gradient?
Yes, simply update the variable bound to ngModel` or your form control.