フォーム
Color Picker
色見本を並べて色を選ぶ部品。見本を押して選べて、必要ならブラウザ標準の色選びの画面も添えられます。
ReactVueWeb Components
Storybook で見る プレイグラウンド
使用例
<ColorPicker aria-label="テーマ色" defaultValue="#cd2e69" onChange={setColor} /> 設定できる項目
| 名前 | 型 | 既定値 | 説明 |
|---|---|---|---|
value | string | — | Controlled value (hex). |
defaultValue | string | — | Initial value when uncontrolled. @default DEFAULT_SWATCHES[0] |
onChange | (hex: string) => void | — | Called with the chosen hex color. |
swatches | string[] | — | Preset swatches. @default DEFAULT_SWATCHES |
custom | boolean | true | Allow a custom color via the native picker. @default true |
customLabel | string | Custom | Label for the custom-color control. @default 'Custom' |
aria-label | string | Color | Accessible label for the swatch group. @default 'Color' |
className | string | — |
アクセシビリティ
- 文字と背景の明るさの差をしっかり取り、読みやすくしています。ライトでもダークでも、見やすさの国際基準 WCAG の最高ランク AAA(明るさの差が 7:1 以上)を満たします。
- マウスがなくても、キーボードだけですべての操作ができます。
- いまどこを操作しているかを示す枠(フォーカスの囲み)が、常にはっきり見えます。
- 利用者が「画面の動きを減らす」設定にしているときは、過剰なアニメーションを止めます。
どのコンポーネントも、だれにとっても使いやすいように、見やすさの国際基準 WCAG の最高ランク AAA(WCAG 2.1 AAA)を満たすよう作っています。