Struct viewy::components::Button

source ·
pub struct Button {
    pub label: Option<String>,
    pub style: ButtonStyle,
    pub icon: Option<Box<dyn IconPack>>,
    /* private fields */
}
Expand description

A control that performs an action when triggered.

Button::new("Label", ButtonStyle::Filled)
    .action("/") // Here create a link to "/"

Fields§

§label: Option<String>§style: ButtonStyle§icon: Option<Box<dyn IconPack>>

Implementations§

source§

impl Button

source

pub fn new(label: &str, style: ButtonStyle) -> Self

Create new button

source

pub fn icon_only<T>(icon: T, style: ButtonStyle) -> Selfwhere T: 'static + IconPack,

Create new icon only button

source

pub fn destructive(&mut self) -> Self

Change button style to destructive (red)

source

pub fn disabled(&mut self, is_disabled: bool) -> Self

Disable interaction on the button

source

pub fn reversed(&mut self, is_reversed: bool) -> Self

source

pub fn attach_to_form(&mut self, form_name: &str) -> Self

Make the button submit specified form

View::new()
   .append_child({
       Form::new("formName", "/")
   })
   .append_child({
       Button::new("Submit", ButtonStyle::Filled)
           .attach_to_form("formName")
       })
source

pub fn attach_to_file_input(&mut self, input_id: &str) -> Self

source

pub fn close_popup(&mut self) -> Self

source

pub fn action(&mut self, url: &str) -> Self

Set url to navigate to.

source

pub fn icon<T>(&mut self, icon: T) -> Selfwhere T: 'static + IconPack,

Set button’s icon

Trait Implementations§

source§

impl BadgeModifiers for Button

source§

fn badge(&mut self, count: &usize) -> Self

source§

impl Clone for Button

source§

fn clone(&self) -> Button

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Button

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl DefaultModifiers<Button> for Button

source§

fn color(&mut self, color: &str) -> Self

source§

fn opacity(&mut self, opacity: f32) -> Self

source§

fn add_class(&mut self, class_name: &str) -> Self

source§

fn remove_class(&mut self, class_name: &str) -> Self

source§

fn position(&mut self, position: Position) -> Self

source§

fn padding(&mut self, padding: Vec<i32>) -> Self

source§

fn padding_top(&mut self, value: i32) -> Self

source§

fn padding_bottom(&mut self, value: i32) -> Self

source§

fn padding_left(&mut self, value: i32) -> Self

source§

fn padding_right(&mut self, value: i32) -> Self

source§

fn margin(&mut self, margin: Vec<i32>) -> Self

source§

fn margin_top(&mut self, value: i32) -> Self

source§

fn margin_bottom(&mut self, value: i32) -> Self

source§

fn margin_left(&mut self, value: i32) -> Self

source§

fn margin_right(&mut self, value: i32) -> Self

source§

fn width(&mut self, value: &str) -> Self

source§

fn height(&mut self, value: &str) -> Self

source§

fn min_width(&mut self, value: &str) -> Self

source§

fn min_height(&mut self, value: &str) -> Self

source§

fn max_width(&mut self, value: &str) -> Self

source§

fn max_height(&mut self, value: &str) -> Self

source§

fn sticky_to_top(&mut self, top: i32) -> Self

source§

fn sticky_to_bottom(&mut self, bottom: i32) -> Self

source§

fn align_self(&mut self, value: &str) -> Self

source§

fn justify_self(&mut self, value: &str) -> Self

source§

fn background_color(&mut self, color: &str) -> Self

source§

fn display(&mut self, display: &str) -> Self

source§

fn background_image(&mut self, url: &str) -> Self

source§

fn background(&mut self, value: &str) -> Self

source§

fn border(&mut self, value: &str) -> Self

source§

fn border_left(&mut self, value: &str) -> Self

source§

fn border_right(&mut self, value: &str) -> Self

source§

fn border_bottom(&mut self, value: &str) -> Self

source§

fn border_top(&mut self, value: &str) -> Self

source§

fn tag(&mut self, tag_name: &str) -> Self

source§

fn set_attr(&mut self, name: &str, value: &str) -> Self

source§

fn unset_attr(&mut self, name: &str) -> Self

source§

fn grid_area(&mut self, name: &str) -> Self

source§

fn grid_column(&mut self, column: &str) -> Self

source§

fn grid_row(&mut self, row: &str) -> Self

source§

fn flex_grow(&mut self, value: i32) -> Self

source§

fn line_height(&mut self, value: &str) -> Self

source§

fn border_radius(&mut self, value: &str) -> Self

source§

fn text_align(&mut self, value: &str) -> Self

source§

fn overflow(&mut self, overflow: Overflow) -> Self

source§

fn popover(&mut self, popover: Popover) -> Self

source§

fn popup(&mut self, popup: Popup) -> Self

source§

impl Renderable for Button

source§

fn render(&self) -> Node

source§

fn to_html(&self) -> String

Auto Trait Implementations§

§

impl !RefUnwindSafe for Button

§

impl Send for Button

§

impl Sync for Button

§

impl Unpin for Button

§

impl !UnwindSafe for Button

Blanket Implementations§

source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for Swhere T: FloatComponent, Swp: WhitePoint, Dwp: WhitePoint, D: AdaptFrom<S, Swp, Dwp, T>,

source§

fn adapt_into_using<M>(self, method: M) -> Dwhere M: TransformMatrix<Swp, Dwp, T>,

Convert the source color to the destination color using the specified method
source§

fn adapt_into(self) -> D

Convert the source color to the destination color using the bradford method by default
source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

const: unstable · source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> DynClone for Twhere T: Clone,

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

const: unstable · source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> IntoColor<U> for Twhere U: FromColor<T>,

source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
source§

impl<T, U> IntoColorUnclamped<U> for Twhere U: FromColorUnclamped<T>,

source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
const: unstable · source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> TryIntoColor<U> for Twhere U: TryFromColor<T>,

source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V