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

Allow using a custom Input component (like asChild in Radix UI) #166

Closed
amotarao opened this issue Feb 13, 2025 · 4 comments
Closed

Allow using a custom Input component (like asChild in Radix UI) #166

amotarao opened this issue Feb 13, 2025 · 4 comments

Comments

@amotarao
Copy link

Hello, and thank you for maintaining this fantastic library! I’m currently using @uiw/react-color-editable-input and would love to use my own custom Input component while retaining the existing color input functionality.

Why this would be helpful:

Maintains consistent styling and behavior across my application
Prevents the need to reinvent color input logic
Aligns with patterns like Radix UI’s asChild, offering flexibility in component composition
Would you consider adding a prop or similar mechanism to allow replacing the default Input component with a custom one?

@jaywcjlove
Copy link
Member

@amotarao Do I need to add a renderInput prop?

export interface EditableInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> {
  //.....
  renderInput?: (props: React.InputHTMLAttributes<HTMLInputElement>) => React.ReactNode;
}
<EditableInput
  label="Hex"
  value={hsvaToHex(hsva)}
  style={{ width: 68, alignItems: 'flex-start' }}
  renderInput={(props) => {
    return <input {...props} />
  }}
/>

@amotarao
Copy link
Author

@jaywcjlove I think that’s also a good approach! Once renderProps is added, this issue will likely be resolved.

@jaywcjlove
Copy link
Member

@amotarao Upgrade v2.4.0

@amotarao
Copy link
Author

@jaywcjlove It worked perfectly. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants