Skip to main content

gpui_material_components/
lib.rs

1//! Material 3 components built on the pinned GPUI and Base interaction primitives.
2#![warn(missing_docs)]
3#![deny(rustdoc::broken_intra_doc_links)]
4
5#[cfg(any(feature = "actions", feature = "selection", feature = "surfaces"))]
6#[cfg_attr(
7    not(all(feature = "actions", feature = "selection", feature = "surfaces")),
8    allow(dead_code)
9)]
10mod action;
11mod avatar;
12#[cfg_attr(
13    not(any(feature = "actions", feature = "selection", feature = "surfaces")),
14    allow(dead_code)
15)]
16mod control_style;
17mod display;
18mod display_scrollbar;
19mod empty_view;
20mod ext;
21mod icon;
22#[cfg(any(feature = "feedback", feature = "inputs"))]
23mod menu_appearance;
24mod skeleton;
25mod text;
26mod tone;
27
28pub use avatar::{Avatar, AvatarColors, AvatarGroup, AvatarShape, AvatarSize};
29pub use control_style::ControlSize;
30pub use display::{Badge, Divider};
31pub use display_scrollbar::{
32    DisplayScrollbar, DisplayScrollbarFade, DisplayScrollbarStyle, ScrollbarHandle,
33};
34pub use empty_view::EmptyView;
35pub use ext::MaterialElementExt;
36pub use gpui_material_theme::LogicalEdges;
37pub use icon::{Icon, IconName};
38#[cfg(any(feature = "feedback", feature = "inputs"))]
39pub use menu_appearance::MenuSurfaceStyle;
40pub use skeleton::{Skeleton, SkeletonColors};
41pub use text::Text;
42pub use tone::SemanticTone;
43
44#[cfg(feature = "actions")]
45mod button;
46#[cfg(feature = "actions")]
47mod fab;
48
49#[cfg(feature = "actions")]
50#[doc(hidden)]
51pub use button::composition as button_composition;
52#[cfg(feature = "actions")]
53pub use button::{
54    Button, ButtonShape, ButtonVariant, IconButton, IconButtonVariant, IconButtonWidth,
55    IconToggleButton, ToggleButton, ToggleButtonVariant,
56};
57#[cfg(feature = "actions")]
58pub use control_style::ButtonColors;
59#[cfg(any(feature = "actions", feature = "selection", feature = "surfaces"))]
60pub use control_style::{ControlBorder, ControlElevations, ControlShapes};
61#[cfg(feature = "actions")]
62pub use fab::{
63    ExtendedFab, Fab, FabAlignment, FabColor, FabSize, FabVisibilityAnimation, FloatingAction,
64};
65
66#[cfg(feature = "selection")]
67mod chip;
68#[cfg(feature = "selection")]
69mod selection;
70#[cfg(feature = "selection")]
71mod slider;
72
73#[cfg(feature = "selection")]
74pub use chip::{
75    Chip, ChipColors, ChipGroup, ChipGroupItem, ChipGroupSelection, ChipStateColors, ChipVariant,
76};
77#[cfg(feature = "selection")]
78pub use selection::{
79    Checkbox, CheckboxColors, CheckboxState, CheckboxStateColors, Radio, RadioColors, RadioGroup,
80    Switch, SwitchColors, SwitchStateColors,
81};
82#[cfg(feature = "selection")]
83pub use slider::{
84    RangeThumb, Slider, SliderColors, SliderEvent, SliderKind, SliderMarker, SliderScale,
85    SliderState, SliderThumbStyle, SliderTrackStyle, SliderValue,
86};
87
88#[cfg(feature = "surfaces")]
89mod card;
90#[cfg(any(feature = "surfaces", feature = "navigation"))]
91mod drag_handle;
92#[cfg(feature = "surfaces")]
93mod drop_target;
94#[cfg(feature = "surfaces")]
95mod list;
96#[cfg(feature = "surfaces")]
97mod settings_tiles;
98#[cfg(feature = "surfaces")]
99mod swipe_to_dismiss;
100
101#[cfg(feature = "surfaces")]
102pub use card::{Card, CardColors, CardVariant};
103#[cfg(any(feature = "surfaces", feature = "navigation"))]
104pub use drag_handle::{DragHandleColors, DragHandleShapes, DragHandleSizes, VerticalDragHandle};
105#[cfg(feature = "surfaces")]
106pub use drop_target::{DropTarget, DropTargetColors};
107#[cfg(feature = "surfaces")]
108pub use list::{
109    List, ListItem, ListItemAlignment, ListItemColors, ListItemShapes, ListItemStateColors,
110    ListVariant,
111};
112#[cfg(feature = "settings-tiles")]
113pub use settings_tiles::{
114    CheckboxTile, ChoiceOption, ChoiceTile, RadioTile, SliderTile, SwitchTile,
115};
116#[cfg(feature = "surfaces")]
117pub use settings_tiles::{ListSection, ListSectionItem};
118#[cfg(feature = "surfaces")]
119pub use swipe_to_dismiss::{SwipeToDismiss, SwipeToDismissState, SwipeToDismissValue};
120
121#[cfg(feature = "feedback")]
122mod banner;
123#[cfg(feature = "feedback")]
124mod loading_indicator;
125#[cfg(feature = "feedback")]
126mod overlay;
127#[cfg(feature = "feedback")]
128mod progress;
129#[cfg(feature = "feedback")]
130mod pull_to_refresh;
131
132#[cfg(feature = "feedback")]
133pub use banner::{Banner, BannerColors};
134#[cfg(feature = "feedback")]
135pub use loading_indicator::{LoadingIndicator, LoadingIndicatorShape, LoadingIndicatorShapes};
136#[cfg(feature = "feedback")]
137pub use overlay::{
138    BottomSheetState, BottomSheetThresholds, BottomSheetValue, Dialog, DialogAction,
139    DialogCloseReason, DialogColors, DialogProperties, DialogState, DialogVariant, Label, Menu,
140    MenuColor, MenuItem, MenuItemStyle, Sheet, SheetClose, SheetColors, SheetEdge, SheetMode,
141    SheetPlacement, Snackbar, SnackbarColors, SnackbarHost, SnackbarId, SnackbarParts,
142    SnackbarResult, Tooltip, TooltipCaret, TooltipColors, TooltipPlacement, TooltipPositioner,
143    TooltipState,
144};
145#[cfg(feature = "feedback")]
146pub use progress::{
147    CircularProgress, LinearProgress, ProgressCap, ProgressShape, ProgressStop, ProgressStroke,
148};
149#[cfg(feature = "feedback")]
150pub use pull_to_refresh::{PullToRefresh, PullToRefreshProgress, PullToRefreshState};
151
152#[cfg(feature = "inputs")]
153mod input;
154
155#[cfg(feature = "inputs")]
156pub use input::{
157    DropdownAnchor, DropdownOption, ExposedDropdown, ExposedDropdownState, TextAreaState,
158    TextField, TextFieldColorOverrides, TextFieldColors, TextFieldEvent, TextFieldLabelAlignment,
159    TextFieldLabelPosition, TextFieldLayout, TextFieldMaskPattern, TextFieldObfuscationMode,
160    TextFieldState, TextFieldVariant,
161};
162
163#[cfg(feature = "navigation")]
164mod navigation;
165
166#[cfg(feature = "navigation")]
167pub use navigation::{
168    AdaptiveNavigation, AdaptiveNavigationInfo, AdaptiveNavigationState, AdaptiveNavigationType,
169    AdaptiveNavigationVisibility, AdaptivePane, AdaptivePaneLayout, AdaptivePaneState, AppBar,
170    AppBarAlignment, AppBarColors, AppBarColumn, AppBarItem, AppBarMenuState, AppBarRow,
171    AppBarScrollBehavior, AppBarScrollState, AppBarVariant, BottomAppBar, BottomAppBarColors,
172    BreadcrumbItem, Breadcrumbs, BreadcrumbsColors, Feed, ListDetail, ListDetailPane,
173    NavigationBar, NavigationBarArrangement, NavigationBarColors, NavigationBarLayout,
174    NavigationDrawer, NavigationDrawerColors, NavigationDrawerEntry, NavigationDrawerMode,
175    NavigationDrawerSection, NavigationItem, NavigationItemColors, NavigationItemIconPosition,
176    NavigationItems, NavigationRail, NavigationRailArrangement, NavigationRailColors,
177    NavigationRailShapes, NavigationRailState, PaneAdaptStrategy, PaneBackBehavior,
178    PaneDestination, PaneExpansionAnchor, PaneLayoutDirective, PaneLayoutValue,
179    PaneOverlayAlignment, PanePlacement, PaneRole, PaneSeparator, RailModalOptions, RailMode,
180    Scaffold, ScaffoldContentLayout, ScaffoldFabPosition, StepItem, StepStatus, Stepper,
181    StepperColors, StepperOrientation, SupportingPane, TabIndicatorLayout, TabIndicatorStyle,
182    TabIndicatorWidth, TabVariant, Tabs, TabsColors,
183};
184
185/// Installs component keybindings after initializing the Material root.
186pub fn init_components(cx: &mut gpui::App) {
187    #[cfg(feature = "feedback")]
188    overlay::init_tooltip(cx);
189    #[cfg(not(feature = "feedback"))]
190    let _ = cx;
191}