Skip to content

Stef432/tailwind-css-intro

Repository files navigation

TailwindCSS Intro

What

This is a TailwindCSS intro created by Niamh Doyle. Also covered is an intro to daisyUI, Material UI Icons and Pravatar avatars. Links to all these are below.

Today's objective

  • Have fun
  • De-scarify CSS libraries
  • Demonstrate how painless and easy it is to use Tailwind/Daisy/Icon libraries
  • Demonstrate how it can supercharge development of your projects
  • Have fun!
  • Oh, and also learn a little.

What we will be doing today

  • This is purely styling tutorial. You won't be writing any JavaScript/React. All the React code has already been written for you.
  • We will be designing a card with text and icons and adding styling to the card, buttons and page
  • I have gone with a person for this tutorial, but you are free to make a card for a pet or a place, etc. Feel free to use the Pravatar images or choose one of your own

Branches

There are 3 branches.

You can find out what branch you are currently on by entering in the terminal:

git branch

The currently-viewed branched with be marked with an asterix (*).

Switch to a different branch by entering:

git checkout <name of branch>

Branch "main"

Branch "main" contains our starting point for today and the branch we will be working in. In a real project you wouldn't work in main (rather a branch called "dev" or "feature x" but this is just a tutorial on styling)

starter image

Branch "final"

Branch "final" contains one possible goal state

(You can also have a peek at the final code on GitHub if you get stuck during the tutorial.)

final image

Branch "setup"

Branch "setup" has the Tailwind/Daisy/Material setup code but nothing else, so you can use it as a jumping off point for your own future projects, should you wish.

setup image

Let's get started!

This project has been set up so there is no need to run any commands other than:

Install packages:

npm i

The index.html file takes its styles from ./src/output.css, so running the below will ensure that the output.css file is always up-to-date with changes to your CSS. Leave this terminal running (don't kill it!) If at any point it dies or you need to restart, just run the below line again.

npx tailwindcss -i ./src/index.css -o ./src/output.css --watch

In a separate terminal:

npm run dev

Steps

Branches

  1. Look at starter code on main (three main components – app, form, card; app has a reducer function to manage state updates)
  2. Checkout final branch
  3. Switch back to main
  4. Create branch "starter" to save start state (but don't checkout; stay on main)

Page/layout styling

  1. Uncomment code in index.css
  2. Apply a data theme (of your choice) in index.html

Buttons

  1. Open form
  2. Style buttons to your preference
  3. Notice basic input validation
  4. Notice conditional button disabling
  5. (Optional) Alter style of input elements

Name

  1. Update name by submitting data via form

Photo

  1. Click button to randomise starting avatar
  2. Choose a person or animal or place, etc. for card.

Card

  1. Apply margins, paddings, flex, flex gaps
  2. Apply text typographic styling
  3. Add icons
  4. Add badges

Resources for today

Material Icons

Material Icons we will use today (feel free to use the ones you prefer!)

DaisyUI

daisyUI themeing and components (button, badge):

Tailwind CSS

TailwindCSS utility classes (feel free to explore during the tutorial to find the necessary class name)

Pravatar:

(You can also have a peek at the final code on GitHub if you get stuck during the tutorial.)

Links and resources for further reading (for AFTER the tutorial, if interested)

Tailwind CSS

A utility-first CSS framework.

DaisyUI

DaisyUI is a component class name library built on top of Tailwind CSS.

Material UI

Material UI is an open-source React component library that implements Google's Material Design. The library comes with icons that are versatile and easy to use.

Pravatar

Contains avatars perfect for using in practice projects / when developing.

Remote tracking

If you want to add remote tracking for a branch run:

git checkout <name of branch>
git branch
git push -u origin <name of branch>

About

Tailwind CSS intro (also daisyuI and Material Icons)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors