Skip to content

Commit

Permalink
feat(Input): invalid styling
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed Jul 12, 2024
1 parent c92781c commit ad0ce88
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/components/Input.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const Basic = {
args: {
defaultValue: "",
placeholder: "Placeholder",
"aria-invalid": false,
readOnly: false,
disabled: false,
},
Expand All @@ -24,6 +25,7 @@ export const Interactivity = {
render: () => (
<Stack>
<Input defaultValue="Focused" />
<Input defaultValue="Invalid" aria-invalid />
<Input value="Read-only" readOnly />
<Input placeholder="Placeholder" />
<Input value="Disabled" disabled />
Expand Down
2 changes: 1 addition & 1 deletion src/components/Input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const Input = forwardRef(function Input(
className={clsx(
className,
controlClassName({ size }),
"bg-ui-neutral-50 text-ui-neutral-800 ring-1 ring-inset ring-ui-neutral-600 placeholder:text-ui-neutral-500",
"bg-ui-neutral-50 text-ui-neutral-800 ring-1 ring-inset ring-ui-neutral-600 placeholder:text-ui-neutral-500 aria-invalid:ring-2 aria-invalid:ring-ui-danger-600",
size === "sm" && "px-2.5",
size === "md" && "px-3",
size === "lg" && "px-4 font-medium",
Expand Down
3 changes: 3 additions & 0 deletions src/tailwind-preset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ export default {
theme: {
colors,
extend: {
aria: {
invalid: 'invalid="true"',
},
borderColor: ({ theme }) => ({
DEFAULT: theme("colors.ui.neutral-200") as string,
}),
Expand Down

0 comments on commit ad0ce88

Please sign in to comment.