Exploring AI: The Roadmap Ahead
Uncover what the future holds for AI and learn about the latest advancements in the field.
Link Overlay
The necessity of LinkOverlay arises from the fact that wrapping an entire interactive component or card with an HTML <a>
element is not considered semantic. The HTML specification clearly states that an <a>
element cannot contain interactive descendants such as buttons, anchors, or input fields.
LinkOverlay tackles this problem by overlaying a single link on top of the interactive element or card, and elevating any remaining links on top of this overlay. This ensures proper semantics and correct handling of nested interactive elements.
LinkOverlay is usually imported alongside the LinkBox component. These two work together to improve link accessibility and user experience. Here is a further explanation of the two components:
LinkBox
: a utility component that's used to create a larger clickable area for one or more nested links. It doesn't provide any styles of its own. The primary role of LinkBox is to enhance accessibility and UX by improving the link interaction area. To create a larger clickable area, you would wrap the LinkBox around a block of content containing a LinkOverlay component. However, please note that it's important to have only one interactive child (an element with click or key press interaction) within a LinkBox.LinkOverlay
: a component that's primarily used in conjunction with LinkBox to create larger, more accessible link areas. It is used to wrap the primary link content within a LinkBox. The LinkOverlay component's main function is to wrap the content that should act as the main link within a LinkBox. When the user clicks anywhere within the LinkBox, they'll be directed to the URL of the LinkOverlay component.These components can be imported as follows:
Examples
Basic Usage
Uncover what the future holds for AI and learn about the latest advancements in the field.
Code
Nested Links
<a>
tag) should not contain any other interactive elements, such as buttons, other links, or inputs.In the code for the example below, you can see a nested interactive element (a link represented by Box as='a') inside a LinkBox, which itself contains a LinkOverlay serving as the main link. Chakra UI uses CSS stacking context (with z-index) to manage this complex interaction scenario properly. In essence, it "lifts" the nested link to the top, so it's independently clickable from the LinkOverlay.
This allows the user to interact with each link separately – when you hover over or focus on the main linked area (covered by LinkOverlay), you get the URL specified in LinkOverlay. But when you hover over or focus on the inner link, you interact with the URL specified in the inner link.
This ability to independently interact with each link despite the nesting is the interesting part of this example. It maintains proper HTML semantics while enhancing user experience, especially for keyboard users who rely on focus states for navigation.
Uncover what the future holds for AI and learn about the latest advancements in the field.
Read MoreCode
Using with Routing
Get an in-depth analysis of the most significant AI advancements made in 2023.
Continue ReadingCode
One Drawback
Did you know?
Creative Idea No. 1
Code
Creative Idea No. 2
Code
Creative Idea No. 3
Code
copyright © 2023 IHeartComponents | evanmarie.com
created with love by the I♥️Components team using
Special thanks to Stefan Bohacek / Generative Placeholders.