Created
September 18, 2023 17:10
-
-
Save danielotieno/a5b1a2f40abcd05ad3d57373d68142cf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Disclosure } from '@headlessui/react' | |
import { MinusSmallIcon, PlusSmallIcon } from '@heroicons/react/24/outline' | |
const faqs = [ | |
{ | |
question: "What's the best thing about Switzerland?", | |
answer: | |
"I don't know, but the flag is a big plus. Lorem ipsum dolor sit amet consectetur adipisicing elit. Quas cupiditate laboriosam fugiat.", | |
}, | |
// More questions... | |
] | |
export default function Example() { | |
return ( | |
<div className="bg-white"> | |
<div className="mx-auto max-w-7xl px-6 py-24 sm:py-32 lg:px-8 lg:py-40"> | |
<div className="mx-auto max-w-4xl divide-y divide-gray-900/10"> | |
<h2 className="text-2xl font-bold leading-10 tracking-tight text-gray-900">Frequently asked questions</h2> | |
<dl className="mt-10 space-y-6 divide-y divide-gray-900/10"> | |
{faqs.map((faq) => ( | |
<Disclosure as="div" key={faq.question} className="pt-6"> | |
{({ open }) => ( | |
<> | |
<dt> | |
<Disclosure.Button className="flex w-full items-start justify-between text-left text-gray-900"> | |
<span className="text-base font-semibold leading-7">{faq.question}</span> | |
<span className="ml-6 flex h-7 items-center"> | |
{open ? ( | |
<MinusSmallIcon className="h-6 w-6" aria-hidden="true" /> | |
) : ( | |
<PlusSmallIcon className="h-6 w-6" aria-hidden="true" /> | |
)} | |
</span> | |
</Disclosure.Button> | |
</dt> | |
<Disclosure.Panel as="dd" className="mt-2 pr-12"> | |
<p className="text-base leading-7 text-gray-600">{faq.answer}</p> | |
</Disclosure.Panel> | |
</> | |
)} | |
</Disclosure> | |
))} | |
</dl> | |
</div> | |
</div> | |
</div> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment