Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(radio): radio with tailwind forms #46

Merged
merged 16 commits into from
Feb 1, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore(radio): radio label improvements
  • Loading branch information
anuraghazra committed Jan 27, 2021
commit 755b5d9f8eaf6b9f01c91d4c32d0dec0e54a9e5f
32 changes: 16 additions & 16 deletions src/radio/Radio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,17 @@ const [RadioProvider, useRadioContext] = createContext({
errorMessage: "Radio must be used within RadioContextProvider",
});

export const RadioLabel: React.FC<{ className?: string }> = ({
children,
className,
}) => {
const theme = useTheme();
export const RadioLabel = forwardRefWithAs<{}, HTMLLabelElement, "label">(
({ children, className }, ref) => {
const theme = useTheme();

return <label className={cx(theme.radio.base, className)}>{children}</label>;
};
return (
<label ref={ref} className={cx(theme.radio.base, className)}>
{children}
</label>
);
},
);

export const Radio = forwardRefWithAs<
Partial<RadioProps>,
Expand All @@ -35,15 +38,12 @@ export const Radio = forwardRefWithAs<
const theme = useTheme();

return (
<label className={cx(theme.radio.base, className)}>
<ReakitRadio
className={theme.radio.input}
{...state}
{...props}
ref={ref}
/>
<span>{children}</span>
</label>
<ReakitRadio
className={theme.radio.input}
{...state}
{...props}
ref={ref}
/>
);
});

Expand Down