Skip to content

Button

An accessible press target that you style and compose with text or other content.

Loading interactive demo…

#Import

Import button from quickgui.

use quickgui::*;

#Usage

button()
    .h(40.0)
    .px(16.0)
    .bg(Color::rgb8(37, 99, 235))
    .text_color(Color::WHITE)
    .rounded(8.0)
    .hover(|style| style.bg(Color::rgb8(59, 130, 246)))
    .on_click(save)
    .child("Save changes")

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

pub fn button() -> Element

Create a semantic, keyboard-focusable button container.

on_clickpub fn on_click<V>(mut self, listener: crate::ClickListener<V>) -> Self—

Attach a listener registered by [`crate::ViewContext::listener`].

pub fn on_click<V>(mut self, listener: crate::ClickListener<V>) -> Self
View source
disabledpub fn disabled(mut self, disabled: bool) -> Self—

Configures disabled for this part.

pub fn disabled(mut self, disabled: bool) -> Self
View source
childpub fn child(mut self, child: impl IntoElement) -> Self—

Configures child for this part.

pub fn child(mut self, child: impl IntoElement) -> Self
View source
hpub fn h(mut self, height: f32) -> Self—

Configures h for this part.

pub fn h(mut self, height: f32) -> Self
View source
pxpub fn px(mut self, value: f32) -> Self—

Configures px for this part.

pub fn px(mut self, value: f32) -> Self
View source
bgpub fn bg(mut self, color: Color) -> Self—

Configures bg for this part.

pub fn bg(mut self, color: Color) -> Self
View source
roundedpub fn rounded(mut self, radius: f32) -> Self—

Configures rounded for this part.

pub fn rounded(mut self, radius: f32) -> Self
View source
hoverpub fn hover(mut self, style: impl FnOnce(ElementStateStyle) -> ElementStateStyle) -> Self—

Configures hover for this part.

pub fn hover(mut self, style: impl FnOnce(ElementStateStyle) -> ElementStateStyle) -> Self
View source