-
-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Accept className
as part of FloatProps
#13
Comments
Hi @JesusTheHun Can you please provide minimal examples (using like github repo, codesandbox, stackblitz..., and suggest can use the Vite & React scaffolding: https://vite.new/react) with the ComboBox component? because I don't know your intention 😅. |
Stackblitz : https://stackblitz.com/edit/github-k6mhmk?file=src/components/ExampleComboboxWithAs.tsx Check the <Float className={'w-full'}> ... </Float>
// Instead of
const MyCustomDiv = ({ children }) => <div className={'w-full'}>{children}</div>;
<Float as={MyCustomDiv}> ... </Float> |
I think you're going to make a fullscreen Modal? If that's the case, Headless UI Float is not suitable for such a thing. This package is a wrapper for Floating UI, the purpose is to create floating elements. If you want to create a fullscreen Modal, it is recommended to use the Dialog / Modal component of Headless UI or other Modal packages. |
No I'm not. |
You can use this to set the list to be the width same as the button. First, you have to wrap the import { Fragment } from 'react'
<Listbox>
<div className="relative w-[260px]">
<Float placement="bottom" offset={4} as={Fragment}>
<Listbox.Button className="w-full ...">
...
</Listbox.Button>
<Listbox.Options className="w-full ...">
...
</Listbox.Options>
</Float>
</div>
</Listbox> If you want to set the width as button self width, you can use the <Listbox>
<div className="relative inline-block">
<Float>...</Float>
</div>
</Listbox> Or wrap a flexbox out fo the <div className="flex items-center">
<Listbox>
<div className="relative">
<Float>...</Float>
</div>
</Listbox>
</div> Reference from Headless UI Listbox example: https://headlessui.com/react/listbox |
Your example could work, if we didn't circle back to #16 . Using |
Is your feature request related to a problem? Please describe.
I'm using a combobox that uses all space available.
Right now
Float
renders a blank div by default, meaning that its width will be width of its content. I want the width of theFloat
div to take all the space available.So right now I have to create a dumb component and pass it to
Float
:It feel like unnecessary work and accepting/passing
className
to the div would be more intuitive. Maybe disable (or trigger a warning) that ifas
is provided because the element itself may not acceptclassName
as a prop.The text was updated successfully, but these errors were encountered: