Skip to main content

Crate gpui_material

Crate gpui_material 

Source
Expand description

Material 3 Expressive controls and theme for GPUI applications.

Initialize MaterialRoot and call init_components before opening windows. Compose controls with GPUI elements and keep controlled selection and command outcomes in the application. Sliders use a retained SliderState entity.

Re-exports§

pub use gpui_material_foundation as foundation;
pub use gpui_material_theme as theme;

Structs§

AdaptiveNavigation
Material 3 navigation suite for the existing Scaffold bar and rail slots.
AdaptiveNavigationInfo
Available scaffold space for an application-supplied navigation policy.
AdaptiveNavigationState
Retained navigation visibility, independent of the current presentation.
AdaptivePane
A pane slot with stable identity, logical geometry preferences and adaptation.
AdaptivePaneLayout
A three-role scaffold with caller-supplied panes, an explicit available viewport, and retained layout, expansion and navigation state.
AdaptivePaneState
Retained presentation, expansion and navigation state for a single adaptive layout.
AppBar
Top app bar with caller-owned navigation, headings, actions, and optional search.
AppBarColors
Per-instance pigments. Missing fields use the window theme.
AppBarColumn
Vertical actions with responsive overflow.
AppBarItem
One action with an inline representation and an overflow menu representation.
AppBarMenuState
Handle to the active strip’s overflow menu, available to its item and trigger builders.
AppBarPadding
Logical insets within each app bar row.
AppBarRow
Horizontal actions with responsive overflow.
AppBarScrollState
Retained app bar presentation state. Use a distinct entity per app bar.
Badge
A standalone or anchored Material badge. For anchored badges, include the badge’s information in the host’s accessible name.
BottomSheetState
Retained position, available stops and transitions of a bottom sheet.
BottomSheetThresholds
Thresholds for settling a released sheet drag.
Button
A labeled Material action. Activation uses Base’s pointer, keyboard and accessibility behavior and invokes the application callback once.
ButtonBorder
A stroke for any button variant. A zero width removes its outline.
ButtonColors
Per-instance pigments. Each omitted field keeps the variant’s color in that state. Checked colors apply to enabled toggles.
ButtonElevations
Optional Material elevation levels. Disabled takes precedence, followed by pressed, keyboard focus, hover and rest.
ButtonPadding
Insets around the label or custom content, including leading and trailing icons.
ButtonShapes
Button corner overrides in logical top-start, top-end, bottom-end, bottom-start order. Unspecified states keep their size and shape presets.
Card
A static surface or a keyboard-operable action with independent child controls.
CardBorder
The card’s stroke. A zero-width border removes the stroke.
CardColors
Per-instance colors. Omitted fields keep their variant and window defaults.
CardElevations
Shadow levels. Each omitted field keeps the variant default for its state.
Checkbox
Controlled Material checkbox. Mixed activation requests Checked.
CheckboxColors
Per-instance checkbox colors. Disabled entries take precedence over error entries.
CheckboxStateColors
Optional pigments for one checkbox state. Unset fields use the window theme.
Chip
A Material chip. Filter and Input chips request controlled selection changes. Filter and Input chips can expose a separate removal action with its own focus.
ChipColors
Enabled, selected, and disabled chip pigments. Disabled-selected fields fall back to disabled overrides. Selection applies to Filter and Input chips.
ChipElevations
Optional shadows for each state. Disabled and dragged take precedence over press, keyboard focus, hover, and rest.
ChipStateColors
Per-slot pigments for one chip state. Omitted fields retain the defaults.
CircularProgress
Circular progress. Supply a fraction from 0 to 1, or omit it for indeterminate progress.
Dialog
A named Material modal with optional structured slots or caller-defined content.
DialogAction
Activation for a dialog slot, valid while that open dialog owns input.
DialogColors
Local overrides for a dialog surface and its content slots.
DialogProperties
User dismissal routes for a Material dialog.
DialogState
Retains a dialog’s visibility and focus scope across renders.
DisplayScrollbar
A read-only scroll position indicator. Mount it after the scroll viewport as a child of the same relative parent and give it a stable ID.
DisplayScrollbarFade
Shows the indicator after a scroll offset change, then fades it out.
DisplayScrollbarStyle
Display scrollbar colors and dimensions. Lengths are in logical pixels.
Divider
Decorative Material divider, with logical start and end insets.
DragHandleColors
Fill colors. Omitted values use the corresponding window theme role.
DragHandleShapes
Corner shapes in logical corner order. Omitted values use Material defaults.
DragHandleSizes
Visual sizes in logical pixels. Omitted values use Material defaults.
DropdownOption
A selectable dropdown value. IDs remain stable when options are reordered.
ExposedDropdown
A Material field and anchored list in editable and selection-only modes. Typing filters the list, while only selecting an option calls the owner.
ExposedDropdownState
Keeps the editable query and pending keyboard choice across renders.
ExtendedFab
An elevated action with a label or custom content and an optional icon. All presentations share one action, accessible name, and focus handle.
Fab
An elevated icon action with a required accessibility name. Mount it beside the scroll viewport to keep its position fixed while content scrolls.
FabVisibilityAnimation
Appearance and disappearance motion for a controlled FAB.
Feed
An ordered, vertically scrolling feed. Supply the same scroll handle when the number of columns changes. Cards are placed in reading order.
FloatingAction
Places a FAB inside the current window viewport at logical bottom-end. Mount this element beside the scroll owner so it stays visible while scrolling.
Icon
A decorative icon by default; .label exposes an independently meaningful image. Named symbols inherit text size and foreground, including disabled colors, from their control’s icon slot. Outside a slot, use .size(px(24.)) for a 24dp icon. Custom SVG paths use the application’s AssetSource. Mirroring is opt-in.
IconButton
An icon-only action with a required accessibility name.
IconToggleButton
An icon-only controlled toggle. The selected icon and native toggle state both reflect the caller’s value.
InteractionSource
Observes the presentation state of controls with a shared GPUI entity.
InteractionState
A snapshot of interaction state from the caller’s GPUI/Base behavior.
InteractionUpdate
One deferred change from an observed control.
Label
An overlay annotation for arbitrary anchor content and its own interaction source.
LinearProgress
Horizontal progress. Supply a fraction from 0 to 1, or omit it for indeterminate progress.
List
A list of identified rows. Applications can supply a visible window of rows from their own virtualized collection.
ListDetail
Shows a list or detail at compact and medium widths, and both at expanded widths. The owner retains pane entities and scroll handles, selects the narrow pane and supplies the back command.
ListItem
A Standard or Segmented list row. Values and data changes belong to the caller.
ListItemColors
Per-row palette. Omitted colors use the current window’s theme.
ListItemElevations
Per-state shadow levels. Rows default to Level0, or Level4 while dragged.
ListItemPadding
Logical padding in pixels. Using the builder replaces the adaptive defaults.
ListItemShapes
Logical shapes for one row. An omitted shape uses the resting or selected shape, including the list’s grouped corners.
ListItemStateColors
Independent colors inherited by the container and each slot in one state.
LoadingIndicator
Progress for an operation. Pass a value to select determinate mode, or omit the value for an indeterminate animation.
LoadingIndicatorShape
An endpoint shape for a loading indicator morph.
LoadingIndicatorShapes
A prepared sequence of rounded polygons for a loading indicator.
MaterialRoot
Initializes Material and Base before the application opens its first window.
MaterialTheme
Application-owned configuration consumed by the Material rendering layer.
Menu
Positions a Material menu against a caller-owned, keyboard-focusable trigger. Pointer and keyboard activation use the same Base popover focus lifecycle.
MenuItem
An item in a Material menu. Callers retain command and selection state.
MenuItemStyle
Per-row overrides. Unset shapes and colors follow the menu palette and layout.
MenuSurfaceStyle
Per-surface menu styling. Omitted values use defaults appropriate to the surface.
NavigationBar
Material Expressive short navigation bar.
NavigationBarColors
Short navigation bar pigments. Item overrides take precedence over content.
NavigationItem
One destination or tab with an ID unique within its collection.
NavigationItemColors
Optional pigments for an Expressive navigation destination.
NavigationItems
Controlled destinations. Use the same collection ID across adaptive presentations to preserve focus on the destination that currently owns it.
NavigationRail
Material wide navigation rail. The optional modal uses the side-sheet session.
NavigationRailColors
Independent local colors and scrim opacity.
NavigationRailPadding
Logical insets in pixels, also used inside a destination’s indicator.
NavigationRailShapes
Per-mode shape overrides. Omitted values use the default docked or sheet shape.
NavigationRailState
Retained presentation of a docked rail. Modal visibility uses DialogState.
PaneDestination
A history entry with an optional stable domain content key.
PaneLayoutDirective
Available partitions and preferred pane sizes in logical pixels.
PaneLayoutValue
Presentation of the three roles, independent of their navigation content keys.
PaneMargins
Pane margins in logical pixels.
PaneSeparator
An opt-in resize handle between two adjacent logical roles.
ProgressStop
Geometry and appearance passed to a linear determinate stop painter.
ProgressStroke
Per-stroke appearance. The default width is 4 dp and the color comes from the window palette’s active or track role.
PullToRefresh
A vertical viewport with an Expressive refresh indicator and accessible action.
PullToRefreshProgress
Readback supplied to a caller’s indicator.
PullToRefreshState
Retained gesture and indicator state. The application owns refreshing.
Radio
A radio option. A group owns the tab stop and the caller owns selection.
RadioColors
Radio indicator pigments. Omitted values use the current window theme.
RadioGroup
A controlled single-selection group with one Tab stop and directional navigation.
RailModalOptions
Window-local side-sheet policy for the optional modal rail.
Scaffold
Arranges the top app bar, leading rail, content and bottom bar. The floating action and snackbar are anchored within the content region above bottom navigation. Give the scaffold a bounded size and give its content a scroll viewport if needed.
ScaffoldContentLayout
Resolved body layout before the content builder applies its padding.
ScaffoldInsets
Logical edges in pixels. Start and end follow the window direction.
Scrim
A backdrop that fills its positioned parent. Add it after background content and before the foreground surface. The caller owns visibility and modal focus.
Sheet
A docked or modal Material sheet. Standard sheets take part in parent layout. The caller owns the bottom sheet’s expanded value and handles changes.
SheetClose
Activation for a close control supplied by the caller.
SheetColors
Optional local colors for the sheet and its adornments.
SheetMargins
Logical detached margins in pixels. The default is 16 px on each side.
Slider
An Expressive slider. Base owns the value and step grid. The caller retains the state entity and observes its SliderEvent notifications.
SliderColors
Optional slider colors. Unspecified fields use the window theme.
SliderMarker
The window position and default paint of a track tick or stop.
SliderState
State of the Slider.
SliderThumbStyle
Optional dimensions and colors for one handle.
SliderTrackStyle
Optional track dimensions in logical pixels.
Snackbar
A message for a window’s snackbar queue. The default timeout is four seconds.
SnackbarColors
Optional per-region colors. Omitted fields use the window’s inverse palette.
SnackbarHost
One FIFO message queue per host. Mount the entity in the window layout. A new message leaves keyboard focus wherever it is.
SnackbarId
An entry in one snackbar host’s queue.
SnackbarParts
Host-owned status and activation elements for a custom layout.
SupportingPane
A main workspace with an optional trailing support pane. In single-pane mode the caller can show the supporting pane as a full-width view.
Surface
A passive Material background or an interactive surface with arbitrary children.
SurfaceBorder
An outline in logical pixels, drawn around the surface’s shape.
SurfaceFeedback
Customizes the Material feedback painted by one interactive surface.
SwipeToDismiss
A foreground and background with logical horizontal swipe gestures. The caller owns the content, action commands, and resulting data changes.
SwipeToDismissState
Retained swipe state. Give each mounted swipe container its own entity.
Switch
Material switch. The caller owns the checked state and optional thumb content.
SwitchColors
Per-instance colors for enabled and disabled switches in either checked state.
SwitchStateColors
Optional pigments for one switch state. Omitted fields use the window theme.
TabIndicatorLayout
Geometry and tint supplied to a decorative custom indicator.
TabIndicatorStyle
Overrides for the indicator that tracks the selected tab.
Tabs
A fixed Material tab row by default. Enable scrolling for long tab lists.
TabsColors
Optional tab row pigments. Per-tab overrides take precedence over content.
Text
Single-line Material text. Measurement and painting share Foundation’s shaped glyphs, including font fallback and letter spacing.
TextField
A Material presentation for a caller-owned Base text editing entity.
TextFieldColorOverrides
Optional colors for a single text field state. An unset role uses the window theme.
TextFieldColors
Per-instance colors. Disabled takes precedence over invalid, then focused.
TextFieldLayout
Geometry reported after the retained Base editor lays out the field.
ToggleButton
A controlled labeled toggle. The caller re-renders with the selected value after accepting a requested change.
Tooltip
A transient plain or rich Material tooltip, or a persistent rich tooltip with caller-owned visibility.
TooltipCaret
Tooltip caret geometry. The default triangle is 16 px wide and 8 px deep.
TooltipColors
Window-theme color overrides for a tooltip’s individual slots.
TooltipPositioner
An unstyled element that positions its children as an anchored popup.
TooltipState
Visibility retained by the owner of a persistent rich tooltip.
VerticalDragHandle
A vertical Material handle for a horizontally adjustable boundary. The owner provides the layout and decides which requested widths to apply.

Enums§

AdaptiveNavigationType
Current Material 3 Expressive navigation presentations.
AdaptiveNavigationVisibility
AppBarAlignment
Logical alignment for a title or subtitle.
AppBarScrollBehavior
How changes in the linked content offset affect the app bar’s height.
AppBarVariant
BottomSheetValue
Settled values for a retained bottom sheet.
ButtonShape
ButtonVariant
CardVariant
CheckboxState
The semantic value exposed by an unstyled Checkbox.
ChipVariant
ControlSize
Material Expressive sizes, from extra small to extra large.
DialogCloseReason
An accepted transition from an open to a closed Material dialog.
DialogVariant
Window-relative presentation for a Material dialog.
DropdownAnchor
Focus and activation behavior for the primary dropdown anchor.
FabAlignment
Logical pivot for the FAB’s visibility transition.
FabColor
FabSize
Expressive FAB sizes. Small is the 56 dp FAB and Small Extended FAB.
IconButtonVariant
IconButtonWidth
IconName
Bundled official Material Symbols Outlined, weight 400, grade 0, optical size 24. Both fill variants are embedded unchanged, without an application AssetSource.
ListDetailPane
ListItemAlignment
Alignment of the slots within one row.
ListVariant
MenuColor
Semantic color presets for Material vertical menus.
NavigationBarArrangement
Distribution of the navigation items along the width of the bar.
NavigationBarLayout
NavigationItemIconPosition
Placement of a navigation item’s icon relative to its label.
NavigationRailArrangement
Distribution of standard destinations along the vertical axis.
PaneAdaptStrategy
The strategy used when resolving a pane from navigation and the directive.
PaneBackBehavior
How many destinations a back operation can skip.
PaneExpansionAnchor
Anchors relative to the logical extent of one horizontal band excluding its gutters.
PaneOverlayAlignment
Logical alignment of a levitated pane in its horizontal band and available height.
PanePlacement
A pane’s realized presentation.
PaneRole
Roles in a Material three-pane scaffold.
ProgressCap
Shape at the ends of a progress stroke.
ProgressShape
Straight or Expressive wavy active progress indicator.
RailMode
RangeThumb
Identifies the Base slider value represented by a semantic node.
ScaffoldFabPosition
Positions a scaffold’s floating action within the usable content width.
SheetEdge
SheetMode
SheetPlacement
Placement of a side sheet relative to its window edge or layout slot.
SliderEvent
Events emitted by the SliderState.
SliderKind
SliderScale
The scale mode of the slider.
SliderValue
The value of the slider, can be a single value or a range of values.
SnackbarResult
How a current snackbar left its host’s queue.
SwipeToDismissValue
The resting anchor or a logical dismissal direction.
TabIndicatorWidth
Width of the indicator relative to the selected tab.
TabVariant
TextFieldEvent
An event emitted by an input.
TextFieldLabelAlignment
Horizontal label alignment. Start and End follow the Material theme direction.
TextFieldLabelPosition
Position of the visual label. Filled uses Inside and Outlined uses Cutout by default.
TextFieldVariant
Material text field container treatment. The default is Filled.
ToggleButtonVariant
TooltipPlacement
Preferred tooltip side. Start and End resolve against the window’s direction.

Traits§

ScrollbarHandle
A trait for scroll handles that can get and set offset.

Functions§

init_components
Installs component keybindings after initializing the Material root.
material_theme
Returns the shared Material theme installed by MaterialRoot::init.
set_material_theme
Commits the application theme and projects semantic defaults into Base before refreshing windows. A window or subtree can pass an explicit theme to its elements.

Type Aliases§

TextAreaState
State for editing ordinary multi-line text.
TextFieldState
State for a single-line text input.