Skip to main content

ui/traits/
visible_on_hover.rs

1use gpui::{InteractiveElement, SharedString, Styled};
2
3/// A trait for elements that can be made visible on hover by
4/// tracking a specific group.
5pub trait VisibleOnHover {
6    /// Sets the element to only be visible when the specified group is hovered.
7    ///
8    /// Pass `""` as the `group_name` to use the global group.
9    fn visible_on_hover(self, group_name: impl Into<SharedString>) -> Self;
10}
11
12impl<E: InteractiveElement + Styled> VisibleOnHover for E {
13    fn visible_on_hover(self, group_name: impl Into<SharedString>) -> Self {
14        self.invisible()
15            .group_hover(group_name, |style| style.visible())
16    }
17}