Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions .changeset/two-clouds-refuse.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@heroui/radio": patch
---

handle props styles in getBaseProps (#5942)
13 changes: 7 additions & 6 deletions apps/docs/content/components/radio-group/custom-impl.raw.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ export const CustomRadio = (props) => {

return (
<Component
{...getBaseProps()}
className={cn(
"group inline-flex items-center hover:opacity-70 active:opacity-50 justify-between flex-row-reverse tap-highlight-transparent",
"max-w-[300px] cursor-pointer border-2 border-default rounded-lg gap-4 p-4",
"data-[selected=true]:border-primary",
)}
{...getBaseProps({
className: cn(
"group inline-flex items-center hover:opacity-70 active:opacity-50 justify-between flex-row-reverse tap-highlight-transparent m-0",
"max-w-[300px] cursor-pointer border-2 border-default rounded-lg gap-4 p-4",
"data-[selected=true]:border-primary",
),
})}
>
<VisuallyHidden>
<input {...getInputProps()} />
Expand Down
13 changes: 7 additions & 6 deletions apps/docs/content/components/radio-group/custom-impl.raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ export const CustomRadio = (props: RadioProps) => {

return (
<Component
{...getBaseProps()}
className={cn(
"group inline-flex items-center justify-between hover:bg-content2 flex-row-reverse",
"max-w-[300px] cursor-pointer border-2 border-default rounded-lg gap-4 p-4",
"data-[selected=true]:border-primary",
)}
{...getBaseProps({
className: cn(
"group inline-flex items-center hover:opacity-70 active:opacity-50 justify-between flex-row-reverse tap-highlight-transparent m-0",
"max-w-[300px] cursor-pointer border-2 border-default rounded-lg gap-4 p-4",
"data-[selected=true]:border-primary",
),
})}
>
<VisuallyHidden>
<input {...getInputProps()} />
Expand Down
2 changes: 1 addition & 1 deletion packages/components/radio/src/use-radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ export function useRadio(props: UseRadioProps) {
return {
...props,
ref: domRef,
className: slots.base({class: baseStyles}),
className: slots.base({class: clsx(baseStyles, props?.className)}),
"data-disabled": dataAttr(isDisabled),
"data-focus": dataAttr(isFocused),
"data-focus-visible": dataAttr(isFocusVisible),
Expand Down
32 changes: 13 additions & 19 deletions packages/components/radio/stories/radio.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import type {RadioProps, RadioGroupProps} from "../src";

import React from "react";
import {VisuallyHidden} from "@react-aria/visually-hidden";
import {radio, button} from "@heroui/theme";
import {radio, button, cn} from "@heroui/theme";
import {clsx} from "@heroui/shared-utils";
import {Form} from "@heroui/form";

import {RadioGroup, Radio, useRadio, useRadioGroupContext} from "../src";
import {RadioGroup, Radio, useRadio} from "../src";

export default {
title: "Components/RadioGroup",
Expand Down Expand Up @@ -360,19 +360,14 @@ export const Controlled = {
const CustomRadio = (props: RadioProps) => {
const {children, ...otherProps} = props;

const {groupState} = useRadioGroupContext();

const isSelected = groupState.selectedValue === otherProps.value;

return (
<Radio
{...otherProps}
classNames={{
base: clsx(
"inline-flex bg-content1 hover:bg-content2 items-center justify-between flex-row-reverse max-w-[300px] cursor-pointer rounded-lg gap-4 p-4 border-2 border-transparent",
{
"border-primary": isSelected,
},
base: cn(
"inline-flex m-0 bg-content1 hover:bg-content2 items-center justify-between",
"flex-row-reverse max-w-[300px] cursor-pointer rounded-lg gap-4 p-4 border-2 border-transparent",
"data-[selected=true]:border-primary",
),
}}
>
Expand Down Expand Up @@ -401,7 +396,6 @@ const RadioCard = (props: RadioProps) => {
const {
Component,
children,
isSelected,
description,
getBaseProps,
getWrapperProps,
Expand All @@ -413,13 +407,13 @@ const RadioCard = (props: RadioProps) => {

return (
<Component
{...getBaseProps()}
className={clsx(
"group inline-flex items-center justify-between hover:bg-content2 flex-row-reverse max-w-[300px] cursor-pointer border-2 border-default rounded-lg gap-4 p-4",
{
"border-primary": isSelected,
},
)}
{...getBaseProps({
className: cn(
"group inline-flex items-center hover:opacity-70 active:opacity-50 justify-between flex-row-reverse tap-highlight-transparent m-0",
"max-w-[300px] cursor-pointer border-2 border-default rounded-lg gap-4 p-4",
"data-[selected=true]:border-primary",
),
})}
>
<VisuallyHidden>
<input {...getInputProps()} />
Expand Down
Loading