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 Button accept Link as custom component #129

Open
khanhhaquang opened this issue Jun 21, 2022 · 4 comments
Open

Allow Button accept Link as custom component #129

khanhhaquang opened this issue Jun 21, 2022 · 4 comments

Comments

@khanhhaquang
Copy link
Contributor

khanhhaquang commented Jun 21, 2022

Currently there no choice to custom Button to be Link from react-router.

Expected like:
<Button component={<Link to='/somewhere' />} />

@benjitrosch
Copy link
Collaborator

benjitrosch commented Jun 21, 2022

Hi @khanhhaquang,

The correct way to do this would be like so:

<Link to="/somewhere">
     <Button>
          Click me
     </Button>
 </Link>

If you believe adding the component prop would be valuable you are welcome to open a PR. Typically, react-daisyui tries to be as close to semantic HTML as possible, but if a new prop offers a huge value-add (or is common enough in other component libraries) then I would be happy to merge it in.

I'm curious where you got that specific prop from, do you have a reference from another component library that you're referring to?

@khanhhaquang
Copy link
Contributor Author

khanhhaquang commented Jun 21, 2022

Surely it's a solution, but nested button in anchor is not match with HTML5 standard, reference to this

@benjitrosch
Copy link
Collaborator

benjitrosch commented Jun 21, 2022

Sorry, you are correct, I was not thinking when I wrote that comment! 😅

In some ways this relates to #108 because we fundamentally lack a way to use a <Button /> with an anchor internally (unless an href is passed in, and even then with limited functionality). A solution that allows us to render an anchor tag would make the button suitable for use with react-router.

btw: am I correct that the component prop you're referencing is from material-ui?

@khanhhaquang
Copy link
Contributor Author

Sorry, you are correct, I was not thinking when I wrote that comment! 😅

In some ways this relates to #108 because we fundamentally lack a way to use a <Button /> with an anchor internally (unless an href is passed in, and even then with limited functionality). A solution that allows us to render an anchor tag would make the button suitable for use with react-router.

btw: am I correct that the component prop you're referencing is from material-ui?

Hi Benji, actually it's just an popup idea to custom the wrapper as a Component.

Another solution for this case is using navigate function instead of Link from react-router . I think you're right, not that worth to implement just for this case.

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