Skip to content

Commit 390128c

Browse files
committed
fix: accept react-style text field readOnly
1 parent 4ed0448 commit 390128c

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

libs/radix-ui-themes/src/components/text-field.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import type { GetPropDefTypes } from '../props/prop-def.js';
1414
type TextFieldRootElement = React.ElementRef<'input'>;
1515
type TextFieldRootOwnProps = GetPropDefTypes<typeof textFieldRootPropDefs> & {
1616
defaultValue?: string | number;
17+
readOnly?: boolean;
1718
value?: string | number;
1819
type?:
1920
| 'date'
@@ -38,8 +39,11 @@ interface TextFieldRootProps extends TextFieldInputProps, MarginProps, TextField
3839
const TextFieldRoot = React.forwardRef<TextFieldRootElement, TextFieldRootProps>(
3940
(props, forwardedRef) => {
4041
const inputRef: React.RefObject<HTMLInputElement> = { current: null };
42+
const { readOnly, readonly, ...restProps } = props as TextFieldRootProps & {
43+
readonly?: boolean;
44+
};
4145
const { children, className, color, radius, style, ...inputProps } = extractProps(
42-
props,
46+
{ ...restProps, readonly: readOnly ?? readonly },
4347
textFieldRootPropDefs,
4448
marginPropDefs,
4549
);

0 commit comments

Comments
 (0)