In the current times, we are all seeing a rise in online shopping.
Some shops however could use a bit of help.
You can choose if you want to rework an existing online shop, or create one from scratch.
The main goal of this workshop is to create a visually appealing store page.
The first step to installing tailwind.css is to make sure you have node npm installed.
use
npm --version
to verify that you have npm installed on your pc
To install tailwind.css fully you will need to go through a few steps.
You can link a stylesheet as we tend to do with bootstrap, this comes at a loss of some functionalities, an example of this is setting up custom colors.
In today's workshop we will go over the full set up, with instructions so you can look it up again should you want to try it in the future.
Make your repository/folder
Set up your basic files, index.html and your css file, this can be done later as well.
In your root folder, open your terminal and type the following code: npm init -y
this should create a package.json.
Once the package.json is made we install tailwind using npm install tailwindcss
.
In your css paste the following code at the top of your file:
@tailwind base;
@tailwind components;
@tailwind utilities;
Next we will set up an autoprefixer using npm install postcss-cli autoprefixer
.
This should install Postcss, which we will need to configure.
In your terminal you use npx tailwindcss init
to create your tailwind.config.js file, in this file you can define and customize your tailwind.
e.g. adding custom colours to your choices.
touch postcss.config.js
In this config file paste the following code:
module.exports = {
plugins: [
require('tailwindcss'),
require('autoprefixer'),
]
}
In your package.json look for the scripts.
In scripts you paste "build": "postcss main.css -o build/styles.css"
so it will look like:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "postcss main.css -o build/styles.css"
},
note that main.css should be changed to your css file name, or even the path to said css file.
npm run build
to execute the scripts.Important to know is that you will need to run this command each time you touch the config files.
add your built stylesheet to your html file.
<link rel="stylesheet" href="build/styles.css">
Time to start! You now should have succesfully installed tailwind.
For those that are curious, but not sure where to start tailwind wise.
I suggest taking a look at the tailwind cheatsheet this site has the corresponding css code as well as extra documentation for each component.
For those that prefer guides with practical examples I suggest to check out tailwind css for beginners.
Check out the following link for guides for other frameworks like vue.js, react, laravel
tailwind installation
possible errors
During installation I got a bug that starts with:
TypeError: Object.entries(...).flatMap is not a function[![enter image description here][1]][1]
TypeError: Object.entries(...).flatMap is not a function
This means that you should check your node version, if it's below v11.0 you will have to update your node version.
To add fonts/colors please refer to: customization
Looking for inspiration? Maybe give the following links a try.
color palettes:
colorsinspo
colorspace
visme colorschemes
Hexcolor random color generator
Have a picture, but don't know which colours are in it?
Hexcolor image to color
Photos and illustrations
PikWizard stock photos
free Illustrations
css Icons
Fonts
google fonts
not sure which font? Try a sentence in:
fontspark
Extra cheat sheet A more visual cheat sheet Tailwind.css cheat sheet
good tool to have but not really for this exercise
For those that really are more for instantly done code.
Though I would make sure you understand it first, or else you will get overwhelmed.
tailblocks