pub struct Button { /* private fields */ }Expand description
A button, or a link styled as one (href).
let b = Button![variant = Variant::Bordered, color = Color::Danger, size = Size::Sm, "Delete"];
assert!(render_static(b).contains(r#"<button class="nr-btn nr-btn-bordered nr-c-danger nr-btn-sm" type="button">Delete</button>"#));Implementations§
Source§impl Button
impl Button
pub fn new() -> Self
Sourcepub fn class(self, v: impl Into<String>) -> Self
pub fn class(self, v: impl Into<String>) -> Self
Extra classes for the outer element. They win over the defaults.
Sourcepub fn with(self, part: impl Part) -> Self
pub fn with(self, part: impl Part) -> Self
Add an attribute (class(..), id(..), aria(..), …) or a child.
pub fn color(self, v: Color) -> Self
pub fn variant(self, v: Variant) -> Self
pub fn size(self, v: Size) -> Self
pub fn radius(self, v: Radius) -> Self
Sourcepub fn full_width(self, v: bool) -> Self
pub fn full_width(self, v: bool) -> Self
Take the full width of the container.
Sourcepub fn icon_only(self, v: bool) -> Self
pub fn icon_only(self, v: bool) -> Self
A square button holding only an icon (give it an aria("label", ..)).
pub fn disabled(self, v: bool) -> Self
Sourcepub fn submit(self, v: bool) -> Self
pub fn submit(self, v: bool) -> Self
A submit button (type="submit"). Buttons are type="button" otherwise.
Inside a form posting to a server action, it shows a spinner while the form submits.
Sourcepub fn href(self, v: impl Into<String>) -> Self
pub fn href(self, v: impl Into<String>) -> Self
Render a link that looks like a button (client-side navigation).
Sourcepub fn start_content(self, v: impl View) -> Self
pub fn start_content(self, v: impl View) -> Self
Content before the label, typically an icon.
Sourcepub fn end_content(self, v: impl View) -> Self
pub fn end_content(self, v: impl View) -> Self
Content after the label.
Sourcepub fn on_press(self, v: impl Into<Press>) -> Self
pub fn on_press(self, v: impl Into<Press>) -> Self
What pressing the button does: on_press = action!(save), or a Press.
Sourcepub fn on_click(self, v: impl Into<Press>) -> Self
pub fn on_click(self, v: impl Into<Press>) -> Self
Same as Button::on_press.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for Button
impl !Sync for Button
impl !UnwindSafe for Button
impl Forget for Button
impl Freeze for Button
impl Move for Button
impl Send for Button
impl Unpin for Button
impl UnsafeUnpin for Button
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more