Import
import { NuiColorPicker, nuiParseColor } from '@needless-ui/angular/color-picker';NuiColorPicker
ตัวเลือกสีใน OKLCH
| ชื่อ | ชนิด | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
valueสองทาง | string | '' | สีที่เขียนตามรูปแบบ ว่างอยู่จนกว่าจะมีการเลือกสี |
formatสองทาง | 'hex' | 'rgb' | 'hsl' | 'oklch' | 'p3' | 'hex' | รูปแบบการเขียนค่า |
formatsInput | NuiColorFormat[] | hex, rgb, hsl, oklch | รูปแบบที่ปุ่มรูปแบบจะวนผ่าน |
gamutInput | 'srgb' | 'p3' | 'srgb' | สีที่พื้นที่สีครอบคลุม: sRGB หรือ Display P3 |
alphaInput | boolean | true | แสดงสไลเดอร์ความทึบแสง |
swatchesInput | NuiColorSwatch[] | [] | สีให้เลือก พร้อมชื่อ |
contrastWithInput | string | พื้นหลังที่ใช้ตรวจคอนทราสต์ | |
eyeDropperInput | boolean | true | แสดงที่ดูดสี หากเบราว์เซอร์มี |
disabledInput | boolean | false | เปลี่ยนค่าไม่ได้ |
labelsInput | Partial<NuiColorPickerLabels> | ข้อความทุกส่วนที่แสดงหรือประกาศ สำหรับการแปล | |
colorพร็อพเพอร์ตี | Signal<NuiColor> | สีที่เลือก ในรูป OKLCH |
Helpers
ฟังก์ชันสำหรับสี
| ชื่อ | ชนิด | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
nuiParseColorเมธอด | (text: string) => NuiColor | null | อ่านสีที่เขียนด้วยไวยากรณ์ CSS แบบใดก็ได้ | |
nuiFormatColorเมธอด | (color, format?) => string | เขียนสีในรูปแบบที่กำหนด | |
nuiToGamutเมธอด | (color, gamut?: 'srgb' | 'p3') => NuiColor | ปรับสีให้อยู่ใน sRGB หรือ Display P3 แบบเดียวกับที่ CSS ทำ | |
nuiContrastเมธอด | (color, background) => number | อัตราส่วนคอนทราสต์ตาม WCAG 2 ของสีบนพื้นหลัง |