Last updated: 13 May 2024

Tailwind CSS Border Style

Tailwind Border Style

In Tailwind CSS, the border-style property is used to define the style of the border around an element. There are several styles available, including solid, dashed, dotted, double, and none.

ClassProperties
border-solidborder-style: solid;
border-dashedborder-style: dashed;
border-dottedborder-style: dotted;
border-doubleborder-style: double;
border-noneborder-style: none;

Applying Tailwind Border Style

In Tailwind CSS, you can apply a border style to an element using the border-{style} utility, where {style} is the border style. For example, to apply a solid border, you would use the border-solid class as shown below:

html
<div class="border border-solid">This div has a solid border.</div>

Preview

This div has a solid border

For example, to give a div a dashed border:

html
<div class="border border-dashed">This div has a dashed border.</div>

Preview

This div has a dashed border

For example, to give a div a dotted border:

html
<div class="border border-dotted">This div has a dotted border.</div>

Preview

This div has a dotted border

For example, to give a div a double border:

html
<div class="border border-double">This div has a double border.</div>

Preview

This div has a double border

For example, to give a div a none border:

html
<div class="border border-none">This div has a none border.</div>

Preview

This div has a none border

Customizing Tailwind Border Styles

Tailwind CSS allows you to customize border styles using the tailwind.config.js file. You can extend the default configuration and define your own custom border styles.

Here's an example of how to add a new border style:

jsx
// tailwind.config.js
module.exports = {
variants: {
extend: {
// ...
borderStyle: ['hover', 'focus'],
}
}
}
html
<div class="border border-hover">This div has a hover border.</div>

Build modern projects using Bootstrap 5 and Contrast

Trying to create components and pages for a web app or website from scratch while maintaining a modern User interface can be very tedious. This is why we created Contrast, to help drastically reduce the amount of time we spend doing that. so we can focus on building some other aspects of the project.

Contrast Bootstrap PRO consists of a Premium UI Kit Library featuring over 10000+ component variants. Which even comes bundled together with its own admin template comprising of 5 admin dashboards and 23+ additional admin and multipurpose pages for building almost any type of website or web app.
See a demo and learn more about Contrast Bootstrap Pro by clicking here.