Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted 4 months ago

Responsive Grid with React, Tailwind CSS, and Dynamic Styling

tailwind-css, react
P
tasosbeast•150
@tasosbeast
A solution to the Testimonials grid section challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


What are you most proud of, and what would you do differently next time?

I'm most proud of successfully implementing a responsive grid layout that accurately matches the design while adapting to different screen sizes. The card component's dynamic styling system—using object mappings for colors, text styles, and grid positioning—turned out to be an elegant solution that made the code more maintainable.

If I were to approach this project again, I would focus on simplifying my workflow to reduce development time:

  • Start with a better component structure - I spent too much time refactoring my Card component. Next time, I'll plan the component hierarchy before writing code.

  • Use utility classes more efficiently - I created several custom style objects in my components when I could have leveraged Tailwind's built-in utilities more consistently.

  • Simplify data management - Moving data to a separate file was helpful, but I could have structured it more efficiently from the start.

  • Focus on mobile-first implementation - While I did use a mobile-first approach, I sometimes found myself making unnecessary adjustments. A stricter mobile-first discipline would save time.

These adjustments would help me complete similar projects more efficiently while maintaining high-quality results.

What challenges did you encounter, and how did you overcome them?

While building this testimonial grid section, I encountered several challenges that pushed me to find creative solutions:

  1. Dynamic Styling Based on Card Type: Each card needed unique styling (colors, backgrounds, grid positioning). Rather than hardcoding styles for each card, I created mapping objects that connected card identifiers with appropriate classes:
const cardColors = {
  card1: "bg-Purple-500",
  card2: "bg-Grey-500",
  card3: "bg-White",
  card4: "bg-Dark-blue",
  card5: "bg-White",
};

This approach made the code more maintainable and easier to update.

  1. Complex Grid Layout: the layout required different cards to span multiple columns/rows at different breakpoints. I solved this by creating a gridProperties object that defined positioning for each card:
const gridProperties = {
  card1: "md:col-span-2",
  card4: "md:col-span-2",
  card5: "md:col-span-2 xl:row-span-2 xl:row-start-1 xl:col-span-1 xl:col-start-4",
};

3.SVG Background Image: Getting the quotation background image to appear correctly on the first card was tricky. I resolved this by creating a custom utility class in my CSS that properly positioned the SVG:

@utility bg-quotation {
  background-image: url("./assets/images/bg-pattern-quotation.svg");
  background-position: 85% 0%;
  background-repeat: no-repeat;
}

4.Custom Font Integration: Incorporating the Barlow Semi Condensed font with multiple weights required careful configuration of font-face rules and ensuring they were properly applied throughout the application.

By approaching each challenge systematically and leveraging the flexibility of React components and Tailwind CSS, I was able to create a responsive, visually accurate implementation of the design.

What specific areas of your project would you like help with?

I'm looking for feedback on the following aspects of my implementation:

  1. Grid Layout Optimization: I've implemented the testimonial grid using Tailwind's responsive grid system, but I'm curious if there are more efficient ways to handle the complex layout requirements, especially handle the varying card sizes across different breakpoints.
const gridProperties = {
  card1: "md:col-span-2",
  card2: "md:col-span-2",
  card3: "md:col-span-2",
  card4: "md:col-span-2",
  card5: "md:col-span-2 xl:row-span-2"
};
  1. Dynamic Styling Pattern: I've used object mappings to apply different styles to each card based on its className prop. For me, this works, but I'm curious if there are better patterns for managing component variants:
const cardColors = {
  card1: "bg-Purple-500",
  card2: "bg-Grey-500",
  card3: "bg-White",
  // ...
};
// ...
  1. Background Image Integration: I've had trouble with the quotation mark background image on the first card. Would using a different approach to background images with Tailwind help?

  2. Component Structure: Is my current Card component too complex? Should I consider breaking it down further into smaller components?

  3. Tailwind Theme Extension: I'm using custom color variables. Is extending Tailwind's theme the best approach or should I rely on CSS custom properties?

Any advice on these specific areas would help me improve both this project and my approach to similar projects in the future!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • orbdev1•130
    @orbdev1
    Posted 4 months ago

    Nice job Tatos! I thinks just 3 little observations:

    • In comment of Patrick Abrams, is cut the 'headline'
    • In mobile design, top and bottom there is not margin/padding
    • Need add a bit more of shadow, try with different values

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub