JaxNode Feb 2022
# CHAPTER 2
JaxNode UG is always looking on people to present at upcoming meetings. Please contact me after the meeting or DM me @JaxNode
# CHAPTER 2
Tailwind is a utility first CSS framework. This gives developers precise control of the design by using CSS class names.
<div class="flex flex-wrap">
<h1 class="flex-auto text-lg font-semibold text-slate-900">
Classic Utility Jacket
</h1>
<div class="text-lg font-semibold text-slate-500">
$110.00
</div>
<div class="w-full flex-none text-sm font-medium text-slate-700 mt-2">
In stock
</div>
</div>
# PRESENTING CODE
# CHAPTER 2
You still need to know CSS to use Tailwindcss. Tailwind will allow you to style your content much quicker than if using plane styles.
input.css
You define a css file that includes any directives for components you need
Build
Tailwind scans you files for Tailwind classes that you use for your designÂ
Output
An output file is generated with just the classes you use in your project
# CHAPTER 2
/**
* This injects Tailwind's base styles and any base styles registered by
* plugins.
*/
@tailwind base;
/**
* This injects Tailwind's component classes and any component classes
* registered by plugins.
*/
@tailwind components;
/**
* This injects Tailwind's utility classes and any utility classes registered
* by plugins.
*/
@tailwind utilities;
# PRESENTING CODE
module.exports = {
theme: {
screens: {
sm: '480px',
md: '768px',
lg: '976px',
xl: '1440px',
},
colors: {
'blue': '#1fb6ff',
'pink': '#ff49db',
'orange': '#ff7849',
'green': '#13ce66',
},
extend: {
spacing: {
'128': '32rem',
'144': '36rem',
},
borderRadius: {
'4xl': '2rem',
}
}
}
}
# PRESENTING CODE
<!-- After extracting a custom class -->
<button class="btn-primary">
Save changes
</button>
<!-- input.css -->
@tailwind base;
@tailwind components;
@tailwind utilities;
@layer components {
.btn-primary {
@apply py-2 px-4 bg-blue-500 text-white font-semibold rounded-lg shadow-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:ring-opacity-75;
}
}
# PRESENTING CODE
Next.js | Laravel | Vite |
---|---|---|
Nuxt.js | Gatsby | Create React App |
SvelteKit | Angular | RoR |
Remix | Phoenix | Parcel |
ExpressJS |
<button class="px-4 py-2 bg-green-500 text-white rounded-xl hover:bg-green-300">
Press Me
</button>
# PRESENTING CODE
<style>
div.mybox {
display: flex;
flex-direction: row;
justify-content: center;
align-items: flex-start;
padding: 12px 6px;
}
</style>
<div class="flex justify-center items-start px-4 py-2">
Sample text
</div>