Skip to content

Buttons should support href as a prop #2118

Closed
@jdrush89

Description

@jdrush89

Describe the bug
According to #1972, LinkButtons have been removed in favor of <Button as="a" />. If this is the recommended way of doing link buttons, then passing an href to the Button component should forward that prop to the a element. Otherwise, an onClick that sets the window.location.href has to be used which is more code and clunkier.

To Reproduce
Steps to reproduce the behavior:

  1. Go to https://primer.style/react/Button
  2. Update the first example to <Button as="a" href="http://google.com">Default</Button>
  3. Click on the Button in the first example
    image

Expected behavior
The user should be navigated to the url passed in as the href.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser chrome
  • Version 101.0.4951.67 (Official Build) (32-bit)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions