用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/thedaviddias/ux-patterns-for-developers --skill color-picker命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | color-picker |
| description | Use when implementing select colors with visual feedback. |
| metadata | {"id":"color-picker","category":"forms","pattern":"Color Picker","source":"uxpatterns.dev","url":"https://uxpatterns.dev/patterns/forms/color-picker","sourcePath":"apps/web/content/patterns/forms/color-picker.mdx"} |
Select colors with visual feedback
A Color Picker is a form input component that allows users to select a color value through visual interaction. It may be implemented as a native browser control (<input type="color">), a custom swatch palette, a hex/RGB/HSL text input, a gradient spectrum canvas, or an eyedropper tool — or any combination of these.
Color pickers are used wherever users need to choose or define colors: theme customization, design tools, annotation systems, data visualization category assignment, and product personalization.
<input type="color"> may be sufficient; avoid heavy custom UIs on small screens.references/pattern.md, then choose the smallest viable variation.| Key | Action |
|---|---|
Enter / Space | Opens or closes the color picker panel when on the trigger |
Tab | Moves focus through picker controls in order |
Shift + Tab | Moves focus in reverse through picker controls |
Arrow Keys | Navigates through swatch grid (roving tabindex) |
Arrow Keys | Adjusts hue/saturation slider values by 1 step |
Home / End | Jumps to first/last swatch in a palette row |
Escape | Closes the picker panel and returns focus to the trigger |
The Problem:
A canvas-only hue/saturation picker is completely inaccessible to keyboard and screen reader users.
How to Fix It? Always pair canvas controls with equivalent range inputs or text inputs.
<!-- Good: keyboard-accessible hue control alongside canvas -->
<input
type="range"
min="0"
max="360"
value="217"
aria-label="Hue"
class="color-picker__hue-slider"
/>
The Problem: Showing only a colored swatch without a hex/name label forces users to remember what they chose and breaks copy-paste workflows.
How to Fix It? Always display the current value as text.
<!-- Good -->
<button class="color-picker__trigger" style="background: #3b82f6" aria-label="Current color: #3b82f6">
</button>
<output class="color-picker__value" aria-live="polite">#3b82f6</output>
The Problem:
Validating hex input on every keystroke while the user is typing causes premature error messages (e.g., error shown for #3b8 which is just incomplete).
How to Fix It? Validate only on blur or when the input matches the expected length.
hexInput.addEventListener('blur', () => {
const isValid = /^#[0-9A-Fa-f]{6}$/.test(hexInput.value);
hexInput.setAttribute('aria-invalid', String(!isValid));
});
For full implementation detail, examples, and testing notes, see references/pattern.md.
Pattern page: https://uxpatterns.dev/patterns/forms/color-picker