How to set a default border color in tailwind 4
Change the Focus Border color in Tailwind CSS
html - Border Color Tailwind CSS - Stack Overflow
next.js - Tailwind css border color not working on web page - Stack Overflow
How do I remove a border in Tailwind CSS?
Can I apply a gradient to a border in Tailwind CSS?
How do I change the border color on hover in Tailwind CSS?
Videos
Hi, i was wondering if there is a way to define a default border color so i only need to apply the border class and not have to also add the border-[color].
Thanks!
You need to:
- Set your focus color (
focus:border-teal) - Remove the default outline (
focus:outline-none) - Then set (
focus:ring-0), this removes the default ring that appears around the input element when it's focused.
Input elements have an outline on focus by default. So your colored border is not visible.
Add focus:outline-none class to your input element to remove the outline.
<input className="border-2 border-gray-500 p-2 rounded-md w-1/2 focus:border-teal-500 focus:outline-none" type="text" name="name" placeholder='Enter Your Name' />
Like you see in inspector, you defined only border color but not border width. Because it is 0px, it is invisible ;)
You need to change it to
class="border border-gray-800"
"border" will by default mean border-width: 1px so if you need thicker use for example
class="border-2 border-gray-800"
or if you wanna it only on one side
class="border-right border-gray-800"
More in documentation.
Nothing was working for me until I added the border-style: solid using border-solid. I had to explicitly set border-0 though, else it will be applied to all directions.
<div className="border-0 border-b-2 border-solid border-b-red-600">Bottom border</div>
I am using "tailwindcss": "^3.3.3"