[Link] Customize rendered link #757
Unanswered
marcialfps
asked this question in
Ideas
Replies: 1 comment 2 replies
-
In order to use DxcLink component with Next.js link, this can be done as in this example (from Chakra UI design system):
Next link's For using DxcLink with React Router, seems that the new prop approach is widely used in most of the design systems. This prop is mostly called Some more examples of design systems that use this approach: |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Feature
The Link component must be able to support different renderers, i.e. React Router or NextJS Link.
Approaches
This functionality can be added in different ways. The following approaches are taken from other design systems that support it.
linkComponent
prop in ProviderBraid design system provides a prop in the BraidProvider called
linkComponent
. This prop receives a function that wraps the custom link.Example:
In our case we can provide this new prop in the ThemeProvider. This approach facilitates the use of a single Link in the application.
New prop
Most design systems choose to provide a new prop in the component. Rainbow and Fluent (example) call it
as
and Spark aselement
. In all the cases it can receive a react element, a function or a primitive type name.Rainbow example:
This approach forces this prop to be used in all links used in the application.
Link component as style, not as functionality
Spectrum design system uses the Link component as a wrapper that applies styles to children. It also supports cases where the children are text but manage the click through
onPress
prop.Example:
This case allow users to use any type of element as a link. I think this approach is dangerous and we should be more restrictive.
Beta Was this translation helpful? Give feedback.
All reactions