usage of Link component
Answered
American Chinchilla posted this in #help-forum
American ChinchillaOP
<Button
onClick={() => push(href)}
className={cn("flex gap-2 my-auto cursor-pointer", className)}
{...props}
>
...
</Button> hey i have this Button component from shadcn ui but i would like to redirect user on click however i heard i should use Link component to do that how can i do so in this case?should i wrap whole button in Link component and move classes to Link instead?
Answered by Ant
You can achive this with asChild as seen here: https://ui.shadcn.com/docs/components/button#as-child
2 Replies
@American Chinchilla tsx
<Button
onClick={() => push(href)}
className={cn("flex gap-2 my-auto cursor-pointer", className)}
{...props}
>
...
</Button>
hey i have this Button component from shadcn ui but i would like to redirect user on click however i heard i should use Link component to do that how can i do so in this case?
should i wrap whole button in Link component and move classes to Link instead?
Ant
You can achive this with asChild as seen here: https://ui.shadcn.com/docs/components/button#as-child
Answer
@Ant You can achive this with asChild as seen here: https://ui.shadcn.com/docs/components/button#as-child
American ChinchillaOP
oh okay thanks