I’m new to frontend development but have about 3 years with Angular and 2 years with React. Recently, I started a project to build a ‘vscode-like’ experience for industrial automation operators just for fun. My basics in frontend are weak, so I decided to improve them by focusing on JavaScript, CSS, and HTML. I was amazed at how powerful CSS classes could be when applying functionality, like making elements draggable or hidden, simply by adding a class. In my experience with Angular and React, we usually wrap components to add such behaviors. Plus, many animations can be done with simple CSS instead of JavaScript. So, why do most popular frameworks like React focus on HTML and JavaScript for functionality and push CSS to the side? Is there a reason why they don’t use CSS for functionality more often?
react and angular focus on js becuz dynamic behavior is needed for most apps. css is great for styling n basic stuff, but js offers more control. also, more devs are familiar with js. check out css-in-js solutions tho; they blend both worlds. happy coding!
Really interesting point! Do you think the rise of CSS-in-JS solutions like styled-components might change how frameworks balance CSS and JS? What challenges have you faced with using CSS alone for functionalities so far?
In the end, it’s primarily about separation of concerns and the versatility that JavaScript brings to the table. Frameworks like React and Angular emphasize using JavaScript for behavior because of its ability to handle complex, dynamic interactions that CSS alone struggles with. JavaScript’s functionalities align well with the component-based architecture of these frameworks. However, don’t discount CSS entirely. Modern CSS features and CSS-in-JS solutions can indeed offer a powerful way to handle various styling and even some interactions without overshadowing JavaScript’s role in functionality.