diff --git a/packages/eds-core-react/src/components/Typography/Typography.docs.mdx b/packages/eds-core-react/src/components/Typography/Typography.docs.mdx
index 49ec97e714..c0a06d998e 100644
--- a/packages/eds-core-react/src/components/Typography/Typography.docs.mdx
+++ b/packages/eds-core-react/src/components/Typography/Typography.docs.mdx
@@ -111,4 +111,19 @@ const myToken = {
### Link
Link used in body of text.
-
\ No newline at end of file
+
+
+### Using the 'as' prop to render as another component
+
+The `as` prop allows you to render `Typography` as another html element or even react component.
+
+
+
+This is useful if you want to use `Typography` with a third party routing library such as react-router.
+
+```tsx
+import { Link } from "react-router-dom"
+import { Typography } from '@equinor/eds-core-react'
+
+About
+```
diff --git a/packages/eds-core-react/src/components/Typography/Typography.stories.tsx b/packages/eds-core-react/src/components/Typography/Typography.stories.tsx
index 455399158e..847b46b61e 100644
--- a/packages/eds-core-react/src/components/Typography/Typography.stories.tsx
+++ b/packages/eds-core-react/src/components/Typography/Typography.stories.tsx
@@ -15,6 +15,19 @@ const SBCard = styled(Card)`
export default {
title: 'Typography/Typography',
component: Typography,
+ argTypes: {
+ as: {
+ description: 'Change the HTML element',
+ table: {
+ type: {
+ summary: 'ElementType',
+ },
+ },
+ control: {
+ type: null,
+ },
+ },
+ },
parameters: {
docs: {
page,
@@ -209,3 +222,18 @@ Link.decorators = [
)
},
]
+
+export const As: Story = () => (
+
+ I am a <h4> styled as a <h2>
+
+)
+As.decorators = [
+ (Story) => {
+ return (
+
+
+
+ )
+ },
+]
diff --git a/packages/eds-core-react/src/components/Typography/Typography.tsx b/packages/eds-core-react/src/components/Typography/Typography.tsx
index fed6a4b5e5..e824b8db4d 100644
--- a/packages/eds-core-react/src/components/Typography/Typography.tsx
+++ b/packages/eds-core-react/src/components/Typography/Typography.tsx
@@ -5,7 +5,11 @@ import {
AnchorHTMLAttributes,
} from 'react'
import styled, { css } from 'styled-components'
-import { typographyTemplate, outlineTemplate } from '@equinor/eds-utils'
+import {
+ typographyTemplate,
+ outlineTemplate,
+ OverridableComponent,
+} from '@equinor/eds-utils'
import {
quickVariants,
colors,
@@ -122,12 +126,10 @@ export type TypographyProps = {
token?: Partial
/** Number of lines. */
lines?: number
- /** Change html element. */
- as?: ElementType
} & (HTMLAttributes | AnchorHTMLAttributes)
-export const Typography = forwardRef(
- function Typography(
+export const Typography: OverridableComponent =
+ forwardRef(function Typography(
{
variant = 'body_short',
children,
@@ -173,7 +175,6 @@ export const Typography = forwardRef(
{children}
)
- },
-)
+ })
// Typography.displayName = 'EdsTypography'