Responsive Sticky Navbar that Shrinks on Scroll with Tailwind CSS & Alpine JS

Поділитися
Вставка
  • Опубліковано 19 вер 2024
  • This is a tutorial to create a sticky navigation bar that shrinks when the user scrolls up, using Tailwind CSS & Alpine JS. The navigation is completely responsive too, with a full page menu toggle.
    CodePen Demo Link : codepen.io/shr...
    ------
    This video is sponsored by Showwcase: Join me - www.showwcase.com using the invite code "joinshrutibalasa"
    ------
    Work illustrations by Storyset - storyset.com/c...
    Subscribe and stay tuned for tips, tutorials and more.
    Follow me on Twitter: / shrutibalasa
    Follow Thirus on Twitter: / thirusofficial
    Visit my website: www.shrutibala...
    #alpine #alpinejs #tailwind #tailwindcss #navbar #shrinkonscroll #responsivenav

КОМЕНТАРІ • 102

  • @necatbolpaca7882
    @necatbolpaca7882 3 роки тому +1

    10:18 - "Yeah. So that's what we needed and that's what we have." is my favorite moment on this tutorial.

  • @theSavanahDev
    @theSavanahDev 3 роки тому +6

    I like your Tailwind videos. This one is one of the best so far, keep them coming.

    • @Thirus
      @Thirus  3 роки тому

      That feels so awesome to know! Thank you :)

    • @kidbrave_7673
      @kidbrave_7673 Рік тому

      I second that comment! I'm new to tailwind and alpine. I was pretty nervous diving into alpine because of the syntax as well as the steps to installing tailwind, but through your videos, you've made it seamless to follow along and learn both technologies at any level as a developer. Thank you, Thirus! 🙏

  • @shahinmirza9934
    @shahinmirza9934 Рік тому +2

    :class="[navbarOpen ? 'translate-x-0' : 'translate-x-full' ]" is a shorter and better way for wrighting conditional statements, but great job on explaining tailwindCss. thank you! Love from Iran.

  • @paulfontaine7819
    @paulfontaine7819 8 місяців тому +2

    Great content and approach. Thanks.
    One detail: I prefer
    `@scroll.window="scrolledFromTop = window.pageYOffset > 50"` because it's more concise.
    But your version may be easier to read from some people.

    • @Thirus
      @Thirus  8 місяців тому

      Thank you..

  • @mainjambunge2402
    @mainjambunge2402 2 роки тому +4

    Awesome tutorial, I love the way you use Alpine JS.

    • @Thirus
      @Thirus  2 роки тому +1

      Thank you 😊

  • @gdogmalone
    @gdogmalone 3 роки тому +5

    Fantastic, thanks. Wish I’d had this last week as it’s taken me all of last week to build this - and not as well! Couldn’t get transitions to work, which you solved with transition all! Thanks again!

    • @Thirus
      @Thirus  3 роки тому +1

      You’re welcome!

  • @swathiashok4923
    @swathiashok4923 Рік тому +1

    I just Amazed! Your way of teaching is next level. Anyone can learn easily. Thank you, Shruthi.

    • @Thirus
      @Thirus  Рік тому

      Glad to hear that Swathi :) Thank you

  • @Codefide
    @Codefide Рік тому +2

    Excellent tutorial. I found this very helpful. Thanks a lot.

    • @Thirus
      @Thirus  Рік тому

      You’re welcome :)

  • @webdevluc
    @webdevluc 3 роки тому +2

    Awesome tutorial Shruti, love it, thanks for creating and sharing it with us

    • @Thirus
      @Thirus  3 роки тому

      Glad you loved it Lucian 😊

  • @MohdRusmanAriefARahman
    @MohdRusmanAriefARahman 3 роки тому +1

    Thank you for making this Shruti.

    • @Thirus
      @Thirus  3 роки тому

      You’re welcome :)

  • @wieN4rn0
    @wieN4rn0 3 роки тому +2

    It's a perfect tutorial as usual...

  • @talkathiriify
    @talkathiriify 3 роки тому +1

    Excellent as usual.
    Thank you very much Shruti for your time and efforts.

    • @Thirus
      @Thirus  3 роки тому

      My pleasure 😊

  • @kouceylahadji
    @kouceylahadji 3 роки тому +1

    I switched recently to tailwind and this thing comes to the best time, I never carried how to do it in bootstrap
    Still want easy and best component for modals

    • @Thirus
      @Thirus  3 роки тому +1

      That’s great! I think I should do a video on modal next

  • @amans6504
    @amans6504 2 роки тому +2

    Such a smooth tutorial.. my fear of css is getting out slowly

    • @Thirus
      @Thirus  2 роки тому +1

      What an amazing compliment. Thank you. Have you checked out my ebook yet? A complete guide to CSS flex and grid concepts with 70+ real world examples and working demos - shrutibalasa.gumroad.com/l/css-flex-and-grid

    • @amans6504
      @amans6504 2 роки тому +1

      @@Thirus yes, i saw that on your twitter profile.. will check it surely

  • @liviuiurcu9709
    @liviuiurcu9709 Рік тому +1

    Recent I found your channel, contents with Tailwind and Alpine is amazing. You are the BEST!!! What Formatter do you use for your code? Is nice and clean.

  • @RobMatthews21
    @RobMatthews21 Рік тому +1

    Fantastic thank you. Can you do a video in how to create expanding links to show sub-links in the mobile menu.

  • @hb.1234
    @hb.1234 Рік тому +1

    Wow, great... thank you 🙂

    • @Thirus
      @Thirus  Рік тому

      You’re welcome!

  • @jvenkatonline
    @jvenkatonline 2 роки тому +3

    Its really nice. The combination of TailwindCSS and AlpineJS, its very new. You did a fantastic job. But one thing, I would like to check with you why did you select AlpineJS for functionality? Is it very easy to use and implement - just I want to know whether it will help me for my project or not.

    • @Thirus
      @Thirus  2 роки тому +3

      Glad you liked it. I chose Alpine JS because it’s the most lightweight framework out there. It’s best suited for such functionalities where vanilla JS would need so many lines of code and other frameworks like Vue would be too heavy

  • @achmadfauzi3755
    @achmadfauzi3755 2 роки тому +1

    thank you sis

    • @Thirus
      @Thirus  2 роки тому

      You’re welcome!

  • @tstarfish8829
    @tstarfish8829 Рік тому +1

    Good, but it is not scrolling to the right positions from the navbar links. Sections are below the navbar. It needs to handle the navbar responsive height ;)

    • @Thirus
      @Thirus  Рік тому +1

      Yes, agreed. Can be done using “scroll padding” property. Recently wrote about it www.getrevue.co/profile/shrutibalasa/issues/did-you-know-about-scroll-padding-easy-solution-to-fixed-header-problem-1325973

  • @DhiBeney
    @DhiBeney 3 роки тому +1

    Very good tutorial.

    • @Thirus
      @Thirus  3 роки тому

      Thank you!

  • @DisasterSPA
    @DisasterSPA 2 роки тому +1

    I noticed that the menu goes over the header and there's a gap underneath it. any way to fix this?

    • @Thirus
      @Thirus  2 роки тому

      I didn’t understand. Can you DM a screenshot on Twitter?

  • @ongomobile9956
    @ongomobile9956 2 роки тому +1

    Thank you so much very cool 🏄‍♂🤠

    • @Thirus
      @Thirus  2 роки тому

      Glad you liked it :)

  • @Raj-iz9uz
    @Raj-iz9uz 3 роки тому +1

    Superb 🔥🔥🔥 pls if possible teach JavaScript 🙏🏻 I like the way you Explain..
    ❤️ from Chennai 😊

    • @Thirus
      @Thirus  3 роки тому +1

      JavaScript is not in my list right now 😊 But I’ll surely consider it!

  • @GreatCaleb
    @GreatCaleb 3 роки тому +1

    Awesome content

    • @Thirus
      @Thirus  3 роки тому

      Thank you :)

  • @ahmedserag7072
    @ahmedserag7072 2 роки тому +1

    i need help i just start study tailwind css and about making it responsive i lost cuz sm refer to small devices from 0 to max-width:768px this right or not

    • @Thirus
      @Thirus  2 роки тому +1

      No, ‘sm’ is from 640px to 768px. Don’t use any prefix to add styles for 0 to 640px. Does that help?

    • @ahmedserag7072
      @ahmedserag7072 2 роки тому

      @@Thirus yup this was good and when search more i found that tailwind first is mobile design

    • @ahmedserag7072
      @ahmedserag7072 2 роки тому

      @@Thirus Thanks

  • @chethiyaprasanga
    @chethiyaprasanga 3 роки тому +1

    Better to add you ebook link also in the description . Thank you.

    • @Thirus
      @Thirus  3 роки тому

      Hey thanks for that tip! Never occurred to me 😀 I’ll go and edit all the video descriptions soon!

  • @smartdheena9352
    @smartdheena9352 2 роки тому +1

    just amazing..please make some more projects..or please make udemy course for us..plzz

    • @Thirus
      @Thirus  2 роки тому

      In the near future, for sure!

  • @aogunnaike
    @aogunnaike 3 роки тому +1

    Awesome 👍

    • @Thirus
      @Thirus  3 роки тому

      Thank you! :)

  • @MichaelBrown-vq4fd
    @MichaelBrown-vq4fd 2 роки тому +1

    Loved this tutorial. I learned quite a bit. One question, when shrinking the screen below :md breakpoint, the nav still uses the transition effect, causing the menu to "fly across the page" off screen as the hamburger menu appears in the duration 200. Is there a way to separate these out so it doesn't do that? I tried the below on the ul, but then I lose the nav slide in animation on :sm

    • @rogermarsh5933
      @rogermarsh5933 2 роки тому

      Did you figure this out?

    • @maxweber06
      @maxweber06 2 роки тому

      I imagine a dynamic class with a listener on which way the window is being resized would work. Basically, only set sm:transition-none when the last screen size was md and md:transition otherwise.

  • @sornt
    @sornt 3 роки тому +1

    great!!!
    Can you also make a use case of Tailwind CSS & Alpine JS for active menu based on where user scroll in one page landing page.

    • @Thirus
      @Thirus  3 роки тому

      You mean like scrollspy right? I tried that, but it doesn’t work great for sections that are too small. I can send you a CodePen link if you want

  • @jimmacdiarmid8230
    @jimmacdiarmid8230 2 роки тому +1

    Can you provide a link to the video where you create the landing page please? I didn't see it listed in the description or in the comments. Thank you! :)

    • @Thirus
      @Thirus  2 роки тому

      I haven’t created a video for this particular landing page. But you can find a lot of other similar videos on Tailwind CSS in this playlist - ua-cam.com/play/PLrC_WsW4VdT4k3LWVFpTGM4ryYlDnrEvz.html

  • @mohammedashfanmamdu556
    @mohammedashfanmamdu556 2 роки тому

    When i add tailwind ui code from their website.. for header.. the dropdown will be static displayed.. why is it so

  • @stephenlau2845
    @stephenlau2845 2 роки тому

    Thanks for your Tutorial....Yes, How can I display the "Contact" item on the navbar also when it use in mobile(0.28), and it will display in middle of the Logo and the toggle button(0:28), and the "Contact" item will not show the list item again while the toggle button is clicked(0.32) ? thanks again....

    • @Thirus
      @Thirus  2 роки тому

      Please DM @shrutibalasa on Twitter with screenshots.

  • @Codefide
    @Codefide Рік тому +1

    Do you have a tutorial on multi-level navigation menus?

    • @Thirus
      @Thirus  Рік тому

      Probably a good topic for my next tutorial

    • @Codefide
      @Codefide Рік тому

      @@Thirus Indeed! Because I have a slight glitch that is, when one of the sub-level menu's are open, and I click on another dropdown, both stay open. I will be working on a solution but I'm sure there will be other beginners who could do with a helpful tutorial

  • @maheshsangam6212
    @maheshsangam6212 Рік тому

    Hello Madam.. This is really opportunity to learn something really new thanks a lot for this video but I'm facing little problem this logo and menu is coming two edges only but i want to keep them in side my container keeps all content in middle with width 1280px but this logo and menu never fits in it shall we do that??? please kindly let me know thanks a lot!!!

    • @Thirus
      @Thirus  Рік тому

      Add these classes - “container” and “mx-auto” to keep the them within that width. If you can’t get it working, send me a DM on Twitter. x.com/shrutibalasa

  • @garbjorn1757
    @garbjorn1757 2 роки тому +1

    Can we use alpinejs in a nodejs express app?

    • @Thirus
      @Thirus  2 роки тому

      I haven’t used nodejs or express. But you should be able to

  • @mattiurrehmanbhatti
    @mattiurrehmanbhatti 3 роки тому +1

    Thanks, how to add drop-down menu in it?

    • @mfazaildotcom
      @mfazaildotcom 3 роки тому

      You can check here for responsive drop-down
      ua-cam.com/video/KNj3TkfrPq0/v-deo.html

  • @blackpurple9163
    @blackpurple9163 10 місяців тому

    How do we close the sidebar when link is clicked?

  • @MilindGoel15
    @MilindGoel15 2 роки тому

    Is it possible to create the half page nav instead of full page which when opened doesn't slide down the content of the page?

    • @Thirus
      @Thirus  2 роки тому

      It’s possible but a half page menu animating from the right might not look great. To animate it from top is tricky.

  • @ebam21
    @ebam21 2 роки тому

    Excelente, muchisimas gracias por compartir tus conocimientos con todos nosotros!! lastima que solo pueda dar un like

  • @entech5669
    @entech5669 2 роки тому +1

    Hey can you please teach state management in React ?

    • @Thirus
      @Thirus  2 роки тому +1

      I wish :) But I’m not a React dev

    • @entech5669
      @entech5669 2 роки тому

      @@Thirus oooh 🙁

  • @eshwerhari4989
    @eshwerhari4989 8 місяців тому +1

    Hi maam...can u do this in react?

    • @Thirus
      @Thirus  8 місяців тому +1

      Definitely possible. But I don’t know React

    • @eshwerhari4989
      @eshwerhari4989 8 місяців тому +1

      @@Thirusfine 👍

  • @quazisamihatasnim792
    @quazisamihatasnim792 2 роки тому +1

    is it possible using react js instead of alpine js?

    • @Thirus
      @Thirus  2 роки тому

      Should be possible. I haven’t used React

  • @isabsk10
    @isabsk10 2 роки тому +1

    How can we get that type beautiful illustrations free ?

    • @Thirus
      @Thirus  2 роки тому

      storyset.com

    • @isabsk10
      @isabsk10 2 роки тому

      @@Thirus Thank you ☺️

  • @usherkadio3861
    @usherkadio3861 2 роки тому

    how do you indent the words in your VSCode?

    • @Thirus
      @Thirus  2 роки тому

      What exactly are you asking?

    • @usherkadio3861
      @usherkadio3861 2 роки тому

      @@Thirus the way you indent the class in the tag please

  • @OnlyJavascript
    @OnlyJavascript 2 роки тому

    how to do this in vue 3

  • @JEsterCW
    @JEsterCW Рік тому

    Guys, never animate heights or widths, this is hella bad practice and can results in alot of glitches and performance issues even with one single animation/transition for height/width. For navbars size use paddings only, and its more performant to animate paddings aswell.