summaryrefslogtreecommitdiffstats
path: root/web/src/widget/container.rs
diff options
context:
space:
mode:
Diffstat (limited to 'web/src/widget/container.rs')
-rw-r--r--web/src/widget/container.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/web/src/widget/container.rs b/web/src/widget/container.rs
index 8e4318f9..78be3543 100644
--- a/web/src/widget/container.rs
+++ b/web/src/widget/container.rs
@@ -8,6 +8,7 @@ pub use iced_style::container::{Style, StyleSheet};
/// It is normally used for alignment purposes.
#[allow(missing_debug_implementations)]
pub struct Container<'a, Message> {
+ padding: u16,
width: Length,
height: Length,
max_width: u32,
@@ -29,6 +30,7 @@ impl<'a, Message> Container<'a, Message> {
use std::u32;
Container {
+ padding: 0,
width: Length::Shrink,
height: Length::Shrink,
max_width: u32::MAX,
@@ -40,6 +42,14 @@ impl<'a, Message> Container<'a, Message> {
}
}
+ /// Sets the padding of the [`Container`].
+ ///
+ /// [`Container`]: struct.Column.html
+ pub fn padding(mut self, units: u16) -> Self {
+ self.padding = units;
+ self
+ }
+
/// Sets the width of the [`Container`].
///
/// [`Container`]: struct.Container.html
@@ -113,12 +123,15 @@ where
let column_class = style_sheet.insert(bump, css::Rule::Column);
+ let padding_class =
+ style_sheet.insert(bump, css::Rule::Padding(self.padding));
+
let style = self.style_sheet.style();
let node = div(bump)
.attr(
"class",
- bumpalo::format!(in bump, "{}", column_class).into_bump_str(),
+ bumpalo::format!(in bump, "{} {}", column_class, padding_class).into_bump_str(),
)
.attr(
"style",