diff --git a/.jules/palette.md b/.jules/palette.md new file mode 100644 index 0000000..8c4d7fb --- /dev/null +++ b/.jules/palette.md @@ -0,0 +1,3 @@ +## 2024-05-22 - Semantic Required Fields with Custom Validation +**Learning:** To combine custom validation UI with semantic `required` attributes (vital for a11y), add `noValidate` to the `
`. This prevents native browser bubbles while keeping the accessibility benefits. +**Action:** Use `noValidate` on forms when implementing custom validation but keep `required` attributes on inputs. diff --git a/src/components/ui/Input.module.css b/src/components/ui/Input.module.css index 6cb7aa9..3acc481 100644 --- a/src/components/ui/Input.module.css +++ b/src/components/ui/Input.module.css @@ -10,6 +10,11 @@ color: var(--md-sys-color-on-surface); } +.required { + color: var(--md-sys-color-error); + margin-left: 0.25rem; +} + .input { padding: var(--space-md); font-family: var(--md-sys-typescale-body-font); diff --git a/src/components/ui/Input.tsx b/src/components/ui/Input.tsx index b3d0c24..185bfbe 100644 --- a/src/components/ui/Input.tsx +++ b/src/components/ui/Input.tsx @@ -15,6 +15,11 @@ export const Input = forwardRef(
(