Skip to content

Commit

Permalink
Test the usage of ownerState in customized slots
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed May 9, 2022
1 parent 09ecee4 commit 4586cbb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions packages/mui-base/src/InputUnstyled/InputUnstyled.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import InputUnstyled, {
InputUnstyledInputSlotProps,
InputUnstyledRootSlotProps,
} from '@mui/base/InputUnstyled';

const InputRoot = React.forwardRef(function InputRoot(
props: InputUnstyledRootSlotProps,
ref: React.Ref<HTMLDivElement>,
) {
const { ownerState, ...other } = props;
return <div data-focused={ownerState.focused} {...other} ref={ref} />;
});

const InputInput = React.forwardRef(function InputInput(
props: InputUnstyledInputSlotProps,
ref: React.Ref<HTMLInputElement>,
) {
const { ownerState, ...other } = props;
return <input data-focused={ownerState.focused} {...other} ref={ref} />;
});

const styledInput = <InputUnstyled components={{ Root: InputRoot, Input: InputInput }} />;

0 comments on commit 4586cbb

Please sign in to comment.