Skip to main content

input_row

Function input_row 

Source
pub fn input_row(
    label_text: impl Into<String>,
    label_width: Option<i64>,
    component: impl Builder,
    spacing: Option<i64>,
) -> Stack
Expand description

Helper to create a horizontal row with a label and another component

Examples found in repository?
examples/simple_plugin.rs (lines 142-149)
129fn build_control_panel() -> PluginValue {
130    Panel::new()
131        .padding(16)
132        .border(2)
133        .border_color("theme.primary")
134        .child(
135            "form",
136            Stack::vertical()
137                .spacing(12)
138                .child("title", Label::new("Device Control Panel").size("lg"))
139                // Using the helper function for input rows
140                .child(
141                    "name_row",
142                    containers::input_row(
143                        "Device Name",
144                        Some(120),
145                        Input::new()
146                            .placeholder("Enter device name")
147                            .on_change("on_name_change"),
148                        Some(8),
149                    ),
150                )
151                .child(
152                    "id_row",
153                    containers::input_row(
154                        "Device ID",
155                        Some(120),
156                        Input::new()
157                            .placeholder("Auto-generated")
158                            .disabled(true)
159                            .bind_value("device.id"),
160                        Some(8),
161                    ),
162                )
163                // Action buttons
164                .child(
165                    "actions",
166                    Stack::horizontal()
167                        .spacing(8)
168                        .justify("end")
169                        .child(
170                            "save_btn",
171                            Button::new("Save")
172                                .variant("primary")
173                                .on_click("save_settings"),
174                        )
175                        .child(
176                            "reset_btn",
177                            Button::new("Reset")
178                                .variant("secondary")
179                                .on_click("reset_settings"),
180                        )
181                        .child(
182                            "delete_btn",
183                            Button::new("Delete")
184                                .variant("danger")
185                                .on_click("delete_device"),
186                        ),
187                ),
188        )
189        .build()
190}