yew-bootstrap
yew-bootstrap copied to clipboard
Draft: Tooltips / Popper support
Based on #45
This adds support for tooltips with popper-rs
.
Bootstrap tooltips are built with Popper. Both Yew and Popper assume they have complete control of the DOM, so Popper needs some extra wiring to handle the component lifecycle correctly, which popper-rs
provides.
This takes some ideas from react-bootstrap
's Tooltip implementation, but goes for a slightly simpler model, where Tooltips are dropped into a portal directly (like popper-rs
' example), and the Tooltip component is responsible for all the event handling (rather than Overlay
and OverlayTrigger
).
To position the tooltip correctly and mark the target element with accessibility attributes, you need to expose a NodeRef
for each component you want to add a tooltip to. I've exposed NodeRef
s for Button
, FormControl
and Link
.
Unlike regular Bootstrap, this doesn't support tooltips from data
attributes.
I've added examples using all of those controls, and also a direct ref=
attribute on a HTML elements.