/* 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 { ExclamationTriangleIcon, FolderIcon, LifebuoyIcon } from '@heroicons/react/24/outline' const projects = [ { id: 1, name: 'Workflow Inc. / Website Redesign', category: 'Projects', url: '#' }, // More projects... ] const users = [ { id: 1, name: 'Leslie Alexander', url: '#', 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 users... ] function classNames(...classes) { return classes.filter(Boolean).join(' ') } export default function Example() { const [open, setOpen] = useState(true) const [rawQuery, setRawQuery] = useState('') const query = rawQuery.toLowerCase().replace(/^[#>]/, '') const filteredProjects = rawQuery === '#' ? projects : query === '' || rawQuery.startsWith('>') ? [] : projects.filter((project) => project.name.toLowerCase().includes(query)) const filteredUsers = rawQuery === '>' ? users : query === '' || rawQuery.startsWith('#') ? [] : users.filter((user) => user.name.toLowerCase().includes(query)) return ( setRawQuery('')} appear>
(window.location = item.url)}>
{(filteredProjects.length > 0 || filteredUsers.length > 0) && ( {filteredProjects.length > 0 && (
  • Projects

      {filteredProjects.map((project) => ( classNames( 'flex cursor-default select-none items-center px-4 py-2', active && 'bg-indigo-600 text-white' ) } > {({ active }) => ( <> ))}
  • )} {filteredUsers.length > 0 && (
  • Users

      {filteredUsers.map((user) => ( classNames( 'flex cursor-default select-none items-center px-4 py-2', active && 'bg-indigo-600 text-white' ) } > {user.name} ))}
  • )}
    )} {rawQuery === '?' && (
    )} {query !== '' && rawQuery !== '?' && filteredProjects.length === 0 && filteredUsers.length === 0 && (
    )}
    Type{' '} # {' '} for projects, to access projects, ') ? 'border-indigo-600 text-indigo-600' : 'border-gray-400 text-gray-900' )} > > {' '} for users, and{' '} ? {' '} for help.
    ) }