Skip to content

Tailwind Introduction

Tailwind CSS is a utility-first CSS framework. Instead of writing custom CSS rules, you apply small, single-purpose classes directly in your HTML. Click here to access the Tailwind docs.

We previously used Bootstrap, but swapped because Tailwind is:

  • Unopinionated - No “default” styling to compete with.
  • JIT compiled - Only used classes end up in CSS bundle.
  • Industry standard - Most popular CSS framework.

Since Vue uses SFCs (Single File Components), writing CSS in <style scoped> is already convenient. However, prefer Tailwind utility classes for common styling needs like spacing, layout, and colors.

Example - Instead of:

<template>
<h1 class="im-a-heading">This is a Heading<h1>
</template>
<style scoped>
.im-a-heading {
padding: 4rem;
}
</style>

Do

<template>
<h1 class="p-16">This is a Heading<h1>
</template>

Use <style scoped> only when:

  • You need custom styles not covered by Tailwind (e.g., a unique animation)
  • You are defining reusable component-level classes (eg., a button that appears several times in the component)

Throughout the codebase, you’ll see classes like px-2 and m-3. These control padding and margin.

  • m - margin
  • p - padding
  • t - top
  • b - bottom
  • l - left
  • r - right
  • x - left and right (horizontal)
  • y - top and bottom (vertical)
  • (omitted) - all sides

Tailwind uses a consistent spacing scale where each unit = 0.25rem (4px):

ClassValue
00
10.25rem (4px)
20.5rem (8px)
30.75rem (12px)
41rem (16px)
51.25rem (20px)
61.5rem (24px)
82rem (32px)
102.5rem (40px)
123rem (48px)
fullsize of container
ClassDescription
m-4Margin on all sides = 1rem
pt-2Padding top = 0.5rem
py-0Padding top & bottom = 0
ml-autoMargin left = auto
px-6Padding left & right = 1.5rem

Tailwind’s flexbox utilities replace verbose CSS:

ClassCSS
flexdisplay: flex
flex-colflex-direction: column
items-centeralign-items: center
justify-betweenjustify-content: space-between
gap-2gap: 0.5rem
w-fullwidth: 100%
h-fullheight: 100%
growflex-grow: 1
<div class="flex flex-col gap-2 h-full">
<div class="flex justify-between items-center">
<h4>Title</h4>
<span>Status</span>
</div>
<div class="grow">Content</div>
</div>

We define a set of reusable component classes in app.css:

  • btn, btn-sm - buttons
  • btn-danger, btn-success, btn-primary, btn-secondary, btn-info, etc. - button variants
  • btn-outline-danger, btn-outline-success - outline variants
  • modal-… - modal dialogs
  • list-item - list items

These are defined in <style scoped> blocks or app.css and provide consistent styling across the GUI. Use Tailwind for layout, use app.css classes for component styling.