FAQ Accordion using React.js

Solution retrospective
I had some trouble with importing fonts into Tailwind. My paths to the font files are relative and when I ctrl + click them it leads me to the file in VS Code. The import statements for the fonts in globals.css are as follows:
@layer base { @font-face { font-family: WorkSans; font-weight: 400; src: url('/public/static/fonts/WorkSans-VariableFont_wght.ttf') format("ttf"); } @font-face { font-family: WorkSans; font-weight: 400; font-style: italic; src: url('/public/static/fonts/WorkSans-Italic-VariableFont_wght.ttf') format("ttf"); } @font-face { font-family: WorkSans; font-weight: 600; src: url('/public/static/fonts/WorkSans-VariableFont_wght.ttf') format("ttf"); } @font-face { font-family: WorkSans; font-weight: 600; font-style: italic; src: url('/public/static/fonts/WorkSans-Italic-VariableFont_wght.ttf') format("ttf"); } @font-face { font-family: WorkSans; font-weight: 700; src: url('/public/static/fonts/WorkSans-VariableFont_wght.ttf') format("ttf"); } @font-face { font-family: WorkSans; font-weight: 700; font-style: italic; src: url('/public/static/fonts/WorkSans-Italic-VariableFont_wght.ttf') format("ttf"); } }
Additionally, I found that Tailwind would only animate the accordion expanding if I explicitly defined the height of the container (h-0 to h-32 works, but h-0 to h-auto didn't). However, this means the container for the answer text will either be too small or too large depending on the screen size/amount of text. Is there a way to animate from h-0 to h-auto with Tailwind, or would the best solution be to animate the expanding and collapsing from scratch?
Please log in to post a comment
Log in with GitHubCommunity feedback
- P@DeyanTopalov
Hey Daniel,
Great work on the Challenge!
Regarding the trouble with the fonts, I recommend using next fonts as it is super easy and has much more benefits. Please find a a great YouTube video about Next fonts:
https://www.youtube.com/watch?v=L8_98i_bMMA
Regarding the animation from h-0 to h-auto, I have this implemented in my solution. Feel free to check it out (it's in the accordion.jsx component).
I hope you find this helpful, and keep the good work!
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