Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a 'streched-link' option (make parent block clickable) #1041

Closed
paulhuisman opened this issue Jul 21, 2019 · 5 comments
Closed

Adding a 'streched-link' option (make parent block clickable) #1041

paulhuisman opened this issue Jul 21, 2019 · 5 comments

Comments

@paulhuisman
Copy link

First off, loving the framework so far, great work!

I was wondering if there's an option to add a class similar to stretched-link in Bootstrap 4.

https://getbootstrap.com/docs/4.3/utilities/stretched-link/

What it does is make the entire parent block clickable if you add the class to a link inside.

@AlexVipond
Copy link
Contributor

I suggest making the parent block a an anchor or a button for accessibility purposes, then adding Tailwind's group class to create a hover group. Then, you can use the group-hover class on its children to customize hover styles when the parent is hovered: https://tailwindcss.com/docs/pseudo-class-variants/#group-hover

@hacknug
Copy link
Contributor

hacknug commented Jul 22, 2019

I'd probably do what @AlexVipond suggested but if for some reason the link can't wrap the whole component, you can use @apply to create a new class that mimics Bootstrap's:

.stretched-link::after {
  content: "";
  @apply z-10 absolute inset-0 bg-transparent pointer-events-auto;
}

@adamwathan
Copy link
Member

Hey @paulhuisman! I would solve this the way @AlexVipond mentioned 👍 I think adding a class like this to core would be a bit too much of a departure from the sorts of classes we currently provide, so if you wanted to create a stretched-link class I would do it in userland or via a plugin.

@iamandrewluca
Copy link

One more solution now with JIT mode, just add after:absolute after:inset-0 to your link

<div class="realtive">
  <a class="after:absolute after:inset-0" href="/link">
    Link
  </a>
</div>

@IbraheemTuffaha
Copy link

One more solution now with JIT mode, just add after:absolute after:inset-0 to your link

<div class="realtive">
  <a class="after:absolute after:inset-0" href="/link">
    Link
  </a>
</div>

That solves it!
Thank you.
Can you edit your response to have the outer div class as "relative" instead of "realtive"? so people don't fall for it :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants