Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

Menu item overflows on really long text. #5

Closed
sebastienlabine opened this issue Jul 6, 2021 · 1 comment
Closed

Menu item overflows on really long text. #5

sebastienlabine opened this issue Jul 6, 2021 · 1 comment

Comments

@sebastienlabine
Copy link

When a menu item is really long, the text overflows due to the fact that the height is pre-defined.

h-8 {
  height: 2rem;
}
![image](https://user-images.githubusercontent.com/8888846/124614036-da33cb00-de41-11eb-9805-670192d32862.png)

Suggestion
Change the height to min-height. However this may have effect on other properties.

h-8 {
  min-height: 2rem;
}

image

@pepelele
Copy link
Contributor

pepelele commented Jul 6, 2021

I think it will depend on different cases... In general, there are 2 ways to solve it.

  1. Show all long text.

Add min-w-max class to Menu.Items element.

<Menu.Items
  className={cx(
    "absolute left-0 z-dropdown w-56 min-w-max mt-2 origin-top-left rounded-md shadow-sm outline-none",
    "bg-white border border-gray-200",
    "dark:bg-neutral-800 dark:border-gray-700"
  )}
>

Screen Shot 2021-07-06 at 21 34 40

  1. Truncate the string

add truncate class to span element.

<Icon
  as={ArrowsExpandIcon}
  label="arrows-expand"
  className={cx("w-4 h-4 mr-2", active ? "" : "text-neutral-500")}
/>
<span className="flex-1 mr-2 truncate">Really really long menu text will overflow.</span>
<Kbd>⌘F</Kbd>

Screen Shot 2021-07-06 at 21 36 25

To make sure it works with the default I think I will choose option 1 to show example.

@pepelele pepelele closed this as completed Jul 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants