

Noticed a small delay in removing/adding the nav elements.Class names in Dev Tools are semantic and reflect the changes.Take note that the class name syntax uses the BEM approach to assigning class names. Here’s what those settings look like in developer tools when applied. The nav_container will only show on large desktops and higher (>1023) and the menu-icon will only show on medium and below ( The easiest is using small, medium, and large keywords to target breakpoints and then assigning up or down as to which direction they should apply. The library also provides a few configurations for listening for common breakpoints. This Higher Order Component now provides access to the Breakpoint Component in all child Components within the heirarchy. This essentially states that the rules defined here apply only when the window width is at a minumum of 1024ppx. Note: Media Queries were added to a separate responsive.css fileĬhanges to the window size are tracked using the CSS rule and setting the min-width to 1024px. So it goes without saying that the first approach to implementing responsive design is using Media Queries. I’ve seen countless CSS works of art on CodePen and on almost any given day I learn something new about CSS. The power of CSS never ceases to amaze and inspire. Mobile: width 1023 - Shows the navigation elements and hides the hamburger icon Note: The above demo is using the Inline-Style approachĪlthough this site has many responsive features, for the purpose of this demo I will be focusing solely on the navigation menu and making the following changes: Add/Remove/Update the necessary DOM elements to reflect those changes.Tracking changes to the window size (width/height).Higher Order Components - (React-Socks)Īs we review the different ways to implement responsive design, I’ll focus on the following points which must be accomplished regardless of which approach you take.So let’s take a look at 3 different approaches to implementing responsive design in your next React app. Even still, both novice and experienced developers alike might work with a front-end framework like Bootstrap or Materialize with predefined breakpoints and custom Components for making those changes.

Using the most basic approach, responsive design has been implemented using Media Queries, where a more experienced developer might opt to add event listeners that respond to the “resize” event and add/remove styles via JS. Responsive design was always a requirement and now that we’re building apps using the “mobile first” mindset, is even more important than ever. UI elements are now being rendered via their own Components with all the intent and purpose of reusability. Components, right from their introduction, went against the “separation of concerns” rule of thumb, choosing to leverage JSX and bringing together HTML and JS in the same file. React has truly been a game changer in how we now approach developing front-end applications for the web.
