Menu Component #3718
-
Hi, I am trying to create a Menu with a fixed width but have the text left aligned. Is this possible? The reason is I want to have other components next to the Menu component but it will be distracting if the component positioning changes when the Menu text changes |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Disclaimer: This is a very experimental bot using OpenAI's GPT-4. The answers may not be correct, a human will review the answer and update it if necessary. Sorry, I don't know how to help with that. I did do a search though, and I managed to find these other Discussions that might be similar or related to your question. Give them a read to see if they answer your question. If they do, head back here and update this discussion and mark it as answered, pointing others to the related discussion:
|
Beta Was this translation helpful? Give feedback.
-
🤖 Hello @wlumtwilio! 👋 I'm Dosu, a friendly bot here to lend a hand with bugs, answer your questions, and guide you in becoming a contributor. While we're waiting for a human maintainer to join us, feel free to ask me anything about the Paste repository. I'm here to help! 🤖💡 Yes, it is possible to create a Menu with a fixed width and left-aligned text in the Paste design system. You can achieve this by using the Here is an example of how you can do it: import { Box } from "@twilio-paste/box";
import { Menu, MenuButton, MenuItem, useMenuState } from "@twilio-paste/menu";
const FixedWidthMenu: React.FC<React.PropsWithChildren<unknown>> = () => {
const menu = useMenuState();
const onClick = (): void => {
menu.hide();
};
return (
<Box width="size20">
<MenuButton {...menu} variant="primary">
Preferences
</MenuButton>
<Menu {...menu} aria-label="Preferences">
<MenuItem {...menu} onClick={onClick}>
Settings
</MenuItem>
<MenuItem {...menu} href="http://www.google.com" onClick={onClick}>
Has a link
</MenuItem>
<MenuItem {...menu} variant="destructive" href="http://www.google.com" onClick={onClick}>
Destructive link
</MenuItem>
<MenuItem {...menu} disabled>
Extensions
</MenuItem>
</Menu>
</Box>
);
}; In this example, the As for the available width options that can be set for the I hope this helps! If you have any other questions, feel free to ask. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
@wlumtwilio Thanks for slacking me the Figma file! A few things here:
Make sure you're using Popover or the Non-modal Dialog Primitive for the dropdown part of this element. Menus should't contain form fields inside them. The Figma file you shared also shows a Popover being used.
You're on the right track here with MenuBadge. You'll have to create something custom using Box and Text, but you can use the MenuBadge source code as a starting point. If you do that, you can get pretty close to the original design, just with a slightly different placement of the dropdown.