Fireship · @fireship

Advanced Dropdown Menu - React & CSS Animation Tutorial for Beginners

Uploaded April 17, 2020 · Length 16:52

Advanced Dropdown Menu - React & CSS Animation Tutorial for Beginners

Summary

Create a multi-level animated dropdown menu using React and CSS animation for beginners.

  • react
  • css animation
  • dropdown menu
  • beginner tutorial
  • ui design

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    I don't log into Facebook often but the

  2. 0:01

    last time I did I was super impressed by

  3. 0:03

    its simple intuitive and fast new UI in

  4. 0:06

    today's video I'll show you how to

  5. 0:07

    reverse engineer some of its UI features

  6. 0:09

    specifically the top navigation bar is

  7. 0:12

    icon buttons and this multi-level

  8. 0:13

    animated drop-down will do it using HTML

  9. 0:16

    CSS and because I mentioned the word

  10. 0:18

    Facebook I'm legally obligated to use

  11. 0:20

    react in this demo in the following code

  12. 0:22

    tutorial you'll learn how to create icon

  13. 0:24

    buttons with flexbox you'll learn how to

  14. 0:25

    use CSS transforms to create sliding

  15. 0:28

    animations and fundamental concepts in

  16. 0:30

    react white component composition hooks

  17. 0:32

    and how to create CSS animations based

  18. 0:34

    on the state of your react application

  19. 0:36

    and I'll throw in a bunch of other cool

  20. 0:37

    tips along the way if you're new here

  21. 0:39

    like and subscribe and let me know if

  22. 0:41

    you want to see more beginner friendly

  23. 0:42

    UI tutorials like this in the comments

  24. 0:44

    before we get started let's take a

  25. 0:46

    closer look at what we're building today

  26. 0:47

    by the end of this video

  27. 0:48

    you'll have several reusable react

  28. 0:50

    components that you can use for

  29. 0:51

    navigation and drop downs at the top we

  30. 0:53

    have a navbar component where the

  31. 0:55

    children are nav items represented at

  32. 0:57

    icon buttons these buttons have children

  33. 0:59

    that you can toggle on or off by

  34. 1:01

    clicking them when we click the carrot

  35. 1:02

    it renders our drop down component it

  36. 1:04

    contains multiple drop down items and

  37. 1:06

    the ones with a chevron can toggle to a

  38. 1:08

    secondary drop down menu notice how the

  39. 1:10

    hold menu slides out to the left and the

  40. 1:12

    new one comes in from the right and

  41. 1:13

    because the height of the two menus

  42. 1:15

    won't be the same we'll animate that as

  43. 1:16

    well now before we get started I'd just

  44. 1:18

    like to say this is a beginner friendly

  45. 1:19

    video but we move at a very fast pace on

  46. 1:22

    this channel so feel free to pause the

  47. 1:23

    video or slow down the playback speed as

  48. 1:25

    you follow along the first thing we'll

  49. 1:27

    need is a react app assuming you have no

  50. 1:29

    js' installed open up the command line

  51. 1:30

    and run npx create react app and of

  52. 1:33

    course the name of our app is Facebook

  53. 1:35

    to keep this demo simple I'm going to

  54. 1:37

    delete everything that's not the index

  55. 1:39

    JSF KS or index dot CSS files the

  56. 1:42

    index.js file is your initial entry

  57. 1:44

    point I'll go ahead and remove the

  58. 1:45

    serviceworker stuff here then you can

  59. 1:47

    ignore this file for the rest of the

  60. 1:48

    video from there I'm removing all the

  61. 1:50

    boilerplate code from the app.js file

  62. 1:52

    will be using functional react

  63. 1:54

    components in this video when you see a

  64. 1:55

    function whose name starts with a

  65. 1:57

    capital letter you can think of that as

  66. 1:58

    a component the return value of a