summaryrefslogtreecommitdiffstats
path: root/widget/src/tooltip.rs
diff options
context:
space:
mode:
Diffstat (limited to 'widget/src/tooltip.rs')
-rw-r--r--widget/src/tooltip.rs46
1 files changed, 45 insertions, 1 deletions
diff --git a/widget/src/tooltip.rs b/widget/src/tooltip.rs
index 39f2e07d..e98f4da7 100644
--- a/widget/src/tooltip.rs
+++ b/widget/src/tooltip.rs
@@ -1,4 +1,26 @@
-//! Display a widget over another.
+//! Tooltips display a hint of information over some element when hovered.
+//!
+//! # Example
+//! ```no_run
+//! # mod iced { pub mod widget { pub use iced_widget::*; } }
+//! # pub type State = ();
+//! # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
+//! use iced::widget::{container, tooltip};
+//!
+//! enum Message {
+//! // ...
+//! }
+//!
+//! fn view(_state: &State) -> Element<'_, Message> {
+//! tooltip(
+//! "Hover me to display the tooltip!",
+//! container("This is the tooltip contents!")
+//! .padding(10)
+//! .style(container::rounded_box),
+//! tooltip::Position::Bottom,
+//! ).into()
+//! }
+//! ```
use crate::container;
use crate::core::event::{self, Event};
use crate::core::layout::{self, Layout};
@@ -13,6 +35,28 @@ use crate::core::{
};
/// An element to display a widget over another.
+///
+/// # Example
+/// ```no_run
+/// # mod iced { pub mod widget { pub use iced_widget::*; } }
+/// # pub type State = ();
+/// # pub type Element<'a, Message> = iced_widget::core::Element<'a, Message, iced_widget::Theme, iced_widget::Renderer>;
+/// use iced::widget::{container, tooltip};
+///
+/// enum Message {
+/// // ...
+/// }
+///
+/// fn view(_state: &State) -> Element<'_, Message> {
+/// tooltip(
+/// "Hover me to display the tooltip!",
+/// container("This is the tooltip contents!")
+/// .padding(10)
+/// .style(container::rounded_box),
+/// tooltip::Position::Bottom,
+/// ).into()
+/// }
+/// ```
#[allow(missing_debug_implementations)]
pub struct Tooltip<
'a,