diff --git a/packages/eds-core-react/src/components/Button/Button.docs.mdx b/packages/eds-core-react/src/components/Button/Button.docs.mdx index 8241e1d5d6..919e5375d6 100644 --- a/packages/eds-core-react/src/components/Button/Button.docs.mdx +++ b/packages/eds-core-react/src/components/Button/Button.docs.mdx @@ -75,3 +75,19 @@ Example All button combinations. Compact `Button` using `EdsProvider`. + +### Using the 'as' prop to render as another component + +The `as` prop allows you to render the `Button` as another html element or even react component. + +```tsx + +``` +This is especially useful if you want to use the `Button` as as a navigation component for a third party routing library such as react-router. + +```tsx +import { Link } from "react-router-dom" +import { Button } from '@equinor/eds-core-react' + + +``` diff --git a/packages/eds-core-react/src/components/Button/Button.stories.tsx b/packages/eds-core-react/src/components/Button/Button.stories.tsx index 97a96e84d0..15384bc5a2 100644 --- a/packages/eds-core-react/src/components/Button/Button.stories.tsx +++ b/packages/eds-core-react/src/components/Button/Button.stories.tsx @@ -40,9 +40,6 @@ export default { export const Introduction: Story = (args) => { return } -Introduction.args = { - as: undefined, -} Introduction.decorators = [ (Story) => ( diff --git a/packages/eds-core-react/src/components/Button/Button.test.tsx b/packages/eds-core-react/src/components/Button/Button.test.tsx index d95e168859..f2fc2f3c4f 100644 --- a/packages/eds-core-react/src/components/Button/Button.test.tsx +++ b/packages/eds-core-react/src/components/Button/Button.test.tsx @@ -19,6 +19,13 @@ const StyledButton = styled(Button)` const MarginButton = styled(Button)` margin: 12px; ` +const LinkButton = ({ to }: { to: string }) => { + return ( + + click + + ) +} afterEach(cleanup) @@ -135,6 +142,13 @@ describe('Button', () => { expect(button).toBeInTheDocument() }) + it('Can be cast as another component', () => { + render(