thaw/demo_markdown/docs/button/mod.md
luoxiaozero 3684f5961b
demo: refactor docs (#67)
* demo: refactor docs

* demo: refactor docs

* demo: refactor guide docs

* chore: workflow add listens to the demo_markdown

* demo: refactor mobile docs
2024-01-03 20:52:56 +08:00

3.9 KiB

Button

view! {
    <Space>
        <Button variant=ButtonVariant::Primary>"Primary"</Button>
        <Button variant=ButtonVariant::Solid>"Solid"</Button>
        <Button variant=ButtonVariant::Text>"Text"</Button>
        <Button variant=ButtonVariant::Link>"Link"</Button>
    </Space>
}

Color

view! {
    <Space>
        <Button color=ButtonColor::Primary>"Primary Color"</Button>
        <Button color=ButtonColor::Success>"Success Color"</Button>
        <Button color=ButtonColor::Warning>"Warning Color"</Button>
        <Button color=ButtonColor::Error>"Error Color"</Button>
    </Space>
}

Icon

view! {
    <Space>
        <Button color=ButtonColor::Error icon=icondata::AiIcon::AiCloseOutlined>
            "Error Color Icon"
        </Button>
        <Button
            color=ButtonColor::Error
            icon=icondata::AiIcon::AiCloseOutlined
            round=true
        />
        <Button
            color=ButtonColor::Error
            icon=icondata::AiIcon::AiCloseOutlined
            circle=true
        />
    </Space>
}

Loading

let loading = create_rw_signal(false);
let on_click = move |_| {
    loading.set(true);
    set_timeout(
        move || {
            loading.set(false);
        },
        std::time::Duration::new(2, 0),
    );
};

view! {
    <Space>
        <Button loading on_click icon=icondata::AiIcon::AiCloseOutlined>
            "Click Me"
        </Button>
        <Button loading on_click>
            "Click Me"
        </Button>
    </Space>
}

Disabled

view! {
    <Space>
        <Button variant=ButtonVariant::Primary disabled=true>
            "Primary"
        </Button>
        <Button variant=ButtonVariant::Solid disabled=true>
            "Solid"
        </Button>
        <Button variant=ButtonVariant::Text disabled=true>
            "Text"
        </Button>
        <Button variant=ButtonVariant::Link disabled=true>
            "Link"
        </Button>
    </Space>
}

Size

view! {
    <Space>
        <Button size=ButtonSize::Tiny>"Primary"</Button>
        <Button size=ButtonSize::Small>"Primary"</Button>
        <Button size=ButtonSize::Medium>"Primary"</Button>
        <Button size=ButtonSize::Large>"Primary"</Button>
    </Space>
}

Group

view! {
    <Space>
        <ButtonGroup>
            <Button variant=ButtonVariant::Solid>"Solid"</Button>
            <Button variant=ButtonVariant::Solid>"Solid"</Button>
            <Button variant=ButtonVariant::Solid>"Solid"</Button>
        </ButtonGroup>
        <ButtonGroup vertical=true>
            <Button variant=ButtonVariant::Solid>"Solid"</Button>
            <Button variant=ButtonVariant::Solid>"Solid"</Button>
            <Button variant=ButtonVariant::Solid>"Solid"</Button>
        </ButtonGroup>
    </Space>
}

Button Props

Name Type Default Description
class MaybeSignal<String> Default::default() Additional classes for the button element.
style MaybeSignal<String> Default::default() Button's style.
variant MaybeSignal<ButtonVariant> ButtonVariant::Primary Button's variant.
color MaybeSignal<ButtonColor> ButtonColor::Primary Button's color.
round MaybeSignal<bool> false Whether the button shows rounded corners.
circle MaybeSignal<bool> false Whether the button is round.
icon Option<Icon> None The icon of the button.
loading MaybeSignal<bool> false Whether the button shows the loading status.
disabled MaybeSignal<bool> false Whether the button is disabled.
size MaybeSignal<ButtonSize> ButtonSize::Medium Button size.
on_click Option<Callback<ev::MouseEvent>> None Listen for button click events.
children Children Button's content.