Skip to content

Commit

Permalink
fix(checkbox): label as text
Browse files Browse the repository at this point in the history
Co-Authored-By: Pram Gurusinga <[email protected]>
  • Loading branch information
chohner and pgurusinga committed Nov 16, 2023
1 parent c21d5c9 commit 5a9713d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions app/components/inputs/Checkbox.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import type { ReactNode } from "react";
import { useField } from "remix-validated-form";

type CheckboxProps = {
name: string;
value?: string; // Defaults to "on", see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Input/checkbox#value
onClick?: () => void;
label?: ReactNode;
label?: string;
formId?: string;
};

const Checkbox = ({
name,
value = "on",
onClick,
label: text,
label,
formId,
}: CheckboxProps) => {
const { error, getInputProps } = useField(name, { formId });
Expand All @@ -28,7 +27,7 @@ const Checkbox = ({
aria-describedby={error && `${name}-error`}
onClick={onClick}
/>
{<label htmlFor={id}>{text}</label>}
{label && <label htmlFor={id}>{label}</label>}
</div>
);
};
Expand Down

0 comments on commit 5a9713d

Please sign in to comment.