0

I found a great accordion solution on the internet and wanted to try it. The difference between the example and my code is I used max-height-fit instead of max-height-20.

Here is my code:

<div className="relative overflow-hidden">
  <input
    type="checkbox"
    className="peer absolute top-0 inset-x-0 w-full h-12 opacity-0 z-10 cursor-pointer"
  />
  <div className="bg-gray-500 h-12 w-full pl-5 flex items-center">
    <h1 className="text-lg font-semibold text-white">Offline</h1>
  </div>

  <div className="absolute top-3 right-3 text-white transition-trasnform duration-500 rotate-0 peer-checked:rotate-180">
    <FontAwesomeIcon icon={faChevronDown} />
  </div>
  <div className="overflow-auto transition-all duration-500 max-h-0 peer-checked:max-h-fit">
    {players
      .filter((p: any) => p.name.toLowerCase().includes(search))
      .map((player: any) => {
        return (
          <div className="flex py-4 border-b-2 border-gray-700 hover:bg-gray-800/90 last:border-b-0">
            <div className="ml-5 -mt-1 bg-gray-700 w-8 h-8 text-center leading-8 rounded-full">
              {player.ID}
            </div>
            <div className="ml-5 flex grow">
              <div className="w-full">
                {player.name} ({player.level})
              </div>
              <div>
                {player.isAdmin && (
                  <FontAwesomeIcon className="mr-5" icon={faCrown} />
                )}
              </div>
            </div>
          </div>
        );
      })}
  </div>
</div>

Ed Lucas
  • 5,955
  • 4
  • 30
  • 42
Ozan Mudul
  • 750
  • 1
  • 9
  • 20
  • Answered here: https://stackoverflow.com/questions/71870743/tailwind-height-transition-not-working-on-h-min-h-fit-h-max-and-h-auto/71875527#71875527 – Ed Lucas May 26 '22 at 19:38
  • oh, shoot! thanks though arbitrary values do not fit my situation. I will try to approach this in a different way – Ozan Mudul May 26 '22 at 20:04

0 Answers0