Skip to content
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

Set CSS variable for adaptive width instead of width #114

Closed
vincerubinetti opened this issue May 3, 2024 · 2 comments · Fixed by #117
Closed

Set CSS variable for adaptive width instead of width #114

vincerubinetti opened this issue May 3, 2024 · 2 comments · Fixed by #117
Labels
enhancement New feature or request

Comments

@vincerubinetti
Copy link

For various reasons, I need to have portal on my <Float>, and I want the adaptiveWidth option to set the min-width on the dropdown instead of the width. It'd be cool if the package set a variable like --width, so we could use the trigger width however we want. Or, you could pass width: number as a render/slot prop for the Content component.

@vincerubinetti vincerubinetti added the enhancement New feature or request label May 3, 2024
@vincerubinetti
Copy link
Author

For now, I'm working around this like this:

<ListboxOptions
  class="list"
  @vue:updated="
    ({ el }) => {
      if (el?.tagName !== 'UL') return;
      el.style.minWidth = el.style.width;
      el.style.width = '';
    }
  "
>

This is in Vue. In React I guess you'd attach a ref and set the style on that.

@ycs77
Copy link
Owner

ycs77 commented May 24, 2024

Hi @vincerubinetti, I've added the width attribute option for adaptive-width in new version v0.14.0 to solve this problem, you can pass the attribute option for adaptive-width to change the width attribute name.

Below example change the width attribute to min-width:

Usage (React)

<Float adaptive-width={{ attribute: 'min-width' }}>

Usage (Vue)

<Float :adaptive-width="{ attribute: 'min-width' }">

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants