### Install cargo-leptos Source: https://github.com/thaw-ui/thaw/blob/main/examples/island/README.md Install the cargo-leptos tool if you don't have it. ```bash cargo install cargo-leptos --locked ``` -------------------------------- ### Using Loading Bar with Provider and Injection Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/loading_bar/docs/mod.md This example demonstrates how to use the Loading Bar component. Wrap your component in LoadingBarProvider and use LoadingBarInjection::expect_context to access the API for starting, finishing, or showing errors. ```rust let loading_bar = LoadingBarInjection::expect_context(); let start = move |_| { loading_bar.start(); }; let finish = move |_| { loading_bar.finish(); }; let error = move |_| { loading_bar.error(); }; view! { } ``` -------------------------------- ### Basic Combobox Usage Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/combobox/docs/mod.md Demonstrates the basic setup of a Combobox with a placeholder and options. One option is disabled. ```rust let selected_options = RwSignal::new(None::); view! { } ``` -------------------------------- ### Inline Drawer Examples Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/drawer/docs/mod.md Illustrates the usage of inline drawers, which are integrated within the layout rather than overlaying it. This example shows left, right, and bottom positioned inline drawers. ```rust let open_left = RwSignal::new(false); let open_right = RwSignal::new(false); let open_buttom = RwSignal::new(false); view! {
"Inline Drawer"

"Drawer content"

"Inline Drawer"

"Drawer content"

"Inline Drawer"

"Drawer content"

``` -------------------------------- ### Install cargo-generate Source: https://github.com/thaw-ui/thaw/blob/main/examples/island/README.md Install the cargo-generate binary, which may be a dependency for project scaffolding. ```bash cargo install cargo-generate ``` -------------------------------- ### Basic OverlayDrawer Example Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/drawer/docs/mod.md Demonstrates how to open and close an OverlayDrawer using a button. The drawer contains a header with a close button and a body with scrollable content. ```rust let open = RwSignal::new(false); view! { "Default Drawer"

r#"This being said, the world is moving in the direction opposite to Clarke's predictions. In 2001: A Space Odyssey, in the year of 2001, which has already passed, human beings have built magnificent cities in space, and established permanent colonies on the moon, and huge nuclear-powered spacecraft have sailed to Saturn. However, today, in 2018, the walk on the moon has become a distant memory.And the farthest reach of our manned space flights is just as long as the two-hour mileage of a high-speed train passing through my city. At the same time, information technology is developing at an unimaginable speed. With the entire world covered by the Internet, people have gradually lost their interest in space, as they find themselves increasingly comfortable in the space created by IT. Instead of an exploration of the real space, which is full of real difficulties, people now just prefer to experience virtual space through VR. Just like someone said, "You promised me an ocean of stars, but you actually gave me Facebook.""#

} ``` -------------------------------- ### Menu Placement Examples Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/menu/docs/mod.md Use the `position` prop to control where the menu appears relative to its trigger. This example showcases all available `MenuPosition` variants. ```rust use leptos_meta::Style; let on_select = move |value: &str| leptos::logging::warn!("{}", value); view! { "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" } ``` -------------------------------- ### Install Rust Nightly Toolchain Source: https://github.com/thaw-ui/thaw/blob/main/examples/island/README.md Ensure you have the Rust nightly toolchain installed, which is often required by Leptos. ```bash rustup toolchain install nightly --allow-downgrade ``` -------------------------------- ### Run Leptos Project in Watch Mode Source: https://github.com/thaw-ui/thaw/blob/main/examples/island/README.md Start the development server with live reloading for Leptos applications. ```bash cargo leptos watch ``` -------------------------------- ### Basic Thaw App Setup with ConfigProvider Source: https://github.com/thaw-ui/thaw/blob/main/demo_markdown/docs/_guide/installation.md A minimal Leptos application demonstrating the required ConfigProvider and a basic Thaw Button component. The ConfigProvider must wrap all Thaw components. ```rust use leptos::prelude::*; use thaw::*; fn main() { mount_to_body(App); } #[component] pub fn App() -> impl IntoView { view! { // The ConfigProvider component is required for Thaw, // please place it at the root of the Thaw component. } } ``` -------------------------------- ### Basic Popover Example Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/popover/docs/mod.md A simple Popover that appears on hover. It can also be configured to trigger on click. ```rust view! { "Content" "Content" } ``` -------------------------------- ### Basic Tag Picker Usage Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/tag_picker/docs/mod.md Demonstrates the fundamental setup of the TagPicker component, including managing selected options and rendering available choices. ```rust let selected_options = RwSignal::new(vec![]); let options = vec!["Cat", "Dog"]; view! { {move || { selected_options.get().into_iter().map(|option| view!{ {option} }).collect_view() }} { move || { selected_options.with(|selected_options| { options.iter().filter_map(|option| { if selected_options.iter().any(|o| o == option) { return None } else { Some(view! { }) } }).collect_view() }) } } ``` -------------------------------- ### Imperative Handle Example Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/button/docs/mod.md Demonstrates how to use the component reference to imperatively control the Button component. ```APIDOC ## Imperative handle ```rust demo let count = RwSignal::new(0); let on_click = move |_| *count.write() += 1; let button_ref = ComponentRef::::new(); let click = move |_| { button_ref.get_untracked().unwrap().click() }; let focus = move |_| { button_ref.get_untracked().unwrap().focus() }; view! { } ``` ``` -------------------------------- ### Tooltip Default Example Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/tooltip/docs/mod.md A standard implementation of the Tooltip component with a Button as its child. ```rust view! { } ``` -------------------------------- ### Dialog Component Usage Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/dialog/docs/mod.md Example of how to use the Dialog component with its various sub-components. ```APIDOC ## Dialog Component ### Description Displays a modal dialog to the user, containing a title, content, and actions. ### Props #### `open` (Model) Controls the open state of the dialog. This is a two-way binding. #### `mask_closeable` (Signal) Default: `true` Determines if the dialog should close when the mask (background overlay) is clicked. #### `close_on_esc` (bool) Default: `true` Determines if the dialog should close when the Escape key is pressed. ### DialogSurface Component ### Description Represents the surface of the dialog, typically containing the body. ### Props No specific props beyond standard component props. ### DialogBody Component ### Description Contains the main content of the dialog, such as title, text, and actions. ### Props No specific props beyond standard component props. ### DialogTitle Component ### Description Displays the title of the dialog. ### Props No specific props beyond standard component props. ### DialogContent Component ### Description Displays the main content area of the dialog. ### Props No specific props beyond standard component props. ### DialogActions Component ### Description Contains action buttons for the dialog, such as confirm or cancel. ### Props No specific props beyond standard component props. ### Example Usage ```rust let open = RwSignal::new(false); view! { "Dialog title" "Dialog body" } ``` ``` -------------------------------- ### Basic TagPicker Usage Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/tag_picker/docs/mod.md Demonstrates the basic setup of the TagPicker component with predefined land and water options. Selected options are displayed as tags, and available options are filtered out. ```rust use leptos::either::Either; let selected_options = RwSignal::new(vec![]); let land = vec!["Cat", "Dog", "Ferret", "Hamster"]; let water = vec!["Fish", "Jellyfish", "Octopus", "Seal"]; view! { {move || { selected_options.get().into_iter().map(|option| view!{ {option} }).collect_view() }} {move || { selected_options.with(|selected_options| { let land_view = land.iter().filter_map(|option| { if selected_options.iter().any(|o| o == option) { return None } else { Some(view! { }) } }).collect_view(); if land_view.is_empty() { Either::Left(()) } else { Either::Right(view! { {land_view} }) } }) }} {move || { selected_options.with(|selected_options| { let water_view = water.iter().filter_map(|option| { if selected_options.iter().any(|o| o == option) { return None } else { Some(view! { }) } }).collect_view(); if water_view.is_empty() { Either::Left(()) } else { Either::Right(view! { {water_view} }) } }) }} } ``` -------------------------------- ### Button with Icon Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/button/docs/mod.md Shows how to add icons to buttons and dynamically change them on click. Includes examples for static icons and clearing icons. ```rust let icon = RwSignal::new(Some(icondata::AiCloseOutlined)); let on_click = move |_| { icon.update(|icon| { *icon = match icon { Some(data) => { if *data == icondata::AiCloseOutlined { icondata::AiCheckOutlined } else { icondata::AiCloseOutlined } } None => icondata::AiCloseOutlined }.into(); }); }; view! { } ``` -------------------------------- ### Basic Accordion Example Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/accordion/docs/mod.md Demonstrates the default behavior of the Accordion component with two items. Each item can be expanded or collapsed independently, but only one can be open at a time. ```rust view! { "Leptos" "Build fast web applications with Rust." "Thaw" "An easy to use leptos component library" } ``` -------------------------------- ### Default MessageBar Example Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/message_bar/docs/mod.md A basic MessageBar with a title, body text, and action buttons. Includes a close button within a MessageBarContainerAction slot. ```rust view! { "Descriptive title" "Message providing information to the user with actionable insights." "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" "Content" } ``` -------------------------------- ### NavDrawer with Categories and Items Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/nav/docs/mod.md Example of using NavDrawer to create a navigation menu with nested categories and items. It demonstrates how to manage the 'multiple' prop for category expansion. ```rust let is_multiple = RwSignal::new(true); let is_multiple_label = Memo::new(move |_| { if is_multiple.get() { "Multiple".to_string() } else { "Single".to_string() } }); view! { "Area Chart" "Target" "Above" "Below" "Pie Chart" "Pie Target" "Pin Above" "Pin Below" "Github" "Chrome"
} ``` -------------------------------- ### Grid Item Offset Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/grid/docs/mod.md Demonstrates how to offset a grid item from the left edge using the 'offset' prop. This example shows an item starting two columns in. ```rust use leptos_meta::Style; view! { "123" "456" } ``` -------------------------------- ### Basic Theme Switching with ConfigProvider Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/config_provider/docs/mod.md Demonstrates how to use ConfigProvider to manage and switch between light and dark themes for child components. Requires `RwSignal` for reactive theme updates. ```rust let theme = RwSignal::new(Theme::light()); view! { } ``` -------------------------------- ### Install Dart Sass Source: https://github.com/thaw-ui/thaw/blob/main/examples/island/README.md Install Dart Sass globally via npm, which is used for CSS preprocessing. ```bash npm install -g sass ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/thaw-ui/thaw/blob/main/examples/ssr_axum/README.md Change the current directory to the newly created Leptos Axum project. ```bash cd ssr_axum ``` -------------------------------- ### Navigate to Project Directory Source: https://github.com/thaw-ui/thaw/blob/main/examples/island/README.md Change the current directory to your newly created Leptos project. ```bash cd island ``` -------------------------------- ### Basic Switch Usage Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/switch/docs/mod.md Demonstrates how to create and render a basic Switch component. Requires `RwSignal` for state management. ```rust let checked = RwSignal::new(false); view! { } ``` -------------------------------- ### Basic Image Usage Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/image/docs/mod.md Demonstrates how to display an image with a specified source and width, and a placeholder image with dimensions. ```rust view! { } ``` -------------------------------- ### Create New Leptos Axum Project Source: https://github.com/thaw-ui/thaw/blob/main/examples/island/README.md Generate a new Leptos project using the Axum starter template from GitHub. ```bash cargo leptos new --git https://github.com/leptos-rs/start-axum-0.7 ``` -------------------------------- ### Basic Textarea Usage Source: https://github.com/thaw-ui/thaw/blob/main/thaw/src/textarea/docs/mod.md Demonstrates the basic usage of the Textarea component with a placeholder. Requires a `RwSignal` for value management. ```rust let value = RwSignal::new(String::from("o")); view! {