I built a Tabs component with 15 props once. It worked. Nobody could use it. Day 3 of my frontend system design series is about the 3-component patterns that actually solve this: → Custom hooks — share stateful logic across components → Compound components — build flexible UI as Radix/Headless UI does → Render props — give consumers full control over rendering The one that changed how I write components: Compound components. Instead of passing everything as props into one giant component, you give consumers a parent + child API. They control the structure. You control the state. That's how Tabs, Accordions, and Selects should be built. Full blog with code examples 👇 [link in first comment] Following GreatFrontend's system design curriculum and posting daily. Follow along if you're leveling up, too. #ReactJS #Frontend #JavaScript #WebDev #SystemDesign
Building Compound Components for Flexible UI with React
More Relevant Posts
-
Sometimes I just like to play around with code and build fun, slightly nonsensical things. So when someone asked me to create a dynamic puzzle effect, I briefly considered the “sensible” route of using SVG… but then decided it was the perfect excuse to experiment with the new shape() function in CSS. With a bit of help from custom properties, it turned into something fully dynamic, responsive, and capable of holding real content like images or text. If you want to build one yourself, I walk through everything, from the very first Tab and Socket, to handling real content inside the pieces. Let’s Get Puzzled! 🧩 (on Frontend Masters) https://lnkd.in/dBPZ8XxF Go break it, tweak it, and make something weird with it. 😉
To view or add a comment, sign in
-
Day 3 — Making Tech Simple. You open a website and see a beautiful UI in seconds… But have you ever thought 🤔 How does the browser actually build that UI? It’s not magic. It’s a process. Behind the scenes: • HTML → converted into a structure (DOM) • CSS → styles everything (colors, layout) • JavaScript → makes it interactive • Then browser calculates layout and paints pixels on screen All this happens in milliseconds That’s how raw code turns into a real website. If you understand this… 👉 You’ll write better code 👉 You’ll debug faster 👉 You’ll build faster UIs 📌 Day 3 of simplifying complex tech into easy visuals. Follow me if you want to master fundamentals (not just copy code). Comment “DAY 4” if you’re ready — Syed Shaaz Akhtar #WebDevelopment #Frontend #Programming #SoftwareEngineering #Developer
To view or add a comment, sign in
-
-
Building loading states shouldn’t feel like copy-paste work. Every React project ends up with the same repetitive loading UI code — divs, shimmer effects, duplicated layouts… again and again. So I built something to fix that. react-auto-skeletonizer An npm package that automatically generates skeleton loaders for your React components. No more manually crafting loading states. Just plug it in and let it handle the boring part. What it does: - Generates skeleton UI based on your components - Saves time and reduces repetitive code - Improves user experience with clean loading states Try it out: https://lnkd.in/gAjmubgD Would love to know what you think — feedback, ideas, or improvements are all welcome 🙌 #React #Frontend #JavaScript #OpenSource #npm #WebDevelopment
To view or add a comment, sign in
-
Have you ever built a perfectly designed tooltip or modal only to find it cut off by its parent container? It is the classic CSS 'overflow: hidden' trap. Your parent component needs to clip its own content, but your child component, like a dropdown or a popup, needs to break free from those boundaries to be visible. Because the child is physically nested inside the parent in the DOM, it is bound by the parent's styling rules and stacking context. This is exactly why React Portals exist. They provide a way to render a child into a different DOM node that exists outside the parent's hierarchy. Even though the child stays part of the React component tree and can still receive props or communicate with the parent, it physically lives somewhere else in the HTML, such as a div at the very end of the body tag. By teleporting the UI, you bypass the parent's 'overflow' and 'z-index' constraints entirely. Your tooltip can now float freely over the rest of the application without you having to mess with the parent's CSS and potentially breaking the rest of your layout. It is the ultimate escape hatch for complex UI components that need to live independently of their logical parents. It keeps your DOM structure clean and your UI accessible without the headache of fighting CSS inheritance. #ReactJS #SoftwareEngineering #WebDevelopment #Frontend #Javascript #CodingTips
To view or add a comment, sign in
-
-
My dear front-end developers (and anyone curious about where UI is heading): I’ve been experimenting with something that genuinely changes how we think about layout. Using @chenglou/pretext — a userland text layout engine — I built a demo where: Text layout is computed before rendering. No DOM measurements. No reflows. No guessing. The browser isn’t deciding layout anymore. Your code is. In this demo, text dynamically flows around: • your cursor • your face (real-time) All of it is powered by a pure TypeScript layout engine. 👉 https://lnkd.in/gX2V7V_p This might sound subtle, but it’s a big shift: From: “Render first, then measure” To: “Compute layout, then render once” Which means: • deterministic layout • zero layout thrashing • fully custom rendering (Canvas, WebGL, anything) We’ve relied on CSS layout engines for decades. But what if layout didn’t need the browser at all? Curious what you think — is this the future of UI, or are we overengineering something the browser already does well?
To view or add a comment, sign in
-
😳 𝗜 𝗿𝗲𝗮𝗹𝗹𝘆 𝘁𝗵𝗼𝘂𝗴𝗵𝘁 𝘁𝗵𝗶𝘀 𝗹𝗮𝘆𝗼𝘂𝘁 𝘄𝗮𝘀 𝗙𝗹𝗲𝘅𝗯𝗼𝘅 Until I tried to build it… and realized something felt off. That moment reminded me: 🧠 Knowing a tool is one thing Understanding how it behaves is another Some UI patterns look familiar… but work very differently under the hood Have you ever been 𝘤𝘰𝘯𝘧𝘪𝘥𝘦𝘯𝘵𝘭𝘺 𝘸𝘳𝘰𝘯𝘨 in coding? 😄 #frontend #webdevelopment #css #cssgrid #flexbox #developerlife
To view or add a comment, sign in
-
Most UI libraries: npm install @ui/library ❌ → Black box components → Hard to customize → Bundle bloat → Breaking changes with updates Velocity-UI approach: npx velocity-ui add button ✅ → Full source code in YOUR project → Modify anything, anytime → Tree-shaken, minimal bundles → You control updates 💡 The Copy-Paste + CLI Model: 1️⃣ Generate components via CLI npx velocity-ui add premium-card 2️⃣ Code lands in YOUR components/ folder Full TypeScript source, no abstractions 3️⃣ Customize freely It's YOUR code now. No vendor lock-in. 4️⃣ Interactive previews & docs See it live before you commit Built with: • Next.js App Router ready • TypeScript props with sensible defaults • Framer Motion for buttery animations • Dark-mode first design system 🔗 This is how modern UI development should work. #WebDevelopment #Frontend #React #NextJS #DeveloperExperience #CodeQuality #TechInnovation #Programming #SoftwareEngineering
To view or add a comment, sign in
-
Tired of building UI from scratch every time… So I built my own Component Library ⚡ 🔗 GitHub: https://lnkd.in/gz_vRwND 🔗 Vercel: https://lnkd.in/gjwbZbcA ✨ Built with React + Tailwind ✨ Clean & reusable components ✨ Live preview + copy code ✨ Dark mode + responsive How to use: 1. Browse components 2. Click "Show Code" 3. Copy & paste into your project 4. Customize as needed “Browse → Copy → Use → Customize” This project helped me improve: UI design thinking Component reusability Real-world frontend skills Still improving it — feedback is welcome 🙌 #ReactJS #TailwindCSS #FrontendDeveloper #WebDevelopment #UIUX #JavaScript #OpenSource #100DaysOfCode #Developer #Portfolio
To view or add a comment, sign in
-
A lot of UI behaviors and interactions that used to require JavaScript can now be handled natively with modern CSS. Small capabilities like tooltips, smooth scrolling, responsive layouts, selection control, and even some visual depth effects are now much easier to build with less complexity in the frontend. It is a good reminder that modern CSS has evolved far beyond styling alone and can often simplify implementation while keeping the experience polished. I used Codex to turn this idea into a visual, and it was interesting to compare it with my usual Claude Code + Remotion workflow. #csshtmljs #webdev #frontend #programming #uidesign
To view or add a comment, sign in
-
Everyone is experimenting with this new text engine. Here is what it actually looks like in a real UI. Text reflows around moving elements in real time. Smooth, no layout breaks. I built an interactive demo 👇 https://lnkd.in/ezshxrKB Built with Pretext by Cheng Lou: https://lnkd.in/eex7dUWH Would you use this in production? #Frontend #JavaScript #WebDev #BuildInPublic #Pretext
To view or add a comment, sign in
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development
Full blog here https://kunalgoel.hashnode.dev/component-design-patterns-every-react-dev-should-know-compound-components-render-props-custom-hooks