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

Social proof section using React.JS and Tailwind CSS

react, tailwind-css
P
Nishanth Venkatesan•1,030
@nishanth1596
A solution to the Social proof 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?

This is my first challenge in tailwind css. I had to go through the documentation often to write code for this, at the end of the I feel happy for completing it.

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

I wanted to apply dynamic styles to the review and testimonial sections for larger screens using Tailwind CSS, but I was unable to do so. Instead, I created custom classes in index.css and applied them. Can someone review my approach and let me know if this is a good way of handling it?

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    markus•2,800
    @markuslewin
    Posted 6 months ago

    Hi!

    Yes, Tailwind doesn't support dynamic class names. Instead, you can use an object to map the ID to a complete class name, or write custom selectors using "arbitrary variants":

    // a) Map props to complete class names
    const marginById = {
      1: "lg:ml-12",
      2: "lg:ml-24",
    };
    
    const Review = ({ item }) => {
      return <div className={`${marginById[item.id] ?? ""}`} />;
    };
    
    // b) Custom selectors
    <div className="lg:[&:nth-child(2)]:ml-12 lg:[&:nth-child(3)]:ml-24" />;
    

    Regarding the heading, the problem is that hidden hides the level-one heading for assistive technology as well. The class you're looking for is sr-only, so that the heading is only visually hidden, but still accessible to screen readers!

    Marked as helpful
  • Aakash Verma•9,500
    @skyv26
    Posted 6 months ago

    Hi @nishanth1596,

    Here’s some feedback and suggestions based on the points you provided. I hope these are helpful in refining your project! 🚀


    1. Large Screen Design

    • As mentioned earlier, ensure your designs are tested and optimized for larger screens. This ensures a consistent and polished user experience across all devices. 😊

    2. Avoid Using <section> for Single Containers

    • Since the webpage is a single container, the <section> tag isn't necessary in this context. It might add unnecessary semantics and could confuse maintainers about the document structure. Consider simplifying it with a <div> instead. 👍

    3. Remove Comments from Production Code

    • Keeping comments in production code can make it look unprofessional and cluttered. While they’re great for local testing and debugging, it’s good practice to remove them before committing or deploying.
    • You can use tools like eslint or prettier to enforce this. 🔧

    4. Conditional Styling for Reviews or Cards

    • Your idea of using breakpoints to style elements like cards or reviews is fantastic!
    • For example, this snippet demonstrates a good practice:
      className="card rounded-lg bg-f7f2f7 lg:flex lg:max-w-[27.81rem] lg:items-center xl:bg-[#555555]"
      
      Using utility classes dynamically based on screen size improves responsiveness and enhances the visual hierarchy. Keep it up! 🎨

    Let me know if you need further assistance or clarification! 👨‍💻✨

    Marked as helpful

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

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

Oops! 😬

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

Log in with GitHub