I’m using React and Tailwind, I want to achieve this :
So I added a border on both button + and -, and I added a border on the parent div to display a border on all the element.
Problem is, the borders on buttons seemes to be larger because of the 2 borders.
If I use a border only on the right for – button, we can see it misses a little pixels with no border…
How can I achieve it ?
Here is a Tailwind Playground
Here is my code :
<div class="p-8">
<div class="flex w-fit items-center rounded ring-1 ring-neutral-300">
<button type="button" class="h-10 w-10 rounded border border-neutral-300 bg-transparent focus:outline-none">-</button>
<input id="{id}" type="number" value="{count}" class="arrow-hide h-10 w-16 rounded border-none text-center text-base font-semibold focus:outline-none" />
<button type="button" class="h-10 w-10 rounded border border-neutral-300 bg-transparent focus:outline-none">+</button>
</div>
</div>
Thank you !
2
Answers
Since you want a rounded border on the inside corner of the buttons as well, IMHO the best solution is to make them overlap the border of the container:
They need two extra pixels of height, so that will probably have to be hard-coded like this, don’t see any way to directly combine this with the
h-10
class here. z-index is needed so that the input field will not be on top of the left button’s right-side border.And of course it will only work if you don’t need any alpha transparence on those borders.
Actually it is not missing any pixels , it seems to be faded because of the rounded border.
Feasible solution:
rounded
from the+
and-
divsUpdated Code:
Output:
Tailwind-play