Skip to content

Tailwind CSS - Border Style

Tailwind CSS provides utility classes to control the style of an element’s borders. These styles, such as solid, dashed, or dotted, are fundamental for defining the visual language and hierarchy of your user interface.

Below is the list of available border style utilities. Note that for a border to appear, you also need to specify its width (e.g., border-2) and color (e.g., border-slate-500).

ClassCSS Properties
border-solidborder-style: solid;
border-dashedborder-style: dashed;
border-dottedborder-style: dotted;
border-doubleborder-style: double;
border-hiddenborder-style: hidden;
border-noneborder-style: none;
  • border-solid: The most common style, used for standard containers, buttons, and inputs.
  • border-dashed: Often used to indicate placeholder content, interactive drop zones, or items in a ‘draft’ state.
  • border-dotted: A softer alternative to dashed, suitable for subtle separators or decorative elements.
  • border-double: A more decorative style, can be used for special callouts or vintage-themed designs.
  • border-none: Explicitly removes any border style, which is useful for resetting styles on elements like buttons.

This example demonstrates how to build an alert component. A thick, solid left border provides a clear visual cue for the alert’s type (e.g., information, success, warning), a common and effective UI pattern.

<div class="space-y-4 p-8">
<!-- Success Alert -->
<div role="alert" class="p-4 bg-green-100 border-l-4 border-solid border-green-600 text-green-800 rounded-r-lg">
<p class="font-bold">Success!</p>
<p>Your profile has been updated successfully.</p>
</div>
<!-- Warning Alert -->
<div role="alert" class="p-4 bg-yellow-100 border-l-4 border-solid border-yellow-600 text-yellow-800 rounded-r-lg">
<p class="font-bold">Warning</p>
<p>Your subscription is expiring in 3 days.</p>
</div>
</div>

Here, we use a border-dashed style to indicate that an area is a drop zone. On hover, we change the style to border-solid and update the color to provide feedback to the user, signaling that the area is interactive.

<div class="p-8 bg-gray-50 dark:bg-slate-900">
<div class="flex items-center justify-center w-full">
<label for="dropzone-file" class="flex flex-col items-center justify-center w-full h-64 border-2 border-dashed border-gray-300 rounded-lg cursor-pointer
bg-gray-100 dark:bg-slate-800 dark:border-slate-600
hover:bg-gray-200 hover:border-solid hover:border-blue-500
dark:hover:bg-slate-700 dark:hover:border-blue-400
transition-all duration-300">
<div class="flex flex-col items-center justify-center pt-5 pb-6">
<p class="mb-2 text-sm text-gray-500 dark:text-gray-400"><span class="font-semibold">Click to upload</span> or drag and drop</p>
<p class="text-xs text-gray-500 dark:text-gray-400">SVG, PNG, JPG or GIF (MAX. 800x400px)</p>
</div>
<input id="dropzone-file" type="file" class="hidden" />
</label>
</div>
</div>

You can change border styles at different screen sizes using responsive prefixes like md: and lg:. This example shows a border-dotted on small screens which becomes a border-solid on medium screens and larger.

<div class="p-8">
<div class="p-6 text-center text-slate-700 dark:text-slate-200 bg-slate-100 dark:bg-slate-800 rounded-lg
border-2 border-purple-500 border-dotted
md:border-solid">
I have a dotted border on small screens, and a solid border on medium screens and up.
</div>
</div>