How would you implement a toolbar? #4584
-
I'd like to build something like the Radix toolbar. I was hoping it could be achieved with some combination of |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 14 replies
-
You could use FocusScope + useFocusManager for this: https://react-spectrum.adobe.com/react-aria/FocusScope.html#usefocusmanager-example |
Beta Was this translation helpful? Give feedback.
-
I implemented it recently and the most complicated was the addition of menu but I was able to implement those too with some custom code. Focus Manager was biggest help here. See #4458 for more details |
Beta Was this translation helpful? Give feedback.
-
Thanks for that @ritz078, I haven't yet implemented a menu but it will likely come up. Should be able to use the same roving Here's where I got to: toolbar-navigation.mov |
Beta Was this translation helpful? Give feedback.
-
If I use the component inside the toolbar on mobile, when I press the buttons the virtual keyboard closes. What would be the way to prevent this? From what I see, it seems to me that this behavior is due to usePress(). Should I make a custom button for the toolbar and add all the hooks to it except usePress()? I feel like I'm complicating something that should be simpler. Isn't there some prop or something designed for this use case? |
Beta Was this translation helpful? Give feedback.
You could use FocusScope + useFocusManager for this: https://react-spectrum.adobe.com/react-aria/FocusScope.html#usefocusmanager-example