title: How would I go about getting a value from a Headless-UI component?
body: <p>I'm using a <a href="https://headlessui.com/react/listbox" rel="nofollow noreferrer">Headless-UI Listbox component.</a></p>
  <p>I put this listbox as it's own React component, and I import that component in a settings form. How would I go about grabbing the value from the component and storing it in the state for the settings form(The listbox component already uses onChange)</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import { Fragment, useState } from 'react'
  import { Listbox, Transition } from '@headlessui/react'
  import { CheckIcon, SelectorIcon } from '@heroicons/react/solid'
  
  const people = [
    { name: 'Wade Cooper' },
    { name: 'Arlene Mccoy' },
    { name: 'Devon Webb' },
    { name: 'Tom Cook' },
    { name: 'Tanya Fox' },
    { name: 'Hellen Schmidt' },
  ]
  
  export default function Example() {
    const [selected, setSelected] = useState(people[0])
  
    return (
      &lt;div className="fixed top-16 w-72"&gt;
        &lt;Listbox value={selected} onChange={setSelected}&gt;
          &lt;div className="relative mt-1"&gt;
            &lt;Listbox.Button className="relative w-full cursor-default rounded-lg bg-white py-2 pl-3 pr-10 text-left shadow-md focus:outline-none focus-visible:border-indigo-500 focus-visible:ring-2 focus-visible:ring-white focus-visible:ring-opacity-75 focus-visible:ring-offset-2 focus-visible:ring-offset-orange-300 sm:text-sm"&gt;
              &lt;span className="block truncate"&gt;{selected.name}&lt;/span&gt;
              &lt;span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2"&gt;
                &lt;SelectorIcon
                  className="h-5 w-5 text-gray-400"
                  aria-hidden="true"
                /&gt;
              &lt;/span&gt;
            &lt;/Listbox.Button&gt;
            &lt;Transition
              as={Fragment}
              leave="transition ease-in duration-100"
              leaveFrom="opacity-100"
              leaveTo="opacity-0"
            &gt;
              &lt;Listbox.Options className="absolute mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm"&gt;
                {people.map((person, personIdx) =&gt; (
                  &lt;Listbox.Option
                    key={personIdx}
                    className={({ active }) =&gt;
                      `relative cursor-default select-none py-2 pl-10 pr-4 ${
                        active ? 'bg-amber-100 text-amber-900' : 'text-gray-900'
                      }`
                    }
                    value={person}
                  &gt;
                    {({ selected }) =&gt; (
                      &lt;&gt;
                        &lt;span
                          className={`block truncate ${
                            selected ? 'font-medium' : 'font-normal'
                          }`}
                        &gt;
                          {person.name}
                        &lt;/span&gt;
                        {selected ? (
                          &lt;span className="absolute inset-y-0 left-0 flex items-center pl-3 text-amber-600"&gt;
                            &lt;CheckIcon className="h-5 w-5" aria-hidden="true" /&gt;
                          &lt;/span&gt;
                        ) : null}
                      &lt;/&gt;
                    )}
                  &lt;/Listbox.Option&gt;
                ))}
              &lt;/Listbox.Options&gt;
            &lt;/Transition&gt;
          &lt;/div&gt;
        &lt;/Listbox&gt;
      &lt;/div&gt;
    )
  }</code></pre>
  </div>
  </div>
  </p>
  <p>Here's an example of what the Listbox component looks like</p>