/* This example requires some changes to your config: ``` // tailwind.config.js module.exports = { // ... plugins: [ // ... require('@tailwindcss/forms'), ], } ``` */ import { Fragment, useState } from 'react' import { Combobox, Dialog, Transition } from '@headlessui/react' import { MagnifyingGlassIcon } from '@heroicons/react/20/solid' import { UsersIcon } from '@heroicons/react/24/outline' import { ChevronRightIcon } from '@heroicons/react/20/solid' const people = [ { id: 1, name: 'Leslie Alexander', phone: '1-493-747-9031', email: 'lesliealexander@example.com', role: 'Co-Founder / CEO', url: 'https://example.com', profileUrl: '#', imageUrl: 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80', }, // More people... ] const recent = [people[5], people[4], people[2], people[10], people[16]] function classNames(...classes) { return classes.filter(Boolean).join(' ') } export default function Example() { const [query, setQuery] = useState('') const [open, setOpen] = useState(true) const filteredPeople = query === '' ? [] : people.filter((person) => { return person.name.toLowerCase().includes(query.toLowerCase()) }) return ( setQuery('')} appear>
(window.location = person.profileUrl)}> {({ activeOption }) => ( <>
{(query === '' || filteredPeople.length > 0) && (
{query === '' && (

Recent searches

)}
{(query === '' ? recent : filteredPeople).map((person) => ( classNames( 'flex cursor-default select-none items-center rounded-md p-2', active && 'bg-gray-100 text-gray-900' ) } > {({ active }) => ( <> {person.name} {active && ( ))}
{activeOption && (

{activeOption.name}

{activeOption.role}

Phone
{activeOption.phone}
URL
{activeOption.url}
Email
{activeOption.email}
)}
)} {query !== '' && filteredPeople.length === 0 && (
)} )}
) }