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

FAQ Accordion Card - React and SASS

matiussi•155
@matiussi
A solution to the FAQ accordion card challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hello o/ This is my attempt for the FAQ challenge, I managed to complete it without using Javascript, but I couldn't create a reverse animation for the dropdown using only CSS (I used checkbox and label), if there is a way to do this using only CSS I would be glad to know :D

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • P
    Dave•5,295
    @dwhenson
    Posted about 4 years ago

    Hi @laura-2035 - Great work on this one! 🙌

    Your solution looks great!! But I'm a bit confused - I was looking forward to seeing how you managed this without JavaScript, but it seems the page requires JavaScript to work? Sorry if I'm missing something here? When I disable JS nothing loads...

    Just a point on your HTML, you might like to consider using the details and summary tags rather than a checkbox inside a div for the questions and answers. I think this would be more semantic, and possibly easier to style.

    I also can't tab through any of the interactive elements on the page, which would be nice to be able to do.

    For animations on the opening and closing without JS, you can do something like:

    details[open] summary ~ * {
    	animation: sweep 0.2s ease-out;
    	will-change: opacity, transform;
    }
    
    @keyframes sweep {
    	0% {
    		opacity: 0;
    		transform: translateY(-1em);
    	}
    
    	100% {
    		opacity: 1;
    		transform: translateY(0);
    	}
    }
    

    You could replace details[open] summary with input:checked ~ label if you wanted to keep to your current HTML structure, but I'm not 100% sure about the accessibility of that, and the details/summary approach is definitely semantically better.

    Hope this helps - as I said your solution looks great so this is really some 'behind the scenes' stuff to think about.

    Cheers 👋 and great work on this one!

  • matiussi•155
    @matiussi
    Posted about 4 years ago

    Hello @dwhenson o/ Thanks for the feedback!!!

    I forgot to mention that I generated the FAQ list using JS (just to test the map() in .jsx files) 😅

    I never heard about the summary and details tags before, it's way better than using label and checkbox, and easier to style as you mentioned.

    I also appreciate the opening animation!! Now the FAQ seems more visually appealing!

    Have a wonderful day 😁😁😁

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

Oops! 😬

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

Log in with GitHub