Link
Links are used as navigational elements. They may appear isolated, inside a sentence or paragraph or following the content.
Name | Type | Description | Default |
---|---|---|---|
disabled | boolean | If true, the link is disabled. | false |
inheritColor | boolean | If true, the color is inherited from parent. | false |
icon | string | (React.ReactNode & React.SVGProps <SVGSVGElement>) | Material Symbol name or SVG element as the icon that will be placed next to the link text. When using Material Symbols, replace spaces with underscores. By default they are outlined if you want it to be filled prefix the symbol name with "filled_" . | - |
iconPosition | 'before' | 'after' | Indicates the position of the icon in the component. | 'before' |
href | string | Page to be opened when the user clicks on the link. | - |
newWindow | boolean | If true, the page is opened in a new browser tab. | false |
onClick | () => void | If defined, the link will be displayed as a button. This function will be called when the user clicks the link. | - |
Required | string | Text of the link. | - |
margin | 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | Margin | Size of the margin to be applied to the component. You can pass an object with 'top', 'bottom', 'left' and 'right' properties in order to specify different margin sizes. | - |
tabIndex | number | Value of the tabindex attribute. | 0 |
There are many React based routers, unfortunately all with different APIs.
So we decided to make our link component just an styled HTML anchor element which allows it to be used in any React based router. For each API is different, so here are some examples for React Router and NextJS Link. Some of these examples are just representations of how they should be implemented but might not work correctly in this scenario.
This is an example of React Router using the prop component
. Note that this prop is not available in v6.
In React Router v6 the prop component
is no longer available so it is necessary to use hooks provided by React Router v6.