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")]
83#[allow(deprecated)]
84pub use slider::{
85    RangeThumb, Slider, SliderColors, SliderEvent, SliderKind, SliderMarker, SliderScale,
86    SliderState, SliderThumbStyle, SliderTrackStyle, SliderValue,
87};
88
89#[cfg(feature = "surfaces")]
90mod card;
91#[cfg(any(feature = "surfaces", feature = "navigation"))]
92mod drag_handle;
93#[cfg(feature = "surfaces")]
94mod drop_target;
95#[cfg(feature = "surfaces")]
96mod list;
97#[cfg(feature = "surfaces")]
98mod settings_tiles;
99#[cfg(feature = "surfaces")]
100mod swipe_to_dismiss;
101
102#[cfg(feature = "surfaces")]
103pub use card::{Card, CardColors, CardVariant};
104#[cfg(any(feature = "surfaces", feature = "navigation"))]
105pub use drag_handle::{DragHandleColors, DragHandleShapes, DragHandleSizes, VerticalDragHandle};
106#[cfg(feature = "surfaces")]
107pub use drop_target::{DropTarget, DropTargetColors};
108#[cfg(feature = "surfaces")]
109pub use list::{
110    List, ListItem, ListItemAlignment, ListItemColors, ListItemShapes, ListItemStateColors,
111    ListVariant,
112};
113#[cfg(feature = "settings-tiles")]
114pub use settings_tiles::{
115    CheckboxTile, ChoiceOption, ChoiceTile, RadioTile, SliderTile, SwitchTile,
116};
117#[cfg(feature = "surfaces")]
118pub use settings_tiles::{ListSection, ListSectionItem};
119#[cfg(feature = "surfaces")]
120pub use swipe_to_dismiss::{SwipeToDismiss, SwipeToDismissState, SwipeToDismissValue};
121
122#[cfg(feature = "feedback")]
123mod banner;
124#[cfg(feature = "feedback")]
125mod loading_indicator;
126#[cfg(feature = "feedback")]
127mod overlay;
128#[cfg(feature = "feedback")]
129mod progress;
130#[cfg(feature = "feedback")]
131mod pull_to_refresh;
132
133#[cfg(feature = "feedback")]
134pub use banner::{Banner, BannerColors};
135#[cfg(feature = "feedback")]
136pub use loading_indicator::{LoadingIndicator, LoadingIndicatorShape, LoadingIndicatorShapes};
137#[cfg(feature = "feedback")]
138pub use overlay::{
139    BottomSheetState, BottomSheetThresholds, BottomSheetValue, Dialog, DialogAction,
140    DialogCloseReason, DialogColors, DialogProperties, DialogState, DialogVariant, Label, Menu,
141    MenuColor, MenuItem, MenuItemStyle, Sheet, SheetClose, SheetColors, SheetEdge, SheetMode,
142    SheetPlacement, Snackbar, SnackbarColors, SnackbarHost, SnackbarId, SnackbarParts,
143    SnackbarResult, Tooltip, TooltipCaret, TooltipColors, TooltipPlacement, TooltipPositioner,
144    TooltipState,
145};
146#[cfg(feature = "feedback")]
147pub use progress::{
148    CircularProgress, LinearProgress, ProgressCap, ProgressShape, ProgressStop, ProgressStroke,
149};
150#[cfg(feature = "feedback")]
151pub use pull_to_refresh::{PullToRefresh, PullToRefreshProgress, PullToRefreshState};
152
153#[cfg(feature = "inputs")]
154mod input;
155
156#[cfg(feature = "inputs")]
157pub use input::{
158    DropdownAnchor, DropdownOption, ExposedDropdown, ExposedDropdownState, TextAreaState,
159    TextField, TextFieldColorOverrides, TextFieldColors, TextFieldEvent, TextFieldLabelAlignment,
160    TextFieldLabelPosition, TextFieldLayout, TextFieldMaskPattern, TextFieldObfuscationMode,
161    TextFieldState, TextFieldVariant,
162};
163
164#[cfg(feature = "navigation")]
165mod navigation;
166
167#[cfg(feature = "navigation")]
168pub use navigation::{
169    AdaptiveNavigation, AdaptiveNavigationInfo, AdaptiveNavigationState, AdaptiveNavigationType,
170    AdaptiveNavigationVisibility, AdaptivePane, AdaptivePaneLayout, AdaptivePaneState, AppBar,
171    AppBarAlignment, AppBarColors, AppBarColumn, AppBarItem, AppBarMenuState, AppBarRow,
172    AppBarScrollBehavior, AppBarScrollState, AppBarVariant, BottomAppBar, BottomAppBarColors,
173    BreadcrumbItem, Breadcrumbs, BreadcrumbsColors, Feed, ListDetail, ListDetailPane,
174    NavigationBar, NavigationBarArrangement, NavigationBarColors, NavigationBarLayout,
175    NavigationDrawer, NavigationDrawerColors, NavigationDrawerEntry, NavigationDrawerMode,
176    NavigationDrawerSection, NavigationItem, NavigationItemColors, NavigationItemIconPosition,
177    NavigationItems, NavigationRail, NavigationRailArrangement, NavigationRailColors,
178    NavigationRailShapes, NavigationRailState, PaneAdaptStrategy, PaneBackBehavior,
179    PaneDestination, PaneExpansionAnchor, PaneLayoutDirective, PaneLayoutValue,
180    PaneOverlayAlignment, PanePlacement, PaneRole, PaneSeparator, RailModalOptions, RailMode,
181    Scaffold, ScaffoldContentLayout, ScaffoldFabPosition, StepItem, StepStatus, Stepper,
182    StepperColors, StepperOrientation, SupportingPane, TabIndicatorLayout, TabIndicatorStyle,
183    TabIndicatorWidth, TabVariant, Tabs, TabsColors,
184};
185
186/// Installs component keybindings after initializing the Material root.
187pub fn init_components(cx: &mut gpui::App) {
188    #[cfg(feature = "feedback")]
189    overlay::init_tooltip(cx);
190    #[cfg(not(feature = "feedback"))]
191    let _ = cx;
192}