Skip to main content

repose_material/material3/
defaults.rs

1use repose_core::*;
2
3/// Default values for surface component.
4pub struct SurfaceDefaults;
5
6impl SurfaceDefaults {
7    pub fn color() -> Color {
8        theme().surface
9    }
10    pub fn content_color() -> Color {
11        theme().on_surface
12    }
13    pub const SHAPE_RADIUS: f32 = 0.0;
14    pub const TONAL_ELEVATION: f32 = 0.0;
15    pub const SHADOW_ELEVATION: f32 = 0.0;
16}
17
18/// Default values for toggle button components.
19pub struct ToggleButtonDefaults;
20
21impl ToggleButtonDefaults {
22    pub const HEIGHT: f32 = 40.0;
23    pub const HORIZONTAL_PADDING: f32 = 24.0;
24    pub const SHAPE_RADIUS: f32 = 20.0;
25    pub fn content_color() -> Color {
26        theme().on_surface_variant
27    }
28    pub fn checked_container_color() -> Color {
29        theme().primary
30    }
31    pub fn checked_content_color() -> Color {
32        theme().on_primary
33    }
34    pub fn tonal_content_color() -> Color {
35        theme().on_surface_variant
36    }
37    pub fn tonal_checked_container_color() -> Color {
38        theme().secondary_container
39    }
40    pub fn tonal_checked_content_color() -> Color {
41        theme().on_secondary_container
42    }
43    pub fn outlined_content_color() -> Color {
44        theme().on_surface_variant
45    }
46    pub fn outlined_border_color() -> Color {
47        theme().outline
48    }
49    pub fn outlined_checked_container_color() -> Color {
50        theme().secondary_container
51    }
52    pub fn outlined_checked_content_color() -> Color {
53        theme().on_secondary_container
54    }
55    pub fn elevated_content_color() -> Color {
56        theme().primary
57    }
58    pub fn elevated_checked_container_color() -> Color {
59        theme().surface_container_low
60    }
61    pub fn elevated_checked_content_color() -> Color {
62        theme().primary
63    }
64    pub fn state_colors_default() -> StateColors {
65        let th = theme();
66        StateColors {
67            default: Color::TRANSPARENT,
68            hovered: th.on_surface.with_alpha_f32(0.08),
69            pressed: th.on_surface.with_alpha_f32(0.12),
70            disabled: th.on_surface.with_alpha_f32(0.12),
71        }
72    }
73    pub fn state_elevation_default() -> StateElevation {
74        StateElevation {
75            default: 0.0,
76            hovered: 1.0,
77            pressed: 0.0,
78            disabled: 0.0,
79        }
80    }
81    pub fn elevated_state_elevation() -> StateElevation {
82        let th = theme();
83        StateElevation {
84            default: th.elevation.level1,
85            hovered: th.elevation.level2,
86            pressed: th.elevation.level1,
87            disabled: 0.0,
88        }
89    }
90}
91
92/// Default values for progress indicator components.
93pub struct ProgressIndicatorDefaults;
94
95impl ProgressIndicatorDefaults {
96    pub fn linear_color() -> Color {
97        theme().primary
98    }
99    pub fn linear_track_color() -> Color {
100        theme().secondary_container
101    }
102    pub const LINEAR_INDICATOR_HEIGHT: f32 = 4.0;
103    pub const LINEAR_INDICATOR_GAP_SIZE: f32 = 4.0;
104    pub const LINEAR_TRACK_STOP_SIZE: f32 = 4.0;
105
106    pub fn circular_color() -> Color {
107        theme().primary
108    }
109    pub fn circular_track_color() -> Color {
110        theme().secondary_container
111    }
112    pub const CIRCULAR_INDICATOR_SIZE: f32 = 40.0;
113    pub const CIRCULAR_STROKE_WIDTH: f32 = 4.0;
114
115    /// M3 `ActiveHandleLeadingSpace` / `ActiveHandleTrailingSpace`
116    pub const SLIDER_THUMB_TRACK_GAP: f32 = 6.0;
117}
118
119/// Default values for button components.
120pub struct ButtonDefaults;
121
122impl ButtonDefaults {
123    pub fn content_color() -> Color {
124        theme().on_primary
125    }
126    pub fn container_color() -> Color {
127        theme().primary
128    }
129    pub fn tonal_container_color() -> Color {
130        theme().secondary_container
131    }
132    pub fn tonal_content_color() -> Color {
133        theme().on_secondary_container
134    }
135    pub fn elevated_container_color() -> Color {
136        theme().surface_container_low
137    }
138    pub fn elevated_content_color() -> Color {
139        theme().primary
140    }
141    pub fn outlined_content_color() -> Color {
142        theme().on_surface_variant
143    }
144    pub fn outlined_border_color() -> Color {
145        theme().outline_variant
146    }
147    pub fn text_content_color() -> Color {
148        theme().primary
149    }
150    pub const HEIGHT: f32 = 40.0;
151    pub const HORIZONTAL_PADDING: f32 = 24.0;
152    pub const TEXT_HORIZONTAL_PADDING: f32 = 12.0;
153    pub const SHAPE_RADIUS: f32 = 20.0;
154    pub fn state_colors_default() -> StateColors {
155        let th = theme();
156        StateColors {
157            default: Color::TRANSPARENT,
158            hovered: th.on_surface.with_alpha_f32(0.08),
159            pressed: th.on_surface.with_alpha_f32(0.12),
160            disabled: th.on_surface.with_alpha_f32(0.12),
161        }
162    }
163    pub fn state_elevation_default() -> StateElevation {
164        StateElevation {
165            default: 0.0,
166            hovered: 1.0,
167            pressed: 0.0,
168            disabled: 0.0,
169        }
170    }
171    pub fn elevated_state_elevation() -> StateElevation {
172        let th = theme();
173        StateElevation {
174            default: th.elevation.level1,
175            hovered: th.elevation.level2,
176            pressed: th.elevation.level1,
177            disabled: 0.0,
178        }
179    }
180}
181
182/// Default values for snackbar components.
183pub struct SnackbarDefaults;
184
185impl SnackbarDefaults {
186    pub const MIN_HEIGHT: f32 = 48.0;
187    pub const MIN_WIDTH: f32 = 280.0;
188    pub const MAX_WIDTH: f32 = 600.0;
189    pub const SHAPE_RADIUS: f32 = 4.0;
190    pub fn container_color() -> Color {
191        theme().inverse_surface
192    }
193    pub fn content_color() -> Color {
194        theme().inverse_on_surface
195    }
196    pub fn action_color() -> Color {
197        theme().inverse_primary
198    }
199    pub fn dismiss_action_content_color() -> Color {
200        theme().inverse_on_surface
201    }
202}
203
204/// Default values for card components.
205pub struct CardDefaults;
206
207impl CardDefaults {
208    pub fn filled_container_color() -> Color {
209        theme().surface_container_highest
210    }
211    pub fn elevated_container_color() -> Color {
212        theme().surface_container_low
213    }
214    pub fn outlined_container_color() -> Color {
215        theme().surface
216    }
217    pub fn outlined_border_color() -> Color {
218        theme().outline_variant
219    }
220    pub fn filled_content_color() -> Color {
221        theme().on_surface
222    }
223    pub fn elevated_content_color() -> Color {
224        theme().on_surface
225    }
226    pub fn outlined_content_color() -> Color {
227        theme().on_surface
228    }
229    pub fn disabled_container_color() -> Color {
230        theme().on_surface.with_alpha_f32(0.04)
231    }
232    pub fn disabled_content_color() -> Color {
233        theme().on_surface.with_alpha_f32(0.38)
234    }
235    pub const SHAPE_RADIUS: f32 = 12.0;
236    pub const ELEVATION: f32 = 0.0;
237}
238
239/// Default values for dialog components.
240pub struct DialogDefaults;
241
242impl DialogDefaults {
243    pub fn container_color() -> Color {
244        theme().surface_container_high
245    }
246    pub const SHAPE_RADIUS: f32 = 28.0;
247    pub const MIN_WIDTH: f32 = 280.0;
248    pub const MAX_WIDTH: f32 = 560.0;
249    pub const HORIZONTAL_PADDING: f32 = 24.0;
250}
251
252/// Default values for icon button components.
253pub struct IconButtonDefaults;
254
255impl IconButtonDefaults {
256    pub const CONTAINER_SIZE: f32 = 48.0;
257    pub const FILLED_CONTAINER_SIZE: f32 = 40.0;
258    pub fn content_color() -> Color {
259        theme().on_surface_variant
260    }
261    pub fn disabled_content_color() -> Color {
262        theme().on_surface.with_alpha_f32(0.38)
263    }
264    pub fn filled_content_color() -> Color {
265        theme().on_primary
266    }
267    pub fn filled_container_color() -> Color {
268        theme().primary
269    }
270    pub fn filled_tonal_content_color() -> Color {
271        theme().on_secondary_container
272    }
273    pub fn filled_tonal_container_color() -> Color {
274        theme().secondary_container
275    }
276    pub fn state_colors_default() -> StateColors {
277        let th = theme();
278        StateColors {
279            default: Color::TRANSPARENT,
280            hovered: th.on_surface.with_alpha_f32(0.08),
281            pressed: th.on_surface.with_alpha_f32(0.12),
282            disabled: Color::TRANSPARENT,
283        }
284    }
285}
286
287/// Default values for checkbox.
288pub struct CheckboxDefaults;
289
290impl CheckboxDefaults {
291    pub const TOUCH_TARGET_SIZE: f32 = 40.0;
292    pub const BOX_SIZE: f32 = 18.0;
293    pub const STROKE_WIDTH: f32 = 2.0;
294    pub const CORNER_RADIUS: f32 = 2.0;
295    pub const CHECK_ICON_SIZE: f32 = 14.0;
296    pub fn checked_color() -> Color {
297        theme().primary
298    }
299    pub fn unchecked_color() -> Color {
300        theme().on_surface_variant
301    }
302    pub fn checkmark_color() -> Color {
303        theme().on_primary
304    }
305    pub fn disabled_checked_box_color() -> Color {
306        theme().on_surface.with_alpha_f32(0.38)
307    }
308    pub fn disabled_checkmark_color() -> Color {
309        theme().surface
310    }
311    pub fn disabled_unchecked_border_color() -> Color {
312        theme().on_surface.with_alpha_f32(0.38)
313    }
314    pub fn state_colors_default() -> StateColors {
315        let th = theme();
316        StateColors {
317            default: Color::TRANSPARENT,
318            hovered: th.on_surface.with_alpha_f32(0.08),
319            pressed: th.on_surface.with_alpha_f32(0.12),
320            disabled: Color::TRANSPARENT,
321        }
322    }
323}
324
325/// Default values for radio button.
326pub struct RadioButtonDefaults;
327
328impl RadioButtonDefaults {
329    pub const TOUCH_TARGET_SIZE: f32 = 40.0;
330    pub const OUTER_RADIUS: f32 = 10.0;
331    pub const DOT_RADIUS: f32 = 5.0;
332    pub const STROKE_WIDTH: f32 = 2.0;
333    pub fn selected_color() -> Color {
334        theme().primary
335    }
336    pub fn unselected_color() -> Color {
337        theme().on_surface_variant
338    }
339    pub fn disabled_selected_color() -> Color {
340        theme().on_surface.with_alpha_f32(0.38)
341    }
342    pub fn disabled_unselected_color() -> Color {
343        theme().on_surface.with_alpha_f32(0.38)
344    }
345    pub fn state_colors_default() -> StateColors {
346        let th = theme();
347        StateColors {
348            default: Color::TRANSPARENT,
349            hovered: th.on_surface.with_alpha_f32(0.08),
350            pressed: th.on_surface.with_alpha_f32(0.12),
351            disabled: Color::TRANSPARENT,
352        }
353    }
354}
355
356/// Default values for switch.
357pub struct SwitchDefaults;
358
359impl SwitchDefaults {
360    pub const TRACK_WIDTH: f32 = 52.0;
361    pub const TRACK_HEIGHT: f32 = 32.0;
362    pub const THUMB_CHECKED_SIZE: f32 = 24.0;
363    pub const THUMB_UNCHECKED_SIZE: f32 = 16.0;
364    pub fn checked_track_color() -> Color {
365        theme().primary
366    }
367    pub fn unchecked_track_color() -> Color {
368        theme().surface_container_highest
369    }
370    pub fn checked_thumb_color() -> Color {
371        theme().on_primary
372    }
373    pub fn unchecked_thumb_color() -> Color {
374        theme().outline
375    }
376    pub fn checked_icon_color() -> Color {
377        theme().on_primary
378    }
379    pub fn unchecked_icon_color() -> Color {
380        theme().outline
381    }
382    pub fn unchecked_border_color() -> Color {
383        theme().outline
384    }
385    pub fn disabled_checked_thumb_color() -> Color {
386        theme().surface
387    }
388    pub fn disabled_checked_track_color() -> Color {
389        theme().on_surface.with_alpha_f32(0.12)
390    }
391    pub fn disabled_checked_icon_color() -> Color {
392        theme().on_surface.with_alpha_f32(0.38)
393    }
394    pub fn disabled_unchecked_thumb_color() -> Color {
395        theme().on_surface.with_alpha_f32(0.38)
396    }
397    pub fn disabled_unchecked_track_color() -> Color {
398        theme().surface_container_highest.with_alpha_f32(0.12)
399    }
400    pub fn disabled_unchecked_border_color() -> Color {
401        theme().on_surface.with_alpha_f32(0.12)
402    }
403    pub fn disabled_unchecked_icon_color() -> Color {
404        theme().surface_container_highest.with_alpha_f32(0.38)
405    }
406    pub fn state_colors_default() -> StateColors {
407        let th = theme();
408        StateColors {
409            default: Color::TRANSPARENT,
410            hovered: th.on_surface.with_alpha_f32(0.08),
411            pressed: th.on_surface.with_alpha_f32(0.12),
412            disabled: Color::TRANSPARENT,
413        }
414    }
415}
416
417/// Default values for slider.
418pub struct SliderDefaults;
419
420impl SliderDefaults {
421    pub const TRACK_HEIGHT: f32 = 4.0;
422    pub const THUMB_SIZE: f32 = 20.0;
423    pub fn active_track_color() -> Color {
424        theme().primary
425    }
426    pub fn inactive_track_color() -> Color {
427        theme().secondary_container
428    }
429    pub fn thumb_color() -> Color {
430        theme().primary
431    }
432    pub fn active_tick_color() -> Color {
433        theme().secondary_container
434    }
435    pub fn inactive_tick_color() -> Color {
436        theme().primary
437    }
438    pub fn disabled_thumb_color() -> Color {
439        theme().on_surface.with_alpha_f32(0.38)
440    }
441    pub fn disabled_active_track_color() -> Color {
442        theme().on_surface.with_alpha_f32(0.38)
443    }
444    pub fn disabled_inactive_track_color() -> Color {
445        theme().on_surface.with_alpha_f32(0.12)
446    }
447    pub fn disabled_active_tick_color() -> Color {
448        theme().on_surface.with_alpha_f32(0.12)
449    }
450    pub fn disabled_inactive_tick_color() -> Color {
451        theme().on_surface.with_alpha_f32(0.38)
452    }
453    pub fn state_colors_default() -> StateColors {
454        let th = theme();
455        StateColors {
456            default: Color::TRANSPARENT,
457            hovered: th.on_surface.with_alpha_f32(0.08),
458            pressed: th.on_surface.with_alpha_f32(0.12),
459            disabled: Color::TRANSPARENT,
460        }
461    }
462}
463
464/// Default values for divider.
465pub struct DividerDefaults;
466
467impl DividerDefaults {
468    pub const THICKNESS: f32 = 1.0;
469    pub fn color() -> Color {
470        theme().outline_variant
471    }
472}
473
474/// Default values for badge.
475pub struct BadgeDefaults;
476
477impl BadgeDefaults {
478    pub const DOT_SIZE: f32 = 6.0;
479    pub const LABEL_MIN_WIDTH: f32 = 16.0;
480    pub const LABEL_HEIGHT: f32 = 16.0;
481    pub const DOT_OFFSET_X: f32 = 6.0;
482    pub const DOT_OFFSET_Y: f32 = 6.0;
483    pub const CONTENT_OFFSET_X: f32 = 12.0;
484    pub const CONTENT_OFFSET_Y: f32 = 14.0;
485    pub fn container_color() -> Color {
486        theme().error
487    }
488    pub fn content_color() -> Color {
489        theme().on_error
490    }
491}
492
493/// Default values for list item.
494pub struct ListItemDefaults;
495
496impl ListItemDefaults {
497    pub const ONE_LINE_HEIGHT: f32 = 56.0;
498    pub const TWO_LINE_HEIGHT: f32 = 72.0;
499    pub const THREE_LINE_HEIGHT: f32 = 88.0;
500    pub const HORIZONTAL_PADDING: f32 = 16.0;
501    pub const TRAILING_PADDING: f32 = 24.0;
502    pub fn headline_color() -> Color {
503        theme().on_surface
504    }
505    pub fn supporting_color() -> Color {
506        theme().on_surface_variant
507    }
508    pub fn overline_color() -> Color {
509        theme().on_surface_variant
510    }
511    pub fn leading_icon_color() -> Color {
512        theme().on_surface_variant
513    }
514    pub fn trailing_icon_color() -> Color {
515        theme().on_surface_variant
516    }
517    // disabled
518    pub fn disabled_container_color() -> Color {
519        theme().on_surface.with_alpha_f32(0.04)
520    }
521    pub fn disabled_headline_color() -> Color {
522        theme().on_surface.with_alpha_f32(0.38)
523    }
524    pub fn disabled_supporting_color() -> Color {
525        theme().on_surface.with_alpha_f32(0.38)
526    }
527    pub fn disabled_overline_color() -> Color {
528        theme().on_surface.with_alpha_f32(0.38)
529    }
530    pub fn disabled_leading_icon_color() -> Color {
531        theme().on_surface.with_alpha_f32(0.38)
532    }
533    pub fn disabled_trailing_icon_color() -> Color {
534        theme().on_surface.with_alpha_f32(0.38)
535    }
536    // selected
537    pub fn selected_container_color() -> Color {
538        theme().surface_container_high
539    }
540    pub fn selected_headline_color() -> Color {
541        theme().on_surface
542    }
543    pub fn selected_supporting_color() -> Color {
544        theme().on_surface_variant
545    }
546    pub fn selected_overline_color() -> Color {
547        theme().on_surface_variant
548    }
549    pub fn selected_leading_icon_color() -> Color {
550        theme().on_surface_variant
551    }
552    pub fn selected_trailing_icon_color() -> Color {
553        theme().on_surface_variant
554    }
555    // dragged
556    pub fn dragged_container_color() -> Color {
557        theme().surface_container_high
558    }
559    pub fn dragged_headline_color() -> Color {
560        theme().on_surface
561    }
562    pub fn dragged_supporting_color() -> Color {
563        theme().on_surface_variant
564    }
565    pub fn dragged_overline_color() -> Color {
566        theme().on_surface_variant
567    }
568    pub fn dragged_leading_icon_color() -> Color {
569        theme().on_surface_variant
570    }
571    pub fn dragged_trailing_icon_color() -> Color {
572        theme().on_surface_variant
573    }
574}
575
576/// Default values for top app bar.
577pub struct TopAppBarDefaults;
578
579impl TopAppBarDefaults {
580    pub const HEIGHT: f32 = 64.0;
581    pub fn container_color() -> Color {
582        theme().surface
583    }
584    pub fn title_content_color() -> Color {
585        theme().on_surface
586    }
587    pub fn navigation_icon_content_color() -> Color {
588        theme().on_surface
589    }
590    pub fn action_icon_content_color() -> Color {
591        theme().on_surface_variant
592    }
593}
594
595/// Default values for tab row.
596pub struct TabDefaults;
597
598impl TabDefaults {
599    pub const HEIGHT: f32 = 48.0;
600    pub const INDICATOR_HEIGHT: f32 = 3.0;
601    pub const INDICATOR_CORNER: f32 = 1.5;
602    pub fn container_color() -> Color {
603        theme().surface
604    }
605    pub fn selected_content_color() -> Color {
606        theme().primary
607    }
608    pub fn unselected_content_color() -> Color {
609        theme().on_surface_variant
610    }
611    pub fn indicator_color() -> Color {
612        theme().primary
613    }
614}
615
616/// Default values for navigation bar.
617pub struct NavigationBarDefaults;
618
619impl NavigationBarDefaults {
620    pub const HEIGHT: f32 = 80.0;
621    pub const TONAL_ELEVATION: f32 = 0.0;
622    pub const ITEM_ACTIVE_INDICATOR_OPACITY: f32 = 1.0;
623    pub const ITEM_SPACING: f32 = 8.0;
624    pub const ACTIVE_INDICATOR_WIDTH: f32 = 56.0;
625    pub const ACTIVE_INDICATOR_HEIGHT: f32 = 32.0;
626    pub fn container_color() -> Color {
627        theme().surface_container
628    }
629    pub fn content_color() -> Color {
630        theme().on_surface
631    }
632    pub fn selected_icon_color() -> Color {
633        theme().on_secondary_container
634    }
635    pub fn selected_text_color() -> Color {
636        theme().secondary
637    }
638    pub fn unselected_icon_color() -> Color {
639        theme().on_surface_variant
640    }
641    pub fn unselected_text_color() -> Color {
642        theme().on_surface_variant
643    }
644    pub fn indicator_color() -> Color {
645        theme().secondary_container
646    }
647    pub const INDICATOR_RADIUS: f32 = 16.0;
648}
649
650/// Default values for navigation rail.
651pub struct NavigationRailDefaults;
652
653impl NavigationRailDefaults {
654    pub const WIDTH: f32 = 80.0;
655    pub const ITEM_RADIUS: f32 = 16.0;
656    pub const ITEM_MIN_HEIGHT: f32 = 56.0;
657    pub const ITEM_ACTIVE_INDICATOR_OPACITY: f32 = 1.0;
658    pub const ITEM_SPACING: f32 = 4.0;
659    pub const ACTIVE_INDICATOR_WIDTH: f32 = 56.0;
660    pub const ACTIVE_INDICATOR_HEIGHT: f32 = 32.0;
661    pub fn container_color() -> Color {
662        theme().surface
663    }
664    pub fn selected_icon_color() -> Color {
665        theme().on_secondary_container
666    }
667    pub fn selected_text_color() -> Color {
668        theme().secondary
669    }
670    pub fn unselected_icon_color() -> Color {
671        theme().on_surface_variant
672    }
673    pub fn unselected_text_color() -> Color {
674        theme().on_surface_variant
675    }
676    pub fn indicator_color() -> Color {
677        theme().secondary_container
678    }
679}
680
681/// Default values for segmented button.
682pub struct SegmentedButtonDefaults;
683
684impl SegmentedButtonDefaults {
685    pub const HEIGHT: f32 = 40.0;
686    pub const SHAPE_RADIUS: f32 = 20.0;
687    pub fn border_color() -> Color {
688        theme().outline
689    }
690    pub fn selected_container_color() -> Color {
691        theme().secondary_container
692    }
693    pub fn selected_content_color() -> Color {
694        theme().on_secondary_container
695    }
696    pub fn unselected_content_color() -> Color {
697        theme().on_surface
698    }
699    pub fn state_colors_default() -> StateColors {
700        let th = theme();
701        StateColors {
702            default: Color::TRANSPARENT,
703            hovered: th.on_surface.with_alpha_f32(0.08),
704            pressed: th.on_surface.with_alpha_f32(0.12),
705            disabled: Color::TRANSPARENT,
706        }
707    }
708}
709
710/// Default values for FAB.
711pub struct FABDefaults;
712
713impl FABDefaults {
714    pub const SMALL_SIZE: f32 = 40.0;
715    pub const SMALL_SHAPE_RADIUS: f32 = 12.0;
716    pub const SIZE: f32 = 56.0;
717    pub const LARGE_SIZE: f32 = 96.0;
718    pub const SHAPE_RADIUS: f32 = 28.0;
719    pub const LARGE_SHAPE_RADIUS: f32 = 28.0;
720    pub fn container_color() -> Color {
721        theme().primary_container
722    }
723    pub fn content_color() -> Color {
724        theme().on_primary_container
725    }
726    pub fn state_elevation() -> StateElevation {
727        StateElevation {
728            default: 6.0,
729            hovered: 8.0,
730            pressed: 12.0,
731            disabled: 0.0,
732        }
733    }
734}
735
736/// Default values for chip components.
737pub struct ChipDefaults;
738
739impl ChipDefaults {
740    pub const HEIGHT: f32 = 32.0;
741    pub const HORIZONTAL_PADDING: f32 = 16.0;
742    pub const SHAPE_RADIUS: f32 = 8.0;
743    pub const BORDER_WIDTH: f32 = 1.0;
744
745    // Colors for non-selected state
746    pub fn container_color() -> Color {
747        Color::TRANSPARENT
748    }
749    pub fn label_color() -> Color {
750        theme().on_surface_variant
751    }
752    pub fn leading_icon_color() -> Color {
753        theme().primary
754    }
755    pub fn trailing_icon_color() -> Color {
756        theme().primary
757    }
758
759    // Disabled colors (non-selected)
760    pub fn disabled_container_color() -> Color {
761        Color::TRANSPARENT
762    }
763    pub fn disabled_label_color() -> Color {
764        theme().on_surface.with_alpha_f32(0.38)
765    }
766    pub fn disabled_leading_icon_color() -> Color {
767        theme().on_surface.with_alpha_f32(0.38)
768    }
769    pub fn disabled_trailing_icon_color() -> Color {
770        theme().on_surface.with_alpha_f32(0.38)
771    }
772
773    // Colors for selected state
774    pub fn selected_container_color() -> Color {
775        theme().secondary_container
776    }
777    pub fn selected_label_color() -> Color {
778        theme().on_secondary_container
779    }
780    pub fn selected_leading_icon_color() -> Color {
781        theme().primary
782    }
783    pub fn selected_trailing_icon_color() -> Color {
784        theme().on_secondary_container
785    }
786
787    // Disabled selected container
788    pub fn disabled_selected_container_color() -> Color {
789        theme()
790            .on_surface
791            .with_alpha_f32(0.12)
792            .composite_over(theme().secondary_container)
793    }
794
795    // Border colors
796    pub fn border_color() -> Color {
797        theme().outline_variant
798    }
799    pub fn selected_border_color() -> Color {
800        Color::TRANSPARENT
801    }
802    pub fn disabled_border_color() -> Color {
803        theme().on_surface.with_alpha_f32(0.12)
804    }
805    pub fn disabled_selected_border_color() -> Color {
806        Color::TRANSPARENT
807    }
808
809    // Elevation defaults (flat chip - no elevation)
810    pub fn elevation_default() -> f32 {
811        0.0
812    }
813    pub fn elevation_hovered() -> f32 {
814        0.0
815    }
816    pub fn elevation_focused() -> f32 {
817        0.0
818    }
819    pub fn elevation_pressed() -> f32 {
820        0.0
821    }
822    pub fn elevation_dragged() -> f32 {
823        0.0
824    }
825    pub fn elevation_disabled() -> f32 {
826        0.0
827    }
828
829    // Elevated chip defaults
830    pub fn elevated_elevation_default() -> f32 {
831        theme().elevation.level1
832    }
833    pub fn elevated_elevation_hovered() -> f32 {
834        theme().elevation.level2
835    }
836    pub fn elevated_elevation_focused() -> f32 {
837        theme().elevation.level1
838    }
839    pub fn elevated_elevation_pressed() -> f32 {
840        theme().elevation.level1
841    }
842    pub fn elevated_elevation_dragged() -> f32 {
843        theme().elevation.level3
844    }
845    pub fn elevated_elevation_disabled() -> f32 {
846        0.0
847    }
848
849    // Elevated chip container colors
850    pub fn elevated_container_color() -> Color {
851        theme().surface_container_low
852    }
853    pub fn elevated_selected_container_color() -> Color {
854        theme().secondary_container
855    }
856    pub fn disabled_elevated_container_color() -> Color {
857        theme()
858            .on_surface
859            .with_alpha_f32(0.12)
860            .composite_over(theme().surface_container_low)
861    }
862}
863
864/// Default values for scaffold layout.
865pub struct ScaffoldDefaults;
866
867impl ScaffoldDefaults {
868    pub fn container_color() -> Color {
869        theme().background
870    }
871    pub const TOP_BAR_HEIGHT: f32 = 64.0;
872    pub const BOTTOM_BAR_HEIGHT: f32 = 80.0;
873    pub const FAB_MARGIN: f32 = 16.0;
874}
875
876/// Default values for navigation drawer.
877pub struct NavigationDrawerDefaults;
878
879impl NavigationDrawerDefaults {
880    pub const WIDTH: f32 = 300.0;
881    pub const TONAL_ELEVATION: f32 = 0.0;
882    pub fn container_color() -> Color {
883        theme().surface_container_low
884    }
885    pub fn content_color() -> Color {
886        theme().on_surface_variant
887    }
888    pub fn scrim_color() -> Color {
889        theme().scrim.with_alpha(82)
890    }
891    pub const SHAPE_RADIUS: f32 = 16.0;
892}
893
894/// Default values for bottom sheet / modal bottom sheet.
895pub struct BottomSheetDefaults;
896
897impl BottomSheetDefaults {
898    pub const TONAL_ELEVATION: f32 = 0.0;
899    pub fn container_color() -> Color {
900        theme().surface_container_low
901    }
902    pub fn content_color() -> Color {
903        theme().on_surface
904    }
905    pub fn drag_handle_color() -> Color {
906        theme().on_surface_variant
907    }
908    pub fn scrim_color() -> Color {
909        theme().scrim.with_alpha(85)
910    }
911    pub const DRAG_HANDLE_WIDTH: f32 = 32.0;
912    pub const DRAG_HANDLE_HEIGHT: f32 = 4.0;
913    pub const SHAPE_RADIUS: f32 = 16.0;
914    pub const PEEK_HEIGHT: f32 = 56.0;
915    pub const MAX_WIDTH: f32 = 640.0;
916}
917
918/// Default values for search bar.
919pub struct SearchBarDefaults;
920
921impl SearchBarDefaults {
922    pub const HEIGHT: f32 = 56.0;
923    pub const EXPANDED_WIDTH: f32 = 360.0;
924    pub const COLLAPSED_WIDTH: f32 = 240.0;
925    pub const DOCKED_HEIGHT: f32 = 400.0;
926    pub fn container_color() -> Color {
927        theme().surface_container
928    }
929    pub fn active_container_color() -> Color {
930        theme().surface_container_high
931    }
932    pub fn content_color() -> Color {
933        theme().on_surface
934    }
935    pub fn placeholder_color() -> Color {
936        theme().on_surface_variant
937    }
938}
939
940/// Default values for dropdown menu.
941pub struct DropdownMenuDefaults;
942
943impl DropdownMenuDefaults {
944    pub const MIN_WIDTH: f32 = 112.0;
945    pub const ITEM_HEIGHT: f32 = 40.0;
946    pub fn container_color() -> Color {
947        theme().surface_container
948    }
949    pub fn item_text_color() -> Color {
950        theme().on_surface
951    }
952    pub fn disabled_item_text_color() -> Color {
953        theme().on_surface.with_alpha_f32(0.38)
954    }
955    pub fn divider_color() -> Color {
956        theme().outline_variant
957    }
958}
959
960/// Default values for tooltip.
961pub struct TooltipDefaults;
962
963impl TooltipDefaults {
964    pub const OFFSET_Y: f32 = -28.0;
965    pub const HORIZONTAL_PADDING: f32 = 8.0;
966    pub const VERTICAL_PADDING: f32 = 4.0;
967    pub fn container_color() -> Color {
968        theme().inverse_surface
969    }
970    pub fn content_color() -> Color {
971        theme().inverse_on_surface
972    }
973}
974
975/// Default values for pull-to-refresh.
976pub struct PullToRefreshDefaults;
977
978impl PullToRefreshDefaults {
979    pub const THRESHOLD: f32 = 64.0;
980    pub fn indicator_color() -> Color {
981        theme().primary
982    }
983    pub fn container_color() -> Color {
984        Color::TRANSPARENT
985    }
986}
987
988/// Default values for alert dialog.
989pub struct AlertDialogDefaults;
990
991impl AlertDialogDefaults {
992    pub const MIN_WIDTH: f32 = 280.0;
993    pub const MAX_WIDTH: f32 = 560.0;
994    pub const HORIZONTAL_PADDING: f32 = 24.0;
995    pub fn scrim_color() -> Color {
996        theme().scrim.with_alpha(82)
997    }
998}
999
1000/// Default values for outlined text field.
1001pub struct OutlinedTextFieldDefaults;
1002
1003impl OutlinedTextFieldDefaults {
1004    pub const MIN_HEIGHT: f32 = 56.0;
1005    pub const MIN_WIDTH: f32 = 280.0;
1006    pub const UNFOCUSED_BORDER_THICKNESS: f32 = 1.0;
1007    pub const FOCUSED_BORDER_THICKNESS: f32 = 2.0;
1008    pub const TEXT_FIELD_PADDING: f32 = 16.0;
1009    pub const VERTICAL_PADDING_WITH_LABEL: f32 = 8.0;
1010
1011    pub fn label_color() -> Color {
1012        theme().on_surface_variant
1013    }
1014    pub fn focused_label_color() -> Color {
1015        theme().primary
1016    }
1017    pub fn error_label_color() -> Color {
1018        theme().error
1019    }
1020    pub fn input_color() -> Color {
1021        theme().on_surface
1022    }
1023    pub fn disabled_input_color() -> Color {
1024        theme().on_surface.with_alpha_f32(0.38)
1025    }
1026    pub fn supporting_color() -> Color {
1027        theme().on_surface_variant
1028    }
1029    pub fn placeholder_color() -> Color {
1030        theme().on_surface_variant
1031    }
1032    pub fn leading_icon_color() -> Color {
1033        theme().on_surface_variant
1034    }
1035    pub fn trailing_icon_color() -> Color {
1036        theme().on_surface_variant
1037    }
1038    pub fn unfocused_border_color() -> Color {
1039        theme().outline
1040    }
1041    pub fn focused_border_color() -> Color {
1042        theme().primary
1043    }
1044    pub fn error_border_color() -> Color {
1045        theme().error
1046    }
1047    pub fn cursor_color() -> Color {
1048        theme().primary
1049    }
1050    pub fn container_color() -> Color {
1051        theme().surface
1052    }
1053}
1054
1055/// Default values for date picker.
1056pub struct DatePickerDefaults;
1057
1058impl DatePickerDefaults {
1059    pub const CONTAINER_WIDTH: f32 = 360.0;
1060    pub const CONTAINER_HEIGHT: f32 = 568.0;
1061    pub const HEADER_CONTAINER_HEIGHT: f32 = 120.0;
1062    pub const DATE_CELL_SIZE: f32 = 40.0;
1063    pub const YEAR_CELL_HEIGHT: f32 = 36.0;
1064    pub const YEAR_CELL_WIDTH: f32 = 72.0;
1065    pub const TODAY_BORDER_WIDTH: f32 = 1.0;
1066    pub const HORIZONTAL_PADDING: f32 = 12.0;
1067
1068    pub fn container_color() -> Color {
1069        theme().surface_container_high
1070    }
1071    pub fn header_color() -> Color {
1072        theme().on_surface_variant
1073    }
1074    pub fn weekday_color() -> Color {
1075        theme().on_surface
1076    }
1077    pub fn day_color() -> Color {
1078        theme().on_surface
1079    }
1080    pub fn selected_day_color() -> Color {
1081        theme().on_primary
1082    }
1083    pub fn selected_day_container_color() -> Color {
1084        theme().primary
1085    }
1086    pub fn today_content_color() -> Color {
1087        theme().primary
1088    }
1089    pub fn today_border_color() -> Color {
1090        theme().primary
1091    }
1092    pub fn year_selected_container_color() -> Color {
1093        theme().primary
1094    }
1095    pub fn year_selected_content_color() -> Color {
1096        theme().on_primary
1097    }
1098    pub fn year_unselected_content_color() -> Color {
1099        theme().on_surface_variant
1100    }
1101}
1102
1103/// Default values for time picker.
1104pub struct TimePickerDefaults;
1105
1106impl TimePickerDefaults {
1107    pub const CLOCK_DIAL_CONTAINER_SIZE: f32 = 256.0;
1108    pub const CLOCK_DIAL_MIN_CONTAINER_SIZE: f32 = 200.0;
1109    pub const PERIOD_SELECTOR_HORIZONTAL_WIDTH: f32 = 216.0;
1110    pub const PERIOD_SELECTOR_HORIZONTAL_HEIGHT: f32 = 38.0;
1111    pub const PERIOD_SELECTOR_VERTICAL_WIDTH: f32 = 52.0;
1112    pub const PERIOD_SELECTOR_VERTICAL_HEIGHT: f32 = 80.0;
1113    pub const TIME_SELECTOR_CONTAINER_WIDTH: f32 = 96.0;
1114    pub const TIME_SELECTOR_CONTAINER_HEIGHT: f32 = 80.0;
1115    pub const TIME_SELECTOR_24H_WIDTH: f32 = 114.0;
1116    pub const MAX_HEIGHT: f32 = 384.0;
1117
1118    pub fn clock_dial_color() -> Color {
1119        theme().surface_container_highest
1120    }
1121    pub fn clock_dial_selected_content_color() -> Color {
1122        theme().on_primary
1123    }
1124    pub fn clock_dial_unselected_content_color() -> Color {
1125        theme().on_surface
1126    }
1127    pub fn selector_color() -> Color {
1128        theme().primary
1129    }
1130    pub fn container_color() -> Color {
1131        theme().surface_container_high
1132    }
1133    pub fn period_selector_selected_container_color() -> Color {
1134        theme().tertiary_container
1135    }
1136    pub fn period_selector_selected_content_color() -> Color {
1137        theme().on_tertiary_container
1138    }
1139    pub fn period_selector_unselected_content_color() -> Color {
1140        theme().on_surface_variant
1141    }
1142    pub fn period_selector_border_color() -> Color {
1143        theme().outline
1144    }
1145    pub fn time_selector_selected_container_color() -> Color {
1146        theme().primary_container
1147    }
1148    pub fn time_selector_selected_content_color() -> Color {
1149        theme().on_primary_container
1150    }
1151    pub fn time_selector_unselected_container_color() -> Color {
1152        theme().surface_container_highest
1153    }
1154    pub fn time_selector_unselected_content_color() -> Color {
1155        theme().on_surface
1156    }
1157    pub fn time_selector_separator_color() -> Color {
1158        theme().on_surface
1159    }
1160}
1161
1162/// Default values for swipe-to-dismiss.
1163pub struct SwipeToDismissDefaults;
1164
1165impl SwipeToDismissDefaults {
1166    pub const POSITIONAL_THRESHOLD: f32 = 56.0;
1167    pub const DISMISS_THRESHOLD: f32 = 150.0;
1168    pub const DISMISSED_OFFSET: f32 = 300.0;
1169    pub const MAX_WIDTH: f32 = 400.0;
1170}
1171
1172/// Default values for carousel.
1173pub struct CarouselDefaults;
1174
1175impl CarouselDefaults {
1176    pub const MIN_SMALL_ITEM_SIZE: f32 = 40.0;
1177    pub const MAX_SMALL_ITEM_SIZE: f32 = 56.0;
1178    pub const ANCHOR_SIZE: f32 = 10.0;
1179}