repose_material/material3/
defaults.rs1use repose_core::*;
2
3pub struct SurfaceDefaults;
5
6impl SurfaceDefaults {
7 pub fn color() -> Color {
8 theme().surface
9 }
10 pub const SHAPE_RADIUS: f32 = 0.0;
11 pub const TONAL_ELEVATION: f32 = 0.0;
12}
13
14pub struct ToggleButtonDefaults;
16
17impl ToggleButtonDefaults {
18 pub const HEIGHT: f32 = 40.0;
19 pub const HORIZONTAL_PADDING: f32 = 24.0;
20 pub const SHAPE_RADIUS: f32 = 20.0;
21 pub fn content_color() -> Color {
22 theme().on_surface_variant
23 }
24 pub fn checked_container_color() -> Color {
25 theme().primary
26 }
27 pub fn checked_content_color() -> Color {
28 theme().on_primary
29 }
30 pub fn tonal_content_color() -> Color {
31 theme().on_surface_variant
32 }
33 pub fn tonal_checked_container_color() -> Color {
34 theme().secondary_container
35 }
36 pub fn tonal_checked_content_color() -> Color {
37 theme().on_secondary_container
38 }
39 pub fn outlined_content_color() -> Color {
40 theme().on_surface_variant
41 }
42 pub fn outlined_border_color() -> Color {
43 theme().outline
44 }
45 pub fn outlined_checked_container_color() -> Color {
46 theme().secondary_container
47 }
48 pub fn outlined_checked_content_color() -> Color {
49 theme().on_secondary_container
50 }
51 pub fn elevated_content_color() -> Color {
52 theme().primary
53 }
54 pub fn elevated_checked_container_color() -> Color {
55 theme().surface_container_low
56 }
57 pub fn elevated_checked_content_color() -> Color {
58 theme().primary
59 }
60 pub fn state_colors_default() -> StateColors {
61 let th = theme();
62 StateColors {
63 default: Color::TRANSPARENT,
64 hovered: th.on_surface.with_alpha_f32(0.08),
65 pressed: th.on_surface.with_alpha_f32(0.12),
66 disabled: th.on_surface.with_alpha_f32(0.12),
67 }
68 }
69 pub fn state_elevation_default() -> StateElevation {
70 StateElevation {
71 default: 0.0,
72 hovered: 1.0,
73 pressed: 0.0,
74 disabled: 0.0,
75 }
76 }
77 pub fn elevated_state_elevation() -> StateElevation {
78 let th = theme();
79 StateElevation {
80 default: th.elevation.level1,
81 hovered: th.elevation.level2,
82 pressed: th.elevation.level1,
83 disabled: 0.0,
84 }
85 }
86}
87
88pub struct ProgressIndicatorDefaults;
90
91impl ProgressIndicatorDefaults {
92 pub fn linear_color() -> Color {
93 theme().primary
94 }
95 pub fn linear_track_color() -> Color {
96 theme().secondary_container
97 }
98 pub const LINEAR_INDICATOR_HEIGHT: f32 = 4.0;
99 pub const LINEAR_INDICATOR_GAP_SIZE: f32 = 4.0;
100 pub const LINEAR_TRACK_STOP_SIZE: f32 = 4.0;
101
102 pub fn circular_color() -> Color {
103 theme().primary
104 }
105 pub fn circular_track_color() -> Color {
106 theme().secondary_container
107 }
108 pub const CIRCULAR_INDICATOR_SIZE: f32 = 40.0;
109 pub const CIRCULAR_STROKE_WIDTH: f32 = 4.0;
110}
111
112pub struct ButtonDefaults;
114
115impl ButtonDefaults {
116 pub fn content_color() -> Color {
117 theme().on_primary
118 }
119 pub fn container_color() -> Color {
120 theme().primary
121 }
122 pub fn tonal_container_color() -> Color {
123 theme().secondary_container
124 }
125 pub fn tonal_content_color() -> Color {
126 theme().on_secondary_container
127 }
128 pub fn elevated_container_color() -> Color {
129 theme().surface_container_low
130 }
131 pub fn elevated_content_color() -> Color {
132 theme().primary
133 }
134 pub fn outlined_content_color() -> Color {
135 theme().on_surface_variant
136 }
137 pub fn outlined_border_color() -> Color {
138 theme().outline_variant
139 }
140 pub fn text_content_color() -> Color {
141 theme().primary
142 }
143 pub const HEIGHT: f32 = 40.0;
144 pub const HORIZONTAL_PADDING: f32 = 24.0;
145 pub const TEXT_HORIZONTAL_PADDING: f32 = 12.0;
146 pub const SHAPE_RADIUS: f32 = 20.0;
147 pub fn state_colors_default() -> StateColors {
148 let th = theme();
149 StateColors {
150 default: Color::TRANSPARENT,
151 hovered: th.on_surface.with_alpha_f32(0.08),
152 pressed: th.on_surface.with_alpha_f32(0.12),
153 disabled: th.on_surface.with_alpha_f32(0.12),
154 }
155 }
156 pub fn state_elevation_default() -> StateElevation {
157 StateElevation {
158 default: 0.0,
159 hovered: 1.0,
160 pressed: 0.0,
161 disabled: 0.0,
162 }
163 }
164 pub fn elevated_state_elevation() -> StateElevation {
165 let th = theme();
166 StateElevation {
167 default: th.elevation.level1,
168 hovered: th.elevation.level2,
169 pressed: th.elevation.level1,
170 disabled: 0.0,
171 }
172 }
173}
174
175pub struct SnackbarDefaults;
177
178impl SnackbarDefaults {
179 pub const MIN_HEIGHT: f32 = 48.0;
180 pub const MIN_WIDTH: f32 = 280.0;
181 pub const MAX_WIDTH: f32 = 600.0;
182 pub const SHAPE_RADIUS: f32 = 4.0;
183 pub fn container_color() -> Color {
184 theme().inverse_surface
185 }
186 pub fn content_color() -> Color {
187 theme().inverse_on_surface
188 }
189 pub fn action_color() -> Color {
190 theme().inverse_primary
191 }
192}
193
194pub struct CardDefaults;
196
197impl CardDefaults {
198 pub fn filled_container_color() -> Color {
199 theme().surface_container_highest
200 }
201 pub fn elevated_container_color() -> Color {
202 theme().surface_container_low
203 }
204 pub fn outlined_container_color() -> Color {
205 theme().surface
206 }
207 pub fn outlined_border_color() -> Color {
208 theme().outline_variant
209 }
210 pub const SHAPE_RADIUS: f32 = 12.0;
211 pub const ELEVATION: f32 = 0.0;
212}
213
214pub struct DialogDefaults;
216
217impl DialogDefaults {
218 pub fn container_color() -> Color {
219 theme().surface_container_high
220 }
221 pub const SHAPE_RADIUS: f32 = 28.0;
222 pub const MIN_WIDTH: f32 = 280.0;
223 pub const MAX_WIDTH: f32 = 560.0;
224 pub const HORIZONTAL_PADDING: f32 = 24.0;
225}
226
227pub struct IconButtonDefaults;
229
230impl IconButtonDefaults {
231 pub const CONTAINER_SIZE: f32 = 48.0;
232 pub const FILLED_CONTAINER_SIZE: f32 = 40.0;
233 pub fn content_color() -> Color {
234 theme().on_surface_variant
235 }
236 pub fn filled_content_color() -> Color {
237 theme().on_primary
238 }
239 pub fn filled_container_color() -> Color {
240 theme().primary
241 }
242 pub fn filled_tonal_content_color() -> Color {
243 theme().on_secondary_container
244 }
245 pub fn filled_tonal_container_color() -> Color {
246 theme().secondary_container
247 }
248 pub fn state_colors_default() -> StateColors {
249 let th = theme();
250 StateColors {
251 default: Color::TRANSPARENT,
252 hovered: th.on_surface.with_alpha_f32(0.08),
253 pressed: th.on_surface.with_alpha_f32(0.12),
254 disabled: Color::TRANSPARENT,
255 }
256 }
257}
258
259pub struct CheckboxDefaults;
261
262impl CheckboxDefaults {
263 pub const TOUCH_TARGET_SIZE: f32 = 40.0;
264 pub const BOX_SIZE: f32 = 18.0;
265 pub const STROKE_WIDTH: f32 = 2.0;
266 pub const CORNER_RADIUS: f32 = 2.0;
267 pub const CHECK_ICON_SIZE: f32 = 14.0;
268 pub fn checked_color() -> Color {
269 theme().primary
270 }
271 pub fn unchecked_color() -> Color {
272 theme().on_surface_variant
273 }
274 pub fn checkmark_color() -> Color {
275 theme().on_primary
276 }
277}
278
279pub struct RadioButtonDefaults;
281
282impl RadioButtonDefaults {
283 pub const TOUCH_TARGET_SIZE: f32 = 40.0;
284 pub const OUTER_RADIUS: f32 = 10.0;
285 pub const DOT_RADIUS: f32 = 5.0;
286 pub const STROKE_WIDTH: f32 = 2.0;
287 pub fn selected_color() -> Color {
288 theme().primary
289 }
290 pub fn unselected_color() -> Color {
291 theme().on_surface_variant
292 }
293}
294
295pub struct SwitchDefaults;
297
298impl SwitchDefaults {
299 pub const TRACK_WIDTH: f32 = 52.0;
300 pub const TRACK_HEIGHT: f32 = 32.0;
301 pub const THUMB_CHECKED_SIZE: f32 = 24.0;
302 pub const THUMB_UNCHECKED_SIZE: f32 = 16.0;
303 pub fn checked_track_color() -> Color {
304 theme().primary
305 }
306 pub fn unchecked_track_color() -> Color {
307 theme().surface_container_highest
308 }
309 pub fn checked_thumb_color() -> Color {
310 theme().on_primary
311 }
312 pub fn unchecked_thumb_color() -> Color {
313 theme().outline
314 }
315 pub fn unchecked_border_color() -> Color {
316 theme().outline
317 }
318}
319
320pub struct SliderDefaults;
322
323impl SliderDefaults {
324 pub const TRACK_HEIGHT: f32 = 4.0;
325 pub const THUMB_SIZE: f32 = 20.0;
326 pub fn active_track_color() -> Color {
327 theme().primary
328 }
329 pub fn inactive_track_color() -> Color {
330 theme().secondary_container
331 }
332 pub fn thumb_color() -> Color {
333 theme().primary
334 }
335}
336
337pub struct DividerDefaults;
339
340impl DividerDefaults {
341 pub const THICKNESS: f32 = 1.0;
342 pub fn color() -> Color {
343 theme().outline_variant
344 }
345}
346
347pub struct BadgeDefaults;
349
350impl BadgeDefaults {
351 pub const DOT_SIZE: f32 = 6.0;
352 pub const LABEL_MIN_WIDTH: f32 = 16.0;
353 pub const LABEL_HEIGHT: f32 = 16.0;
354 pub fn color() -> Color {
355 theme().error
356 }
357 pub fn label_color() -> Color {
358 theme().on_error
359 }
360}
361
362pub struct ListItemDefaults;
364
365impl ListItemDefaults {
366 pub const ONE_LINE_HEIGHT: f32 = 56.0;
367 pub const TWO_LINE_HEIGHT: f32 = 72.0;
368 pub const THREE_LINE_HEIGHT: f32 = 88.0;
369 pub const HORIZONTAL_PADDING: f32 = 16.0;
370 pub const TRAILING_PADDING: f32 = 24.0;
371 pub fn headline_color() -> Color {
372 theme().on_surface
373 }
374 pub fn supporting_color() -> Color {
375 theme().on_surface_variant
376 }
377}
378
379pub struct TopAppBarDefaults;
381
382impl TopAppBarDefaults {
383 pub const HEIGHT: f32 = 64.0;
384 pub fn container_color() -> Color {
385 theme().surface
386 }
387 pub fn title_color() -> Color {
388 theme().on_surface
389 }
390}
391
392pub struct TabDefaults;
394
395impl TabDefaults {
396 pub const HEIGHT: f32 = 48.0;
397 pub const INDICATOR_HEIGHT: f32 = 3.0;
398 pub const INDICATOR_CORNER: f32 = 1.5;
399 pub fn container_color() -> Color {
400 theme().surface
401 }
402 pub fn selected_content_color() -> Color {
403 theme().primary
404 }
405 pub fn unselected_content_color() -> Color {
406 theme().on_surface_variant
407 }
408 pub fn indicator_color() -> Color {
409 theme().primary
410 }
411}
412
413pub struct NavigationBarDefaults;
415
416impl NavigationBarDefaults {
417 pub const HEIGHT: f32 = 80.0;
418 pub const ITEM_ACTIVE_INDICATOR_OPACITY: f32 = 0.12;
419 pub fn container_color() -> Color {
420 theme().surface_container
421 }
422 pub fn selected_icon_color() -> Color {
423 theme().primary
424 }
425 pub fn unselected_icon_color() -> Color {
426 theme().on_surface_variant
427 }
428 pub fn indicator_color() -> Color {
429 theme().primary
430 }
431}
432
433pub struct NavigationRailDefaults;
435
436impl NavigationRailDefaults {
437 pub const WIDTH: f32 = 80.0;
438 pub fn container_color() -> Color {
439 theme().surface
440 }
441 pub fn selected_icon_color() -> Color {
442 theme().on_secondary_container
443 }
444 pub fn unselected_icon_color() -> Color {
445 theme().on_surface_variant
446 }
447 pub fn selected_container_color() -> Color {
448 theme().secondary_container
449 }
450}
451
452pub struct SegmentedButtonDefaults;
454
455impl SegmentedButtonDefaults {
456 pub const HEIGHT: f32 = 40.0;
457 pub const SHAPE_RADIUS: f32 = 20.0;
458 pub fn border_color() -> Color {
459 theme().outline
460 }
461 pub fn selected_container_color() -> Color {
462 theme().secondary_container
463 }
464 pub fn selected_content_color() -> Color {
465 theme().on_secondary_container
466 }
467 pub fn unselected_content_color() -> Color {
468 theme().on_surface
469 }
470}
471
472pub struct FABDefaults;
474
475impl FABDefaults {
476 pub const SIZE: f32 = 56.0;
477 pub const LARGE_SIZE: f32 = 96.0;
478 pub const SHAPE_RADIUS: f32 = 28.0;
479 pub const LARGE_SHAPE_RADIUS: f32 = 28.0;
480 pub fn container_color() -> Color {
481 theme().primary_container
482 }
483 pub fn content_color() -> Color {
484 theme().on_primary_container
485 }
486 pub fn state_elevation() -> StateElevation {
487 StateElevation {
488 default: 6.0,
489 hovered: 8.0,
490 pressed: 12.0,
491 disabled: 0.0,
492 }
493 }
494}
495
496pub struct ChipDefaults;
498
499impl ChipDefaults {
500 pub const HEIGHT: f32 = 32.0;
501 pub const HORIZONTAL_PADDING: f32 = 16.0;
502 pub const SHAPE_RADIUS: f32 = 8.0;
503 pub fn surface_color() -> Color {
504 theme().surface
505 }
506 pub fn selected_container_color() -> Color {
507 theme().secondary_container
508 }
509 pub fn selected_content_color() -> Color {
510 theme().on_secondary_container
511 }
512 pub fn unselected_content_color() -> Color {
513 theme().on_surface_variant
514 }
515 pub fn unselected_border_color() -> Color {
516 theme().outline_variant
517 }
518 pub fn assist_icon_color() -> Color {
519 theme().primary
520 }
521 pub fn input_selected_icon_color() -> Color {
522 theme().primary
523 }
524 pub fn input_unselected_icon_color() -> Color {
525 theme().on_surface_variant
526 }
527 pub fn suggestion_icon_color() -> Color {
528 theme().primary
529 }
530}
531
532pub struct ScaffoldDefaults;
534
535impl ScaffoldDefaults {
536 pub fn container_color() -> Color {
537 theme().background
538 }
539 pub const TOP_BAR_HEIGHT: f32 = 64.0;
540 pub const BOTTOM_BAR_HEIGHT: f32 = 80.0;
541 pub const FAB_MARGIN: f32 = 16.0;
542}
543
544pub struct NavigationDrawerDefaults;
546
547impl NavigationDrawerDefaults {
548 pub const WIDTH: f32 = 300.0;
549 pub fn container_color() -> Color {
550 theme().surface_container_low
551 }
552 pub fn scrim_color() -> Color {
553 theme().scrim.with_alpha(82)
554 }
555 pub const SHAPE_RADIUS: f32 = 16.0;
556}
557
558pub struct BottomSheetDefaults;
560
561impl BottomSheetDefaults {
562 pub fn container_color() -> Color {
563 theme().surface_container_low
564 }
565 pub fn drag_handle_color() -> Color {
566 theme().on_surface_variant
567 }
568 pub fn scrim_color() -> Color {
569 theme().scrim.with_alpha(85)
570 }
571 pub const DRAG_HANDLE_WIDTH: f32 = 32.0;
572 pub const DRAG_HANDLE_HEIGHT: f32 = 4.0;
573 pub const SHAPE_RADIUS: f32 = 16.0;
574 pub const PEEK_HEIGHT: f32 = 56.0;
575 pub const MAX_WIDTH: f32 = 640.0;
576}
577
578pub struct SearchBarDefaults;
580
581impl SearchBarDefaults {
582 pub const HEIGHT: f32 = 56.0;
583 pub const EXPANDED_WIDTH: f32 = 360.0;
584 pub const COLLAPSED_WIDTH: f32 = 240.0;
585 pub const DOCKED_HEIGHT: f32 = 400.0;
586 pub fn container_color() -> Color {
587 theme().surface_container
588 }
589 pub fn active_container_color() -> Color {
590 theme().surface_container_high
591 }
592 pub fn content_color() -> Color {
593 theme().on_surface
594 }
595 pub fn placeholder_color() -> Color {
596 theme().on_surface_variant
597 }
598}
599
600pub struct DropdownMenuDefaults;
602
603impl DropdownMenuDefaults {
604 pub const MIN_WIDTH: f32 = 112.0;
605 pub const ITEM_HEIGHT: f32 = 40.0;
606 pub fn container_color() -> Color {
607 theme().surface_container
608 }
609 pub fn item_text_color() -> Color {
610 theme().on_surface
611 }
612 pub fn disabled_item_text_color() -> Color {
613 theme().on_surface.with_alpha_f32(0.38)
614 }
615 pub fn divider_color() -> Color {
616 theme().outline_variant
617 }
618}
619
620pub struct TooltipDefaults;
622
623impl TooltipDefaults {
624 pub const OFFSET_Y: f32 = -28.0;
625 pub const HORIZONTAL_PADDING: f32 = 8.0;
626 pub const VERTICAL_PADDING: f32 = 4.0;
627 pub fn container_color() -> Color {
628 theme().inverse_surface
629 }
630 pub fn content_color() -> Color {
631 theme().inverse_on_surface
632 }
633}
634
635pub struct PullToRefreshDefaults;
637
638impl PullToRefreshDefaults {
639 pub const THRESHOLD: f32 = 64.0;
640 pub fn indicator_color() -> Color {
641 theme().primary
642 }
643 pub fn container_color() -> Color {
644 Color::TRANSPARENT
645 }
646}
647
648pub struct AlertDialogDefaults;
650
651impl AlertDialogDefaults {
652 pub const MIN_WIDTH: f32 = 280.0;
653 pub const MAX_WIDTH: f32 = 560.0;
654 pub const HORIZONTAL_PADDING: f32 = 24.0;
655 pub fn scrim_color() -> Color {
656 theme().scrim.with_alpha(170)
657 }
658}