makara 0.2.6

A Bevy UI simplifier that make it easy to build GUI app with bevy engine.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
# Widgets


**Makara** provides a comprehensive set of built-in widgets for building modern GUI applications. Each widget comes with styling options, event handling capabilities, and built-in class support for rapid development.

## Container Widgets


Container widgets manage layout and can contain child elements.

### Root


The `root_!` widget is the starting point for your UI hierarchy and must be spawned by commands. It supports alignment utility classes.

**Basic Usage:**
```rust
commands.spawn(root_!([
    text_!("Hello World")
]));
```

**With styling and alignment:**
```rust
commands.spawn(
    root_!(
        background_color: Color::srgb(0.1, 0.1, 0.2),
        class: "justify-center align-center p-4";
        [
            column_!([
                text_!("Welcome to Makara!"),
                button_!("Get Started")
            ])
        ]
    )
);
```

**With custom properties:**
```rust
commands.spawn(
    root_!(
        width: percent(100),
        height: percent(100),
        id: "main-container",
        class: "justify-between align-stretch";
        [/* children */]
    )
);
```

### Column


The `column_!` widget arranges children vertically in a flexbox column layout.

**Basic Usage:**
```rust
column_!([
    text_!("Item 1"),
    text_!("Item 2"),
    text_!("Item 3")
])
```

**With alignment and spacing:**
```rust
column_!(
    class: "justify-center align-center p-4 m-2",
    background_color: Color::WHITE;
    [
        text_!("Centered Column", font_size: 24.0),
        button_!("Action Button", class: "is-primary mt-3"),
        text_!("Footer text", class: "mt-2")
    ]
)
```

**With event handling:**
```rust
column_!(
    on: |built: On<WidgetBuilt>| {
        println!("Column widget built!");
    };
    [/* children */]
)
```

### Row


The `row_!` widget arranges children horizontally in a flexbox row layout.

**Basic Usage:**
```rust
row_!([
    text_!("Left"),
    text_!("Center"), 
    text_!("Right")
])
```

**Navigation bar example:**
```rust
row_!(
    class: "justify-between align-center p-3",
    background_color: Color::srgb(0.2, 0.3, 0.8);
    [
        text_!("MyApp", font_size: 20.0, color: Color::WHITE),
        row_!(
            class: "justify-end align-center";
            [
                button_!("Home", class: "mr-2"),
                button_!("About", class: "mr-2"),
                button_!("Contact")
            ]
        )
    ]
)
```

### Scroll


The `scroll_!` widget creates a scrollable container for content that exceeds the container size.

**Basic Usage:**
```rust
scroll_!([
    text_!("Line 1"),
    text_!("Line 2"),
    text_!("Line 3"),
    // ... many more lines
])
```

**Styled scroll container:**
```rust
scroll_!(
    width: px(300),
    height: px(200),
    class: "p-3",
    background_color: Color::srgb(0.95, 0.95, 0.95);
    [
        column_!(
            class: "justify-start align-stretch";
            [
                text_!("Scrollable Content", font_size: 18.0, class: "mb-2"),
                text_!("This is line 1"),
                text_!("This is line 2"),
                // ... more content
            ]
        )
    ]
)
```

**With scroll event handling:**
```rust
scroll_!(
    on: |scrolling: On<Scrolling>| {
        println!("User is scrolling!");
    };
    [/* scrollable content */]
)
```

## Interactive Widgets


### Button


The `button_!` widget provides clickable interactions with built-in hover states.

**Basic Usage:**
```rust
button_!("Click Me")
```

**With styling:**
```rust
button_!("Submit", class: "is-primary p-3 m-2")
```

**With event handling:**
```rust
button_!(
    "Save Data";
    on: |clicked: On<Clicked>| {
        println!("Save button clicked!");
    };
    on: |over: On<MouseOver>| {
        println!("Mouse over save button");
    };
    on: |out: On<MouseOut>| {
        println!("Mouse left save button");  
    }
)
```

**Complete example with styling and events:**
```rust
button_!(
    "Delete Item",
    id: "delete-btn",
    class: "is-danger p-2 m-1";
    on: |clicked: On<Clicked>| {
        // Handle delete action
    };
    on: |built: On<WidgetBuilt>| {
        println!("Delete button ready!");
    }
)
```

### Text Input


The `text_input_!` widget provides text entry with placeholder support and theming.

**Basic Usage:**
```rust
text_input_!("Enter your name...")
```

**With styling and validation:**
```rust
text_input_!(
    "Enter email address...",
    class: "is-primary p-2",
    width: px(300),
    id: "email-input"
)
```

**With change event handling:**
```rust
text_input_!(
    "Search...";
    on: |change: On<Change<String>>| {
        println!("Search text: {}", change.0);
    };
    on: |clicked: On<Clicked>| {
        println!("Input field focused");
    }
)
```

**Form example:**
```rust
column_!(
    class: "justify-start align-stretch p-4";
    [
        text_!("User Registration", font_size: 20.0, class: "mb-3"),
        text_input_!("Full Name...", class: "mb-2", width: px(300)),
        text_input_!("Email Address...", class: "is-info mb-2", width: px(300)),
        text_input_!("Password...", class: "is-warning mb-3", width: px(300)),
        button_!("Register", class: "is-success")
    ]
)
```

### Checkbox


The `checkbox_!` widget provides boolean toggle functionality.

**Basic Usage:**
```rust
checkbox_!("Accept terms and conditions")
```

**With styling:**
```rust
checkbox_!("Enable notifications", class: "is-primary p-2")
```

**With state change handling:**
```rust
checkbox_!(
    "Subscribe to newsletter";
    on: |active: On<Active<String>>| {
        println!("Checkbox activated: {}", active.0);
    };
    on: |inactive: On<Inactive<String>>| {
        println!("Checkbox deactivated: {}", inactive.0);
    }
)
```

**Settings panel example:**
```rust
column_!(
    class: "justify-start align-start p-4";
    [
        text_!("Settings", font_size: 18.0, class: "mb-3"),
        checkbox_!("Dark mode", class: "is-info mb-2"),
        checkbox_!("Auto-save", class: "is-success mb-2"),  
        checkbox_!("Show tooltips", class: "is-primary mb-2"),
        button_!("Apply Settings", class: "is-primary mt-2")
    ]
)
```

### Radio Group & Radio


Radio widgets provide single-selection from multiple options.

**Basic Usage:**
```rust
radio_group_!([
    radio_!("Option A"),
    radio_!("Option B"),
    radio_!("Option C")
])
```

**Payment method selector:**
```rust
radio_group_!(
    class: "p-3";
    on: |change: On<Change<String>>| {
        println!("Selected payment method: {}", change.0);
    };
    [
        radio_!("Credit Card", class: "is-primary mb-2"),
        radio_!("PayPal", class: "is-info mb-2"),
        radio_!("Bank Transfer", class: "is-success mb-2"),
        radio_!("Cash on Delivery", class: "is-warning")
    ]
)
```

**With individual radio event handling:**
```rust
radio_group_!([
    radio_!(
        "Small Size";
        on: |active: On<Active>| {
            println!("Small size selected");
        }
    ),
    radio_!("Medium Size"),
    radio_!("Large Size")
])
```

### Select


The `select_!` widget provides a dropdown selection interface.

**Basic Usage:**
```rust
select_!("Choose country...", choices: &["USA", "Canada", "Mexico"])
```

**With styling and events:**
```rust
select_!(
    "Select payment method...",
    choices: &["Credit Card", "Debit Card", "PayPal"],
    class: "is-primary p-2",
    width: px(250);
    on: |change: On<Change<String>>| {
        println!("Selected: {}", change.0);
    };
    on: |active: On<Active>| {
        println!("Dropdown opened");
    };
    on: |inactive: On<Inactive>| {
        println!("Dropdown closed");
    }
)
```

**Form integration:**
```rust
column_!(
    class: "justify-start align-stretch p-4";
    [
        text_!("Shipping Information"),
        select_!("Country...", choices: &["USA", "Canada", "UK"], class: "mb-2"),
        select_!("State/Province...", choices: &["CA", "NY", "TX"], class: "mb-2"),
        button_!("Continue", class: "is-success")
    ]
)
```

### Dropdown


The `dropdown_!` widget creates a button that shows/hides child content.

**Basic Usage:**
```rust
dropdown_!(
    "Menu";
    [
        button_!("Profile"),
        button_!("Settings"),
        button_!("Logout")
    ]
)
```

**Navigation dropdown:**
```rust
dropdown_!(
    "Products",
    class: "is-primary";
    on: |clicked: On<Clicked>| {
        println!("Products dropdown toggled");
    };
    [
        button_!("Laptops", class: "mb-1"),
        button_!("Phones", class: "mb-1"),
        button_!("Tablets", class: "mb-1"),
        button_!("Accessories")
    ]
)
```

### Slider


The `slider_!` widget provides numeric input via draggable control.

**Basic Usage:**
```rust
slider_!(min: 0.0, max: 100.0)
```

**Volume control example:**
```rust
column_!(
    class: "justify-start align-center p-4";
    [
        text_!("Volume Control", class: "mb-2"),
        slider_!(
            min: 0.0, 
            max: 100.0,
            class: "is-primary p-2";
            on: |change: On<Change<f32>>| {
                println!("Volume: {:.1}%", change.0);
            }
        )
    ]
)
```

**Settings panel with multiple sliders:**
```rust
column_!(
    class: "justify-start align-stretch p-4";
    [
        text_!("Audio Settings", font_size: 18.0, class: "mb-3"),
        
        column_!(class: "mb-2"; [
            text_!("Master Volume"),
            slider_!(min: 0.0, max: 100.0, class: "is-primary")
        ]),
        
        column_!(class: "mb-2"; [
            text_!("Music Volume"),
            slider_!(min: 0.0, max: 100.0, class: "is-info")
        ]),
        
        column_!(class: "mb-2"; [
            text_!("Effects Volume"), 
            slider_!(min: 0.0, max: 100.0, class: "is-success")
        ])
    ]
)
```

## Display Widgets


### Text


The `text_!` widget displays styled text content.

**Basic Usage:**
```rust
text_!("Hello World")
```

**With styling:**
```rust
text_!("Welcome!", font_size: 24.0, color: Color::srgb(0.2, 0.6, 0.8))
```

**With classes:**
```rust
text_!("Error message", class: "is-danger", font_size: 16.0)
```

**Typography example:**
```rust
column_!(
    class: "justify-start align-start p-4";
    [
        text_!("Main Heading", font_size: 32.0, class: "mb-3"),
        text_!("Subheading", font_size: 20.0, class: "is-info mb-2"),
        text_!("Regular paragraph text with some content.", font_size: 14.0, class: "mb-2"),
        text_!("Small caption text", font_size: 12.0, class: "is-secondary")
    ]
)
```

### Image


The `image_!` widget displays images from file paths or URLs.

**Basic Usage:**
```rust
image_!("assets/logo.png")
```

**With sizing:**
```rust
image_!(
    "assets/hero-banner.jpg",
    width: px(400),
    height: px(200)
)
```

**With events:**
```rust
image_!(
    "assets/profile.png";
    on: |clicked: On<Clicked>| {
        println!("Profile image clicked");
    };
    on: |over: On<MouseOver>| {
        println!("Hovering over image");
    }
)
```

**Image gallery example:**
```rust
row_!(
    class: "justify-around align-center p-4";
    [
        image_!("assets/thumb1.jpg", width: px(150), height: px(150)),
        image_!("assets/thumb2.jpg", width: px(150), height: px(150)),
        image_!("assets/thumb3.jpg", width: px(150), height: px(150))
    ]
)
```

### Link


The `link_!` widget creates clickable links that open in the browser.

**Basic Usage:**
```rust
link_!("https://rust-lang.org/")
```

**With custom text:**
```rust
link_!("Visit Rust Website", url: "https://rust-lang.org/")
```

**With styling and events:**
```rust
link_!(
    "Documentation", 
    url: "https://docs.rs/makara",
    class: "is-primary";
    on: |clicked: On<Clicked>| {
        println!("Documentation link clicked");
    }
)
```

**Footer links example:**
```rust
row_!(
    class: "justify-center align-center p-3";
    [
        link_!("Privacy Policy", url: "https://example.com/privacy", class: "mr-4"),
        link_!("Terms of Service", url: "https://example.com/terms", class: "mr-4"),
        link_!("Contact Us", url: "https://example.com/contact")
    ]
)
```

## Progress & Loading Widgets


### Progress Bar


The `progress_bar_!` widget shows linear progress indication.

**Basic Usage:**
```rust
progress_bar_!()
```

**With styling:**
```rust
progress_bar_!(
    class: "is-primary p-2",
    width: px(300)
)
```

**With progress tracking:**
```rust
progress_bar_!(
    class: "is-success";
    on: |change: On<Change<f32>>| {
        println!("Progress: {:.1}%", change.0 * 100.0);
    }
)
```

**Loading interface example:**
```rust
column_!(
    class: "justify-center align-center p-4";
    [
        text_!("Loading...", class: "mb-2"),
        progress_bar_!(class: "is-info", width: px(250)),
        text_!("Please wait while we process your request", 
               font_size: 12.0, class: "mt-2")
    ]
)
```

### Circular


The `circular_!` widget shows circular/spinner progress indication.

**Basic Usage:**
```rust
circular_!()
```

**With styling:**
```rust
circular_!(
    class: "is-primary p-3",
    width: px(50),
    height: px(50)
)
```

**Loading spinner example:**
```rust
column_!(
    class: "justify-center align-center p-4";
    [
        circular_!(class: "is-info mb-3"),
        text_!("Processing...", class: "is-info")
    ]
)
```

## Modal


The `modal_!` widget creates overlay dialogs and is independent of the root widget hierarchy.

**Basic Usage:**
```rust
commands.spawn(
    modal_!([
        column_!([
            text_!("Are you sure?"),
            button_!("Confirm")
        ])
    ])
);
```

**Confirmation dialog:**
```rust
modal_!(
    on: |active: On<Active>| {
        println!("Modal opened");
    };
    on: |inactive: On<Inactive>| {
        println!("Modal closed"); 
    };
    [
        column_!(
            class: "justify-center align-center p-4",
            background_color: Color::WHITE,
            width: px(300),
            height: px(200);
            [
                text_!("Delete Confirmation", font_size: 18.0, class: "mb-3"),
                text_!("Are you sure you want to delete this item?", class: "mb-4"),
                row_!(
                    class: "justify-center align-center";
                    [
                        button_!("Cancel", class: "is-secondary mr-2"),
                        button_!("Delete", class: "is-danger")
                    ]
                )
            ]
        )
    ]
)
```

**Settings modal:**
```rust
modal_!([
    column_!(
        class: "justify-start align-stretch p-4",
        background_color: Color::WHITE,
        width: px(400),
        height: px(500);
        [
            text_!("Settings", font_size: 24.0, class: "mb-4"),
            
            checkbox_!("Enable notifications", class: "mb-2"),
            checkbox_!("Auto-save documents", class: "mb-2"),
            
            text_!("Theme", class: "mb-1"),
            select_!("Choose theme...", choices: &["Light", "Dark", "Auto"], class: "mb-4"),
            
            row_!(
                class: "justify-end align-center";
                [
                    button_!("Cancel", class: "mr-2"),
                    button_!("Save", class: "is-primary")
                ]
            )
        ]
    )
])
```

## Built-in Classes


All widgets support built-in utility classes:

### Color Classes

- `is-primary`, `is-primary-dark`
- `is-link`, `is-link-dark`  
- `is-info`, `is-info-dark`
- `is-success`, `is-success-dark`
- `is-warning`, `is-warning-dark`
- `is-danger`, `is-danger-dark`

### Spacing Classes (Container widgets only)

- Margin: `m-0` to `m-6`, `mt-2`, `mr-3`, `mb-1`, `ml-4`, `mx-2`, `my-3`
- Padding: `p-0` to `p-6`, `pt-2`, `pr-3`, `pb-1`, `pl-4`, `px-2`, `py-3`

### Alignment Classes (Container widgets only)

- Justify: `justify-start`, `justify-center`, `justify-end`, `justify-between`, `justify-around`, `justify-evenly`
- Align: `align-start`, `align-center`, `align-end`, `align-stretch`, `align-baseline`

## Complete Example


Here's a complete application example using multiple widgets:

```rust
use makara::prelude::*;
use bevy::prelude::*;

fn setup(mut commands: Commands) {
    commands.spawn(
        root_!(
            class: "justify-center align-center p-4",
            background_color: Color::srgb(0.9, 0.9, 0.9);
            [
                column_!(
                    class: "justify-start align-stretch p-4",
                    background_color: Color::WHITE,
                    width: px(500);
                    [
                        // Header
                        text_!("User Profile", font_size: 24.0, class: "mb-4"),
                        
                        // Profile image
                        row_!(
                            class: "justify-center align-center mb-4";
                            [
                                image_!("assets/avatar.png", width: px(100), height: px(100))
                            ]
                        ),
                        
                        // Form fields
                        text_input_!("Full Name...", class: "mb-2"),
                        text_input_!("Email...", class: "is-info mb-2"),
                        
                        // Preferences
                        text_!("Preferences", font_size: 16.0, class: "mb-2"),
                        checkbox_!("Email notifications", class: "mb-1"),
                        checkbox_!("Dark mode", class: "mb-3"),
                        
                        // Theme selection
                        select_!("Theme...", choices: &["Light", "Dark", "Auto"], class: "mb-4"),
                        
                        // Actions
                        row_!(
                            class: "justify-end align-center";
                            [
                                button_!("Cancel", class: "mr-2"),
                                button_!("Save Profile", class: "is-primary")
                            ]
                        )
                    ]
                )
            ]
        )
    );
}
```

For detailed API documentation, visit the [Rust docs](https://docs.rs/makara/latest/makara/).