GPUI MaterialClose

Components

English | 中文

These components and layouts are available from gpui_material. Enable the named features to use the optional component families. See the integration guide for setup and platform support, or run cargo gallery to try interactive examples.

The pinned Material 3 specification governs component design. The links below point to the corresponding official guidance, and the site snapshot index records the pinned data version.

Actions and selection

Component Supported variants and behavior Material 3
Button, ToggleButton Elevated, Filled, Filled Tonal, and Outlined. Both provide variant shorthands (filled, tonal, elevated, outlined, plus text on Button) and a controlled .loading(bool) busy state. Both support XS–XL sizes, round or square shapes, SemanticTone (aliased as ButtonTone) semantic shortcuts (Default, Danger, Success, Warning, Info), custom content and appearance, and optional interaction observation. Buttons
IconButton, IconToggleButton Standard, Filled, Filled Tonal, and Outlined. Both provide variant shorthands (standard, filled, tonal, outlined) and a controlled .loading(bool) busy state, selectable sizes and widths, SemanticTone (ButtonTone) semantic shortcuts, per-instance shapes, colors and stroke, and optional interaction observation. Icon buttons
Fab, ExtendedFab Small, Medium, and Large sizes with per-instance appearance and controlled visibility. ExtendedFab supports a text label, an optional icon, and custom content. FAB · Extended FAB
Checkbox Unchecked, checked, mixed, error, and disabled states, with per-instance colors, strokes, and interaction observation. Checkbox
Radio, RadioGroup Mutually exclusive selection, group keyboard navigation, per-option colors, and optional interaction observation. Radio button
Switch On and off states with optional thumb icons or custom content, per-state colors, and shared interaction observation. Switch
Chip, ChipGroup Assist, Filter, Input, and Suggestion chips with content slots, custom appearance, and independent selection and removal, plus controlled ChipGroup collections with Single, SingleRequired, and Multiple selection, wrapping or horizontal scroll layout, and roving keyboard focus. Chips
Slider Single-value, centered, and range sliders with custom tracks, handles, and indicators. Supports horizontal and reversible vertical layout, with continuous or stepped values. Sliders

Use .content(element) to customize the rendered label while retaining the constructor’s accessible name and any leading or trailing icon slots. Keep the content free of independent controls so the button owns activation and focus. Use Button::filled, Button::tonal, Button::elevated, Button::outlined, or Button::text (and ToggleButton::filled, ToggleButton::tonal, ToggleButton::elevated, or ToggleButton::outlined) as variant shorthands for .variant(...). Set .loading(true) on Button, ToggleButton, IconButton, or IconToggleButton to enter a controlled busy state: pointer, keyboard, and accessibility activation are suppressed, busy semantics are exposed, the active palette is preserved unless .disabled(true) is also set, the resting button width is preserved to prevent layout jitter, and a compact inline Material circular spinner is centered in the control while respecting window/viewport visibility and reduced motion (static arc fallback). Set .tone(SemanticTone) (also aliased as ButtonTone) to apply Material 3 semantic palettes (Default, Danger, Success, Warning, Info) across all variants and toggled states. Set .shapes(ButtonShapes), .colors(ButtonColors), .border(ButtonBorder), .content_padding(ButtonPadding), and .elevations(ButtonElevations) per instance; explicit .colors and .border overrides always take precedence over tone defaults. Unspecified shape, color, and elevation fields keep the size, variant, and tone defaults for that state. ButtonPadding follows the window’s text direction. A zero-width border removes the default outline.

Pass an accessible name and decorative icon element to IconButton::new(id, name, icon) (or the variant shorthands IconButton::standard, IconButton::filled, IconButton::tonal, IconButton::outlined) or IconToggleButton::new(id, name, icon, selected) (or IconToggleButton::standard, IconToggleButton::filled, IconToggleButton::tonal, IconToggleButton::outlined). Icon buttons default to the Small size, Uniform width, Round shape, and Standard palette. Use .shapes(ButtonShapes) for resting and pressed corners and for checked corners on toggles. .colors(ButtonColors) supplies container and icon colors for enabled, disabled, and checked states. Omitted fields use the current size and variant defaults. .border(ButtonBorder) replaces the default stroke. Use zero width to remove it. IconToggleButton renders the caller’s selected value and uses .selected_icon(element) when selected, if supplied.

Keep an Entity<InteractionSource> in the caller and attach it with .interaction_source(&source) to observe a button or icon button. Give each control sharing a source a distinct element ID within its window. Read the current state with InteractionSource::state, or subscribe to InteractionUpdate for each deferred change, including press and release between draws. A removed control clears its snapshot. Base still owns input handling and the application owns toggle values.

Floating action button

Fab::new takes an icon and an accessible name. It defaults to a 56 dp Small FAB in the primary container palette. Give each Small, Medium, or Large instance its own .shape(CornerShape), .colors(ButtonColors), and .elevations(ButtonElevations). Use the container and content fields for enabled and disabled colors. Omitted fields keep the size and palette defaults. Use .interaction_source(&source) to observe the action with a caller-owned source.

Keep the visibility flag in application state and pass it with .visible(visible) on each render. Use a stable element ID between updates so the two motion channels can reverse from their current progress. FabVisibilityAnimation defaults to center alignment, a hidden scale of 0.2, and the theme’s Fast Spatial and Fast Effects motion for scale and alpha. Use logical FabAlignment positions to scale about an edge or corner that mirrors in right-to-left windows. Set target_scale to a finite nonnegative value and set scale_motion and alpha_motion independently. Invalid scales, including values that overflow the scaled extent, fall back to 0.2. Reduced motion applies the final state immediately.

A hiding FAB stops taking focus and input immediately. It occupies its layout space while fading and gives up that space at zero opacity. An initially hidden FAB takes no space. Keep the icon decorative so the FAB owns activation and focus. Use inherited text sizing or relative dimensions for custom icons that should resize during the transition.

Extended floating action button

Use ExtendedFab::new(id, label, icon) for an icon and label or ExtendedFab::text(id, label) for a text-only action. .content(element) replaces the rendered label and retains the constructor’s accessible name and optional icon. Keep the icon and custom content decorative so the action owns activation and focus. Long built-in labels are constrained by the available width and ellipsize once fully expanded. Custom content receives the available label space and is clipped to it.

Small, Medium, and Large default to heights of 56, 80, and 96 dp respectively. Use .expanded(expanded) to render the caller’s expansion state. Icon-bearing actions animate to a square with only the icon when collapsed. Iconless actions keep their text or custom content in either state. Both presentations use one action and focus handle. The leading icon mirrors in right-to-left windows. Reduced motion applies the requested presentation immediately.

The same .shape, .colors, .elevations, .interaction_source, .visible, and .visibility_animation builders are available as on Fab. Expansion and visibility can change independently when rendered with a stable ID. The full-size layout footprint stays in place during visibility scaling, then is removed at zero opacity. The action leaves focus navigation and accessibility as soon as hiding begins. The built-in label and icon slot scale with the button. Custom label content is laid out within the scaled slot, which clips any fixed-size content that extends beyond it.

Checkbox

Checkbox::new(id, label, state) renders the caller’s state. Pointer, keyboard, and accessibility activation request the next value through .on_change. Activating a mixed checkbox requests Checked. Apply the request in the owner and pass the current state on the next render. .error(true) exposes the validation state and uses Error and OnError by default. Disabled appearance takes precedence over error appearance.

Use .colors(CheckboxColors) to set CheckboxStateColors for each unchecked, checked, or indeterminate state, including error and disabled states. Each state can override its checkmark, box_color, and border independently. Omitted fields keep the window theme’s defaults. In the unchecked state, checkmark color applies while the mark retracts.

Set .checkmark_stroke(gpui::StrokeOptions) for the uniform checkmark and mixed mark stroke, including width, caps, and joins. Use .outline_stroke(width) for the rounded box outline in logical pixels. Both widths default to two logical pixels. A zero width removes that stroke. Negative or non-finite widths use the default, and large widths are bounded by the indicator size. Set .show_label(false) to omit the visible label and trailing gap while keeping the constructor’s label as the accessible name, or pass .label_content(element) to replace the visible label while keeping the accessible name. Use a caller-owned Entity<InteractionSource> with .interaction_source(&source) to observe hover, press, keyboard focus, and disabled state. The source can be shared with other controls using distinct IDs and leaves the value with the caller. Pass .track_focus(&focus) to attach a caller-owned FocusHandle.

Radio buttons

Use Radio::colors(RadioColors) to override the indicator’s selected, unselected, disabled-selected, and disabled-unselected colors independently. Unspecified fields use the current window palette. Selected defaults to Primary, unselected defaults to On Surface Variant, and both disabled defaults use On Surface at 38% opacity.

Pass .show_label(false) to omit the visible label and trailing gap while retaining the accessible name, or .label_content(element) to customize the visible label. Pass .interaction_source(&source) to observe a standalone radio or individual options in a RadioGroup. Grouped snapshots use the rendered ID ElementId::from((group_id, option_id.to_string())), so groups can share one Entity<InteractionSource>. Removing an option or replacing its source clears its snapshot in the old source. The caller owns selection and applies .on_select(...) requests. A group has one Tab stop, skips disabled options, and mirrors horizontal navigation in RTL. Use .track_focus(&focus) on a standalone Radio or on individual Radio options inside a RadioGroup to attach a caller-owned FocusHandle; RadioGroup preserves and uses caller-supplied focus handles for roving navigation.

Switches

Pass the application’s current value to Switch::new(id, label, checked) and handle the requested next value with .on_change(...). Pointer, keyboard, and accessible activation request the same change. .disabled(true) prevents user changes. The constructor’s label provides the visible label and accessible name; use .show_label(false) to omit the visible label and trailing gap while retaining the accessible name, or .label_content(element) to replace the visible label.

Use .checked_icon and .unchecked_icon for optional icons, or pass a decorative GPUI element through .thumb_content(element). The custom element takes precedence for that render. Choose it from the caller’s checked value to show different elements in each state. Custom content sits in a centered 16 px slot and inherits the state’s content color. Keep labels and independent controls outside the thumb.

Use .colors(SwitchColors) to configure each SwitchStateColors palette for checked, unchecked, disabled checked and disabled unchecked states. Each palette can override track, border, thumb and content independently. Omitted fields retain the theme defaults. Attach a caller-owned Entity<InteractionSource> with .interaction_source(&source) to observe hover, focus, press and disabled changes while the application continues to own the checked value. Pass .track_focus(&focus) to attach a caller-owned FocusHandle.

Chips

Chip::new(id, label) (or the variant shorthands Chip::assist, Chip::filter, Chip::input, and Chip::suggestion) uses the label as its accessible name. Use .content(element) to replace the displayed label in any variant and .leading_icon(element) for a leading icon. Input chips accept .avatar(element), a 24 dp circular slot that takes precedence over the leading icon. .trailing(element) adds visual content to an Assist, Filter, or Input chip. When a Filter or Input chip has .on_remove(...), that content becomes the removal button’s visual label and the removal action keeps its separate accessible name and focus stop. Without custom trailing content, removal uses the Close icon. Keep all visual slot content free of independent controls.

Filter and Input render the owner’s .selected(value) and request changes through .on_change. Assist and Suggestion use .on_activate. Removal invokes only the removal callback. When an enabled Filter or Input chip has .on_remove(...), pressing Backspace or Delete (with no modifiers) while the main chip action has focus also invokes the removal callback and stops propagation. .disabled(true) disables both actions. Leading and trailing content and removal position mirror in RTL. Keyboard traversal reaches the main action before removal.

.tonal(true) selects the expressive Tonal defaults for Filter, elevated Filter, and Input. These presets use Medium resting, Full selected, and Small pressed corners and the theme’s OnSurfaceVariant for the unselected leading icon. The normal constructor retains the current flat Assist and Small corners. Set .tone(SemanticTone) to apply Material 3 semantic container, label, icon, and border colors for enabled and selected states while preserving disabled styling and explicit .colors(ChipColors) / .border(ButtonBorder) precedence. Use .shapes(ButtonShapes) to set corners by state. Set .colors(ChipColors) with a ChipStateColors entry for enabled, selected, disabled, or disabled-selected appearance. Each entry can set the container, label, leading, trailing, and border colors. Missing fields use the chosen variant’s defaults, with disabled-selected fields falling back to disabled overrides.

Use .border(ButtonBorder) to change the outline width and its fallback color. A zero width hides the outline. .elevations(ChipElevations) overrides rest, press, focus, hover, drag, and disabled shadow levels. .dragged(bool) reflects an application-owned drag and cancels the pending pointer activation; the application owns the gesture. .spacing(width) sets the horizontal gap between content slots, and .content_padding(ButtonPadding) sets logical inner edges. The default gap is 8 dp, label-only edges are 16 dp, icon edges are 8 dp, and the avatar starts at 4 dp.

Give each chip a distinct ID and use a caller-owned Entity<InteractionSource> with .interaction_source(&source) to observe the main action by that ID. The source reports hover, press, keyboard focus, dragged, and disabled feedback; selection and removal remain controlled by the caller. Use .track_focus(&focus) to attach a caller-owned FocusHandle to the main action, such as a restoration target for an adjacent chip’s .on_remove(...).

Use ChipGroup::new(id, name, items) with ChipGroupItem entries for a controlled chip collection (Role::ListBox) with Material 3 8 dp spacing, RTL mirroring, and a single roving Tab stop (Left/Right/Home/End, skipping disabled chips). Configure .selection(ChipGroupSelection, selected) (Single, SingleRequired, or default Multiple) with .on_change(|ids, window, cx| ...), or use .single_select(selected, |id, window, cx| ...) as a SingleRequired shorthand. Choose .variant(ChipVariant) (default Filter; supports Input too), group-level defaults .tonal(bool) and .elevated(bool) (applied to items unless overridden per item), .disabled(bool) (disables all items when true, OR-ed with per-item disabled state), .scrollable(true) (with optional .scroll_handle(&handle)) for a single horizontal scrolling row instead of wrapping, and .spacing(px) / .row_spacing(px) for custom gaps. Each ChipGroupItem supports .leading_icon, .avatar, .trailing, .disabled, .tonal, .elevated, .tone, and .on_remove(label, handler).

Sliders

Retain the SliderState entity in the owner. Base manages the range and step grid. SliderEvent::Change reports value edits, and SliderEvent::Release reports the end of a pointer gesture and follows Change when a keyboard or accessibility adjustment changes the value. An adjustment that leaves the value unchanged emits neither event. Use Slider::range with a range value and two accessible names. .kind(SliderKind::Centered) fills from the midpoint for single values. .axis(Axis::Vertical) runs from bottom to top by default. Set .reverse_vertical(true) for top-to-bottom layout, pointer movement, and Up and Down keys. Horizontal layout and keys follow the window direction. Home and End jump a focused handle to its numeric minimum or maximum, and PageUp and PageDown adjust by a larger step (10% of the range or at least one accessibility step). Accessibility values and bounds use the numeric order in either orientation.

.track_style(SliderTrackStyle) sets thickness, outer_radius, inner_radius, and thumb_gap in logical pixels. Omitted fields use the size’s default thickness and outer radius, a 2 dp inner radius, and a 6 dp gap from each handle edge. Use .thumb_style(RangeThumb, SliderThumbStyle) for each handle’s size, pressed_width, color, disabled_color, and focused_color. Size uses the first dimension along the value axis and the second across it. The default handle is 4 dp along the axis, narrows to 2 dp when dragged, and uses the chosen size’s cross-axis extent. Non-finite dimensions and nonpositive sizes use the defaults. Zero is valid for radii and gaps. Use RangeThumb::End for a single-value slider.

.colors(SliderColors) supplies enabled and disabled colors for the thumb, active and inactive track, and active and inactive ticks. Unspecified fields use the window palette. The enabled thumb and active track use Primary, the inactive track Secondary Container, and the ticks On Primary and On Secondary Container, respectively. Disabled defaults use On Surface at 38% for the thumb, active track and ticks, and 12% for the inactive track. Per-thumb colors take precedence over slider colors. Default keyboard-focus color is Secondary. Use .thumb(RangeThumb, element) and .track(element) for decorative content in place of the default handle and track. Keep independent controls out of these slots so the slider owns input, focus, and accessibility. When supplying a custom track, draw its own inset icon, ticks, and stops if needed.

.tick_intervals(count) controls visual intervals independently of Base’s steps. .draw_ticks(...) and .draw_stop_indicators(...) receive each SliderMarker with its window position and default color and diameter, where the default diameter is 4 dp. .show_stop_indicators(false) hides stops. The value indicator defaults to visible for the dragged or keyboard-focused handle and displays two decimal places. Use .value_indicator(false) to turn it off and .format_value(...) to format a live value for display.

.interaction_source(RangeThumb, &source) observes each handle independently. The keys are ElementId::from((slider_id, "start")) and ElementId::from((slider_id, "end")). One source can observe both keys, or each handle can use its own source. Removing a handle or replacing its source clears the previous snapshot. Pass .track_focus(RangeThumb, &focus) to attach a caller-owned FocusHandle to either handle (use RangeThumb::End for a single-value slider).

Content and feedback

Component Supported variants and behavior Material 3
Text, Icon Themed typography with all 15 Material type-role shorthands (display_large–label_small), .muted(), .align(TextAlign), .max_lines(usize), and .color_override(Hsla); replaceable icons with .inherit_color(), .color_override(Hsla), and bundled Material Symbols. Typography · Icons
Surface Passive, clickable, selectable, and checked surfaces with theme content colors and elevation. Elevation
Card Elevated, Filled, and Outlined, with static and actionable forms and per-instance appearance. Cards
List, ListItem, ListSection, SwitchTile, CheckboxTile, RadioTile, SliderTile, ChoiceTile Standard and Segmented lists and titled sections with custom slots, controlled row actions, per-state appearance, and settings convenience tiles for switches, checkboxes, radios, sliders, and anchored option menus. Lists
DropTarget Material drag-and-drop container supporting external OS file drops (ExternalPaths) and typed in-app payloads, with validation feedback and optional click/keyboard activation. Drag and drop
SwipeToDismiss Horizontal swipes with caller-owned content, background, and action. Lists · Compose SwipeToDismissBox
Divider, Badge, Avatar, AvatarGroup Horizontal and vertical dividers with logical insets, configurable thickness, and per-divider color. Standalone and anchored badges with dot, text, count, or custom content and optional colors. Circular or rounded avatars for initials, icons, images with fallback, or custom content, plus overlapping AvatarGroup stacks with cutout rings and +N overflow counters. Divider · Badges
EmptyState Purely presentational Material 3 Expressive empty-state layout with an optional decorative icon or custom visual backdrop (MaterialShape or CornerShape), title, supporting text/content, and centered action slots. Empty states
Skeleton M3 SurfaceContainerHigh/SurfaceContainerHighest pulse loading placeholders (rect, text_line, circle, and shape) with zero offscreen animation frames and static reduced-motion fallback. Loading & progress
DisplayScrollbar Paints scroll position for either axis from the viewport state, with configurable dimensions, colors, and fading. Compose non-interactive scrollbar
LinearProgress, CircularProgress Determinate and indeterminate progress with configurable straight and wavy styles. Progress indicators
LoadingIndicator Default and Contained, with determinate and indeterminate modes, custom morph sequences and instance colors. Loading indicator
PullToRefresh Controlled refresh with gesture and accessible action, configurable indicator and retained scroll handoff. Loading indicator
Banner In-flow Material 3 banner/callout surface with SemanticTone palettes, optional icon, title, message, 1–2 tone-matched actions or custom actions content, optional dismiss button, RTL mirroring, and Role::Status/Role::Alert semantics. Banners
Snackbar, SnackbarHost Queued timed or persistent messages with custom content and layout, optional actions and dismissal, and a completion result. Snackbars

Surfaces

Surface::new(role) supplies a passive background. For custom controls, use Surface::clickable(id, label, role) or Surface::selectable(id, label, role, selected) with .on_activate(...). Use Surface::toggleable(id, label, role, checked) with .on_checked_change(...). The label names the interactive surface, and the owner supplies the current selected or checked value on each render. Pointer, Enter, Space, and accessibility actions call the same handler. .disabled(true) turns off activation and skips the surface in Tab navigation. Give each surface a stable ID and keep independent actions on their own surfaces. Group related selectable surfaces in a named gpui::Role::ListBox.

Surface uses the theme foreground paired with its background role. Roles without a matching foreground and colors set by .container_color(color) inherit the current foreground. Use .inherit_content_color(true) to inherit across a paired role or .content_color(color) to override it. The resulting color flows to descendants through GPUI text style, including Material text and icons without their own color.

Use .shape(CornerShape) for logical corners, or .polygon_shape(...) with any MaterialShape, PolygonRole, custom ShapePolygon, or sampled ShapeMorph outline. .shape_fit(ShapeFit) chooses aspect-preserving Contain (default for polygons) or Stretch. Use .border(SurfaceBorder { width, color }) for a stroke in logical pixels. These settings apply to the background, outline and feedback. Other GPUI Styled layout and paint settings remain available. GPUI clips overflowing children with a rectangular content mask; pass .shape_clip_backdrop(color) on uniform backgrounds to paint an EvenOdd exterior mask that visually clips overflowing children to the shape outline. .tonal_elevation(Elevation) tints a theme Surface background, and .shadow_elevation(Elevation) sets the shadow independently.

Interactive surfaces use the Material state layer, bounded ripple and keyboard focus ring. .feedback(SurfaceFeedback) configures those effects and their colors for a single surface. Polygon surfaces enable shape-aware pointer hit testing by default so pointer hover, press, and click ignore points outside the shape contour; use .shape_hit_test(bool) to configure this behavior for any surface. Keyboard and accessibility activation stay available. Attach .interaction_source(&source) to observe hover, press, keyboard focus and disabled state. .track_focus(&focus) uses a caller-owned focus handle. Reduced motion uses static press feedback.

Cards

Use Card::new(id).variant(CardVariant::Elevated), Filled, or Outlined (or the variant shorthands Card::elevated(id), Card::filled(id), and Card::outlined(id)) for the current Material variants. Static cards group their content (Role::Group) without taking keyboard focus and accept .accessible_label(label) to name the group. .on_activate(name, callback) gives the card a named action and keyboard focus. Child controls keep their own actions. .disabled(true) disables the card action and supplies disabled colors to the card and its inherited content.

Set .shape(CornerShape) for the container, border, shadow, and feedback; child content is clipped to the card’s rounded corners and follows the window’s writing direction. Use .content_padding(Edges<Pixels>) (default 16 dp) and .gap(Pixels) (default 8 dp) to adjust inner spacing. Use .border(CardBorder { width, color }) for a custom stroke. A width of zero removes the stroke. .colors(CardColors) independently overrides enabled and disabled container and content colors. .elevations(CardElevations) independently overrides resting, pressed, focused, hovered, dragged, and disabled shadow levels. Omitted fields keep the variant defaults, including Medium corners, an outline on Outlined cards, and flat Outlined cards on hover. Disabled elevation takes priority, followed by drag, press, keyboard focus, hover, and rest.

Set .dragged(bool) from the caller’s drag lifecycle, including completion and cancellation. A drag interrupts a pending pointer activation. Pass .interaction_source(&source) to observe the card through a shared Entity<InteractionSource>. Give each observed card a distinct ID within its window. Use .track_focus(&focus) to attach a caller-owned FocusHandle to an actionable card.

Lists

Use List::new(id).item(row) or .items(rows) for Standard rows or .variant(ListVariant::Segmented) for grouped corners and a 2-pixel gap, with optional .accessible_label(label) on the Role::List container. Give each ListItem::new(id, label) a stable ID and an accessible name. .content(element), .overline_content(element), and .supporting_content(element) supply arbitrary elements. The label still names the row’s action. The text helpers .overline(text) and .supporting_text(text) apply Material typography, and supporting text wraps. .leading(element) and .trailing(element) follow the window’s writing direction. Embedded controls keep their own focus and activation.

Use .on_activate(...) for an action. .selected(bool) controls selection styling and semantics. .checked(bool).on_checked_change(...) supplies an independent checkbox value and receives a request for its opposite. Checked rows expose a checkbox role. .expanded_content(expanded, element).on_expanded_change(...) exposes a disclosure state and requests a change through row activation. Expanded content appears below the row and can contain independently operable controls. The application applies each requested value. The list’s roving tab stop moves through enabled row actions with Up and Down. .track_focus(&focus, tab_stop) lets a virtual collection or caller supply its own FocusHandle, which is preserved by List and ListSection.

Use .on_long_press(label, callback) to run a named secondary action on primary-pointer hold, desktop secondary click (MouseButton::Right), Shift+F10, the contextmenu key, or the accessibility context action where supported. Hold the row’s central content on a pointer device. The gesture cancels when released early, dragged, or interrupted. .long_press_button(id) adds a visible button at the logical end with the same accessible name and command, including on platforms without the secondary context action. A completed hold consumes the corresponding row click.

Use .swipe_to_dismiss(&state, |swipe| ...) to wrap a row in the existing SwipeToDismiss using its retained state and configuration methods. The application owns dismissal and supplies a named keyboard-accessible command as described below. Vertical scrolling remains available. Settled dismissed rows leave traversal until reset or removal.

.shapes(ListItemShapes) overrides logical resting, selected, pressed, focused, hovered, and dragged corners. .tone(SemanticTone) tints the enabled and selected label, leading, and trailing roles with a Material 3 semantic palette while preserving disabled styling and explicit .colors(ListItemColors) precedence. .colors(ListItemColors) configures container, content, leading, trailing, overline, and supporting colors for each normal, disabled, selected, and dragged state through ListItemStateColors. Omitted fields keep the window defaults. .vertical_alignment(ListItemAlignment) chooses Auto, Start, Center, or End. Auto centers short rows and aligns taller text rows to the top. .content_padding(ListItemPadding) sets logical start, end, top, and bottom in pixels. The default is 16 horizontally and 10 vertically, or 12 vertically for three-line rows. .elevations(ListItemElevations) overrides resting and interaction shadow levels. .dragged(bool) reports a caller-owned drag and .interaction_source(&source) observes the row’s hover, press, keyboard focus, drag, and disabled state.

Settings tiles and list sections

SwitchTile::new(id, label, checked) wraps a ListItem with a synchronized visual trailing Switch (available when both surfaces and selection features are enabled). Clicking anywhere on the row or pressing Enter or Space toggles through .on_change(...) with a single focus stop and Role::Switch semantics, avoiding duplicate focus or double toggles. Use .supporting, .overline, .leading, .disabled, .variant(ListVariant), .colors(ListItemColors), .switch_colors(SwitchColors), .track_focus(&focus), and .interaction_source(&source) to customize the row and indicator independently.

CheckboxTile::new(id, label, state) (or CheckboxTile::bool(id, label, checked)) wraps a ListItem with a synchronized decorative Checkbox (available with surfaces + selection). Clicking anywhere on the row or pressing Enter or Space requests the next CheckboxState (Unchecked or Indeterminate → Checked; Checked → Unchecked) through .on_change(...) with a single focus stop and Role::CheckBox semantics. Configure .supporting, .overline, .leading, .trailing(element) (displayed when .trailing_checkbox(false) places the checkbox in the leading slot), .trailing_checkbox(bool) (defaults to trailing), .error(bool), .disabled(bool), .variant(ListVariant), .colors(ListItemColors), .checkbox_colors(CheckboxColors), .track_focus(&focus), and .interaction_source(&source).

RadioTile::new(id, label, selected) wraps a ListItem with a synchronized decorative Radio (available with surfaces + selection). Clicking anywhere on an unselected row or pressing Enter or Space invokes .on_select(...) with a single focus stop and Role::RadioButton semantics. Configure .supporting, .overline, .leading, .trailing(element) (displayed when .trailing_radio(false) places the radio in the leading slot), .trailing_radio(bool), .disabled(bool), .variant(ListVariant), .colors(ListItemColors), .radio_colors(RadioColors), .track_focus(&focus), and .interaction_source(&source).

SliderTile::new(id, label, &state) combines a ListItem header (optional .overline, .leading, .supporting, and live formatted value on the trailing side via .format_value(...)) with an embedded Slider bound to the caller’s retained Entity<SliderState> (available with surfaces + selection). Use .disabled(bool), .variant(ListVariant), .colors(ListItemColors), .track_focus(&focus), .interaction_source(&source), and .slider(|slider| ...) to customize the embedded slider without duplicating individual slider builders.

ChoiceTile::new(id, label, options, selected) wraps a ListItem with an anchored Material Menu of ChoiceOption items (available when both surfaces and feedback features are enabled). It shows the currently selected option’s label (or .placeholder(...)) beside a dropdown chevron, exposes that value to assistive technology via the row’s accessible description, marks the active choice in the menu, reports selections through .on_select(...), and restores focus on close. Provide an optional .menu_state(&state) (Entity<DialogState>) for external control, or let the tile retain its own keyed DialogState, and attach .track_focus(&focus) or .interaction_source(&source) as needed.

ListSection::new(id) (or ListSection::segmented(id), available with surfaces) groups any mix of ListItem, SwitchTile, CheckboxTile, RadioTile, SliderTile, and ChoiceTile via .item(...) / .items(...) (ListSectionItem) under an optional .title(...) heading (LabelMedium with logical horizontal inset). In ListVariant::Segmented, it applies Material 3 Expressive grouped corner geometry ([16, 16, 4, 4] first, [4, 4, 4, 4] middle, [4, 4, 16, 16] last, [16, 16, 16, 16] single, 2 dp gap) and wires unified vertical roving focus (Up/Down/Home/End, skipping disabled rows, while preserving caller-supplied .track_focus(...) handles) across interactive rows while leaving SliderTile’s embedded slider keyboard controls intact.

Drop target

DropTarget::files(id) accepts external OS file drops (gpui::ExternalPaths) and DropTarget::new::<T>(id) accepts any typed in-app GPUI drag payload T: 'static. Use .title, .supporting, and .icon for a default placeholder drop zone, or .content(element) to wrap custom content. .can_drop(|payload, window, cx| ...) validates payloads during drag-over and drop; accepted payloads highlight with the primary active palette while rejected payloads display error feedback and skip .on_drop(...). Set .on_activate(...) to support click and keyboard activation (preserving a disabled Role::Button when .disabled(true) is also set), .shape(CornerShape) for corners resolved dynamically from laid-out bounds, .colors(DropTargetColors) for idle/active/invalid palettes, .disabled(true) to suppress drop registration and activation, .track_focus(&focus) and .interaction_source(&source) for focus and state observation, and .accessible_label(...) for assistive technology.

Divider

Divider::horizontal() and Divider::vertical() default to one logical pixel in the window theme’s OutlineVariant color. Use .thickness(px(2.)) to set a different logical width or .thickness(px(0.)) for a one-device-pixel hairline. Invalid thickness values fall back to the default. A vertical divider fills the available height of its parent.

Use .color(ColorRole::Primary) to resolve a role against the window theme or .color_override(hsla) to use a literal color. The last color setter takes precedence. .inset(start, end) follows the window’s text direction for horizontal dividers and applies to the top and bottom for vertical dividers. The divider is decorative and adds no focus stop.

Badges

Badge::dot(host), Badge::label(host, text), and Badge::count(host, count, maximum) anchor a mark to the host’s upper trailing edge. Pass the current count and cap when rendering. Counts above the cap display the cap followed by +. Badge::standalone(), Badge::standalone_label(text), and Badge::standalone_count(count, maximum) render standalone dot, text, or capped count marks in the surrounding layout. Use .visible(false) to hide a badge (rendering only the host for anchored badges or nothing for standalone badges), .offset(Point<Pixels>) to nudge anchored placement, and .content(id, element) to supply a short visual element for either placement. Give each custom mark a stable ID within its parent. Any IntoElement can also attach badges in postfix style via MaterialElementExt (.badge_dot(), .badge_label(text), .badge_count(count, maximum)).

Container and content colors default to the window theme’s Error and OnError roles. Use .tone(SemanticTone) for Material semantic status palettes (Default/Danger use Error/OnError; Success, Warning, and Info use their corresponding role pairs) or .color_role(container, content) to pick explicit theme roles. Explicit .container_color(color) and .content_color(color) overrides take precedence over .color_role(...), which takes precedence over .tone(...). Keep custom content noninteractive and let the host’s accessible name describe the anchored badge. For a standalone indicator that conveys information on its own, use .accessible_label(id, label) to give it a name without adding a focus stop.

Avatars

Avatar::initials(text), Avatar::icon(icon), Avatar::image(source), and Avatar::custom(content) display user or entity identity badges in ExtraSmall (24 px), Small (32 px), Medium (40 px, default), Large (48 px), ExtraLarge (64 px), or Custom(Pixels) sizes via .size(AvatarSize). Initials automatically trim, uppercase, and scale Material typography with the avatar size. Images render with ObjectFit::Cover clipped to AvatarShape::Circle (default) or AvatarShape::Rounded(CornerShape) and show optional .fallback(element) content while loading or on load failure. Configure .color_role(container, content) (defaults to PrimaryContainer / OnPrimaryContainer), .colors(AvatarColors), .border(width), and .accessible_label(id, label) for Role::Image semantics without adding a focus stop.

Use AvatarGroup::new(id, avatars) to render an overlapping horizontal stack of Avatar items. .size(AvatarSize) applies a uniform diameter across members and the overflow indicator (defaults to Medium). .max_visible(count) truncates longer lists and appends a +N overflow avatar using SurfaceContainerHighest and OnSurfaceVariant, customizable with .overflow_colors(AvatarColors) or .overflow_content(|count| ...). Configure .overlap(pixels) (defaults to 25% of the diameter, clamped to a valid nonnegative range strictly less than the diameter) and surface-matched cutout rings with .ring_width(pixels) (default 2 px), .ring_role(ColorRole) (default Surface), or .ring_color(color). Stack order and negative overlap margins mirror automatically in RTL windows. .accessible_label(label) exposes a summary Role::Group label without adding focus stops.

Empty states

EmptyState::new(id, title) provides a purely presentational Material 3 Expressive empty-state layout shell without an embedded loading or retry state machine. Attach .icon(element) to render an icon inside a decorative Surface backdrop (default MaterialShape::Cookie7Sided in SecondaryContainer / OnSecondaryContainer), customizable via .icon_container_shape(shape) (accepting any ShapePolygon, MaterialShape, or PolygonRole), .shape(CornerShape), and .icon_container_color_role(container, content). Use .visual(element) to replace the icon container with any custom illustration. Provide body copy with .supporting(text) (BodyMedium in OnSurfaceVariant) or .supporting_content(element), configure layout width and heading hierarchy with .max_width(pixels) (default 360 dp) and .title_role(TypeRole) (default TitleLarge), and place caller-owned controls in .primary_action(element) and .secondary_action(element) (rendered in a centered horizontal row with a 12 dp gap, 24 dp top margin, and RTL mirroring). The icon container is decorative and adds no focus stop, while title, supporting copy, and caller actions preserve normal semantics and keyboard focus.

Skeleton placeholders

Skeleton::rect(id, width, height), Skeleton::text_line(id), Skeleton::circle(id, diameter), and Skeleton::shape(id, width, height, shape) render Material 3 loading placeholders in core without optional feature dependencies. text_line defaults to full width, 16 dp height, and CornerRole::Small, and accepts .width(...), .height(...), .role(TypeRole), and .full_width(). shape accepts any ShapePolygon (including MaterialShape such as MaterialShape::Cookie7Sided). Customize rounded presets with .corner(CornerShape) or .corner_role(CornerRole) and override base/highlight tints (defaulting to SurfaceContainerHigh and SurfaceContainerHighest) with .colors(SkeletonColors). Placeholders are decorative by default and never add Tab stops; pass .accessible_label(label) to expose a polite Role::Status label when appropriate. Animation is driven by foundation::LoopClock and gated by is_bounds_visible: offscreen or clipped skeletons schedule zero animation frames, and .animated(false) or reduced_motion renders the static base color with zero animation frames.

Swipe to dismiss

Keep an Entity<SwipeToDismissState> per item and pass it to SwipeToDismiss::new(id, &state, content). The state starts at rest. Use .initial_value(value) when restoring an item at a dismissal anchor. Add a background with .background(element). It fills the container behind the moving foreground. Observe the state to update the background with the logical dismiss_direction(), signed offset() in logical pixels, or outward progress() from 0 to 1. current_value() is the nearest anchor, target_value() is the expected landing anchor, and settled_value() changes when the movement completes.

Both logical directions and gestures are enabled by default. Use .enable_start_to_end(bool), .enable_end_to_start(bool), and .gestures_enabled(bool) to configure them. The window’s writing direction determines the physical swipe direction. The default threshold is 56 logical pixels. Use SwipeToDismissState::positional_threshold(|width| ...) to compute a threshold from the laid-out width. Finite results are clamped to the available travel and invalid values use the default. Vertical drags and scroll continue through the surrounding layout.

dismiss(direction, window, cx) animates to an enabled direction, reset(window, cx) animates back to the resting position, and snap_to(value, window, cx) moves immediately. Reduced motion settles immediately. .on_dismiss(|direction, window, cx| ...) runs once when movement settles in a new dismissal direction. The foreground leaves keyboard traversal and the accessibility tree at that point. The application owns data changes such as removing the item, and can call reset to show it again. Provide a named, keyboard-focusable button or menu item for each offered action. Its activation calls the same dismiss method and remains available when gestures are disabled.

Progress indicators

Create a LinearProgress or CircularProgress with a stable ID and accessible name. The caller owns the measured value and passes it with .value(fraction). Finite values are clamped to 0..=1. Omit the value or call .indeterminate() to show unspecified progress. Non-finite values also select indeterminate mode. The accessible progress bar reports the current target percentage in determinate mode and has no numeric value in indeterminate mode.

Use .shape(ProgressShape::Wavy) for a wavy active indicator. Each mode accepts .tone(SemanticTone), .active_stroke(ProgressStroke), .track_stroke(ProgressStroke), and .gap(size). Each stroke specifies its own optional width and color and a ProgressCap of Round, Butt, or Square. Defaults are 4 dp round strokes, a 4 dp gap, and the window’s Primary and SecondaryContainer colors; semantic tones map the active stroke to the tone’s role (Error, Success, Warning, or Info) and the track stroke to its container role (*Container), while explicit .active_stroke and .track_stroke colors take precedence. Width zero hides that stroke. Negative or non-finite widths and gaps use their defaults. The renderer fits the strokes to the available bounds and limits gaps to the available track. Linear geometry follows the window’s layout direction. Circular progress starts at the top and sweeps clockwise.

Use .wave_amplitude(fraction) or .wave_amplitude_by(|progress| …) to select the wave’s height within the available space. The callback receives the displayed progress in determinate mode and zero in indeterminate mode. Amplitude is clamped to 0..=1, and NaN becomes zero. The default suppresses the wave through 10% and from 95% in determinate mode, and uses full amplitude in indeterminate mode. The measured endpoints at zero and 100% are flat. .wavelength(length) sets crest spacing in logical pixels. The circular renderer fits a whole number of waves around the ring. .wave_speed(length_per_second) sets the travel speed in logical pixels per second and defaults to one wavelength per second. Zero speed holds the current phase, and invalid lengths or speeds use their defaults. Reduced motion holds a static shape and applies measured changes immediately.

Linear determinate progress has a 4 dp stop marker at the logical track end. Use .stop_size(size) to resize it, or zero to hide it. Invalid sizes use the default. Keep a visible stop marker when the track contrasts with its surrounding surface by less than 3:1. .draw_stop_indicator(|stop, window, cx| …) replaces the default paint. ProgressStop provides the marker bounds, active color and cap, and layout direction. The renderer runs only for a visible stop, is clipped to its bounds, and adds no accessibility node.

Loading indicator

LoadingIndicator::new(id, label) uses a 48 dp footprint and a seven-shape indeterminate loop. Add .contained(true) for a rounded container. The Default indicator uses the window’s Primary color. Contained uses OnPrimaryContainer for the indicator and PrimaryContainer for the container. Override either indicator with .indicator_color(color). Set .container_color(color) and .container_shape(CornerShape) on Contained instances. Start and end corners follow the window’s layout direction.

The application owns determinate progress. Pass it as .value(fraction) on each render. The fraction is clamped to 0..=1, and NaN becomes zero. With the default sequence, zero shows a circle and one shows the Soft Burst shape. Create a reusable LoadingIndicatorShapes with at least two LoadingIndicatorShape values and pass it by reference with .shapes(&shapes). Use LoadingIndicatorShape::circle(), LoadingIndicatorShape::material(MaterialShape), LoadingIndicatorShape::from(ShapePolygon), or LoadingIndicatorShape::rounded_polygon(&vertices, radius) with GPUI points and a radius in the same units. Polygon construction returns None for non-finite, degenerate or self-intersecting geometry. The sequence constructor returns None if given fewer than two shapes. A determinate sequence goes from first to last, and an indeterminate sequence also morphs from last to first.

The label names a progress indicator. Determinate mode exposes a numeric percentage and draws the supplied value directly. Indeterminate mode exposes no numeric value and uses a polite live status. Reduced motion holds the first indeterminate shape and keeps determinate progress responsive. .active(false) retains the footprint and suppresses visuals and progress semantics. Only an active indeterminate indicator in an active window requests animation frames.

Pull to refresh

Create an Entity<PullToRefreshState> for each viewport and observe it in its rendering view. Use PullToRefresh::new(id, &state, refreshing, on_refresh) and add children with GPUI’s ParentElement API. The container creates a vertical viewport with a retained scroll_handle(). To wrap an existing scrollable child, use .track_scroll(&handle) or .scroll_position(|window, cx| ...) with its positive distance from the top in logical pixels. The child keeps its own scroll behavior and the wrapper uses its top edge for handoff.

A downward touchscreen pan or phased precise scroll pulls the indicator when scrolling reaches the top. Pulling back toward the content reduces the indicator distance before vertical scrolling resumes. Horizontal movement and ordinary wheel input continue to scroll. The threshold is 80 logical px by default, with half-speed drag before the threshold. Use .threshold(pixels) to set the threshold and .indicator_distance(pixels) to set the indicator travel separately. The default indicator travel is 80 logical px. .enabled(false) cancels an active pull and disables the refresh action. Cancelling a gesture discards its pending release.

The application owns the refreshing argument. A release beyond the threshold or the named Refresh button issues one request. The button works with keyboard and assistive technology and takes its label from .refresh_label(label). Further requests wait until the application renders refreshing = true or calls reject_refresh(cx) to decline. Requests stay unavailable while refreshing. Render refreshing = false again when the operation completes.

The centered Contained Loading Indicator tracks pull progress and becomes indeterminate during a refresh. Use .indicator(|progress, window, cx| ...) to supply decorative content. PullToRefreshProgress reports the distance fraction, requested or refreshing state, indicator offset, and whether the indicator is settling. Read distance_fraction(), is_animating(), and is_refresh_pending() from the retained state. snap_to(fraction, cx), animate_to_threshold(cx), animate_to_hidden(cx), and reset(cx) control presentation independently of the application’s refreshing value. Reduced motion applies the target position immediately and holds the indeterminate shape static.

Banners

Banner::new(id, message) renders a non-blocking, in-flow Material 3 banner/callout surface (feedback feature). Visibility is entirely caller-owned with no internal hidden state. Add an optional bold heading with .title(text), a decorative leading icon with .icon(element) (tinted to the tone accent/foreground color), up to two tone-matched Material text buttons via .action(label, handler) and .secondary_action(label, handler) (or custom controls via .actions_content(element)), and an optional trailing dismiss IconButton via .on_dismiss(handler) (named by .dismiss_label(label), defaulting to "Dismiss"). Choose .tone(SemanticTone) to switch between Default (SurfaceContainerLow container, OnSurface text, Primary icon, OutlineVariant border) and semantic (Container, OnContainer, Role) palettes for Danger, Success, Warning, and Info; explicit .colors(BannerColors) overrides always take precedence over .tone. Customize corners with .shape(CornerShape) (default CornerRole::Medium) and accessibility role with .alert(bool) (Role::Alert vs Role::Status; SemanticTone::Danger defaults to Role::Alert unless overridden). Icon, text alignment, actions, and dismiss placement mirror in RTL.

Snackbars

Retain a window’s Entity<SnackbarHost> and mount it in the layout or pass it to Scaffold::snackbar. Call push to append a Snackbar::new(message) to the FIFO. A plain message lasts four seconds. .action(label, callback) makes it persistent by default. Set .timeout(Some(duration)) after .action(...) to override that duration, or .timeout(None) to wait for a dismissal. Each timer starts when its message becomes current.

Set .message_content(|window, cx| ...) to replace the visible message. Snackbar::new still supplies the accessible status text. Use .action_content(...) with .action(...) to replace the named action’s visible content. .dismiss_label(label) customizes the default close button’s accessible label while preserving the default Close icon, and .dismiss_content(label, |window, cx| ...) replaces the named close control’s content. The close icon is shown by default, and .show_dismiss(false) hides the affordance. Keep slot content decorative so the host owns focus, activation, and the completion path. .action_on_new_line(true) puts the action and optional close control on a trailing-aligned row below the message.

Use .shape(CornerShape) for the container, .tone(SemanticTone) for Material semantic status palettes, and .colors(SnackbarColors) to set the container, message content, action, and dismiss colors independently. The default corner radius is 4 dp. SemanticTone::Default uses Inverse Surface for the container, Inverse On Surface for message and dismissal content, and Inverse Primary for the action; semantic tones (Danger, Success, Warning, Info) use the tone’s *Container, On*Container, and base role respectively while explicit SnackbarColors take precedence. The host renders the message as a polite live status without moving keyboard focus. Timed snackbars pause their auto-dismiss timer while hovered or while one of their controls holds focus, and restart the timeout when pointer hover and focus leave. The named controls use normal Tab traversal and activation. Escape dismisses the snackbar when one of its controls has focus. Completing a focused snackbar restores the prior focus target when it is available.

Use enqueue (or push_message(message, window, cx) for a plain message) when the caller needs a SnackbarId. Call replace(snackbar, window, cx) to dismiss the currently active snackbar (if any, firing its dismissal completion cleanly) and present the new snackbar immediately ahead of any pending entries. current() returns the active ID and message, pending_len() returns the count of queued messages waiting behind the active entry, clear_queue(cx) discards queued entries without disturbing the active message, and dismiss() dismisses the current message. dismiss_message(id, window, cx) and perform_action(id, window, cx) apply only to the active entry. perform_action also requires an action. Use .on_result(|result, window, cx| ...) to observe SnackbarResult::ActionPerformed or SnackbarResult::Dismissed. Timeout and explicit or programmatic dismissal report Dismissed and call .on_dismiss(...) when supplied. Each result is delivered once. The queue advances before callbacks run, so callbacks can enqueue or dismiss messages from the same host. Dropping the host cancels its timer and discards remaining messages.

SnackbarHost::renderer(|message, parts, window, cx| ...) can lay out the provided SnackbarParts within a custom container. Place parts.message to retain the live status and parts.action and parts.dismiss to retain the named controls. The host still owns timing, completion, motion, and outgoing content. During exit, the parts render as passive content. The scale field lets the renderer scale its own dimensions to match the animation.

Display-only scrollbar

Create DisplayScrollbar::new(id, axis, &handle) with the ScrollHandle, UniformListScrollHandle, or ListState already bound to the viewport. These implement Base’s ScrollbarHandle. Mount the scrollbar after the viewport as an overlay child of the same relative parent. The viewport retains scroll state, focus, and input. The indicator contributes paint only. In a horizontal layout, progress runs from the logical start to the end. In a vertical layout, the track is on the logical trailing edge. Its position follows the window direction in RTL.

Use .style(DisplayScrollbarStyle) to set thumb_color, track_color, thickness, thumb_min_length, thumb_max_length_fraction, main_axis_track_inset, and cross_axis_track_inset. The default thumb is the window’s Outline at 70% opacity and the track is transparent. Thickness is 4 logical pixels, minimum thumb length is 24 logical pixels, and maximum thumb length is 90% of the track remaining after insets. The main-axis inset is 2 logical pixels at both ends and the cross-axis inset is zero. The indicator hides when content fits the viewport or the track cannot fit the thumb’s minimum length. .offset(point(dx, dy)) moves the painted scrollbar in physical logical pixels inside the viewport clip.

.fade(DisplayScrollbarFade { enabled, delay, duration }) controls visibility after an offset change. Fading starts enabled with a 400 ms idle delay and a 250 ms fade. Use enabled: false to keep the indicator visible while content overflows. Reduced motion keeps the delay and hides it instantly at the end. The viewport schedules ordinary redraws as its offset or extent changes. The indicator schedules a wake-up for the fade delay and requests frames during the fade.

Input and overlays

Component Supported variants and behavior Material 3
TextField Filled and Outlined, with single-line, multiline, secure, read-only, and disabled modes. Supports label placement, adornment and description slots, required and invalid states, and character counts. Text fields
ExposedDropdown Editable filtering and selection-only lists anchored to a text field. Menus · Text fields
Menu Anchored menus and context menus, with groups, checked items, and submenus. Menus
Tooltip Transient plain and rich tooltips, and persistent rich tooltips with caller-owned visibility and customizable content, placement and appearance. Tooltips
Label Passive control-anchored labels with shared interaction state and persistent visibility. Compose Label
Scrim Standalone backdrop with themed or custom color, adjustable opacity, and optional dismissal. Scrim
Dialog Structured basic and adaptive full-screen task dialogs, a custom-content modal shell, and opt-in native dialog windows. Dialogs
Sheet Standard and modal bottom sheets, and side sheets docked or overlaid at the logical start or end. Bottom sheets · Side sheets

TextField decorates the caller’s retained Base editor. Use TextField::filled(id, label, &state) or TextField::outlined(id, label, &state) as shorthands for TextField::new(id, label, &state).variant(...). Use label_content, placeholder_content, and supporting_content with plain text for the accessible name, hint, and description. Leading and trailing elements are separate from the prefix and suffix next to the value. Prefix and suffix appear while the label is minimized and stay outside the stored value. Set .show_label(false) to omit the visual label and vertical label reserve while keeping the constructor’s label as the accessible name and keeping placeholders, prefixes, and suffixes immediately visible. The default container minimum height adapts to theme.layout.density (52 dp Compact, 56 dp Standard, 60 dp Comfortable); pass .min_height(Pixels) to override it down to the text and padding fit (negative or non-finite values are ignored). Use .indicator_width(unfocused, focused) (default 1 px unfocused / 2 px focused; negative or non-finite values are ignored) to customize the Filled bottom indicator or Outlined border thickness, or pass px(0.) to omit it cleanly. Set .clearable(true) (with optional .clear_label(label), defaulting to "Clear") to automatically display a trailing clear button (IconName::Close) whenever the editor is editable and non-empty; activating it clears the Base state via replace_all("") and keeps focus on the editor without emitting an intermediate blur on pointer press. If both .clearable(true) and custom .trailing(...) (or .visibility_toggle(...)) are set, built-in controls render in logical order before custom trailing content. Pointer presses inside the container or label focus the editor, while pointer presses outside them (including the supporting-text row and non-focusable background) blur the editor unless an open ExposedDropdown popup handles the press; disabling a focused editor also blurs it. Labels default to Inside for Filled and Cutout for Outlined. Select Above for a label outside the container, or configure the horizontal alignments and keep an inside or cutout label minimized. The character count shows Unicode scalar values in value() without enforcing the limit. Set instance colors, the container shape, content padding, or input typography independently of the window theme. on_text_layout reports the laid-out editor and text bounds and the wrapped line count after the frame. Set interaction_source to share observations of hover, keyboard focus, and disabled states. The Base entity still owns editing, selection, validation, scrolling, and IME composition.

For secure fields, keep a dedicated TextFieldState initialized with .masked(true) and render it with TextField::secure. Use .obfuscation_mode(TextFieldObfuscationMode::Hidden | Visible) (default Hidden) to control visibility manually, or call .visibility_toggle(visible, on_toggle) (with optional .visibility_labels(show, hide), defaulting to "Show password" / "Hide password") to sync obfuscation mode automatically and render a trailing reveal button using the bundled IconName::Visibility and IconName::VisibilityOff symbols. Hidden masks text with Base’s fixed bullet (•), disables copy and cut, and omits the accessible value, accessible SetValue, and character count; Visible switches the editor to plain text to match native desktop and web conventions. Custom mask characters and mobile reveal-last-typed timers are omitted as desktop adaptations.

Use Base’s TextFieldState::validate or pattern to reject disallowed edits before commit across typing, paste, IME composition, and accessible SetValue. Use TextFieldMaskPattern with TextFieldState::mask_pattern and unmask_value for structured patterns and numeric grouping; use prefix and suffix for fixed display-only affixes. Arbitrary value normalization (such as case conversion) runs in the application’s TextFieldEvent::Change or Blur handler, where post-commit rewrites record their own undo step rather than using a separate display-only offset layer.

Exposed dropdowns

Create ExposedDropdownState once per dropdown. It owns the pending query, committed selection and list position. Read the displayed visibility with is_open() and the last committed option ID with selected_option_id(). with_editor(&editor, editable, window, cx) uses the caller’s retained TextFieldState. .editor(|field| ...) customizes or wraps the supplied TextField, including its label, decoration and editor layout. Keep this field in the result to retain its accessible name and native editing, caret and IME behavior.

The default editable field opens on typing or via its trailing trigger and keeps editor focus. The default selection-only field opens on a click or Space and also retains its field focus. Use .primary_anchor(DropdownAnchor::PrimaryEditable) to add whole-field activation while keeping editor focus. Use PrimaryNotEditable with selection-only state to move focus to the list and return it to the field on dismissal. .secondary_anchor(label, |open| ...) customizes the trailing trigger and supplies its accessible name. Secondary pointer activation keeps the editor available for typing, and accessibility activation of an editable secondary anchor moves focus to the options. .primary_anchor_enabled(false) and .secondary_anchor_enabled(false) turn off their respective menu activation while leaving editor input available.

Add .open(open) and .on_open_change(|requested, window, cx| ...) to control visibility. Apply requests in the owner and render again. .on_dismiss(...) reports a user request to close. Programmatic updates apply immediately on render and preserve the committed value when discarding the draft. Up and Down navigate options, Enter commits, and Escape dismisses after composition is complete. Focus returns from the menu to its invoking anchor when available. Dismissal leaves focus with an outside control that already received it.

Options retain their IDs across recreation and reordering. Use ExposedDropdown::with_shared_options(id, label, &state, options) with a retained Rc<[DropdownOption]> (or any Into<Rc<[DropdownOption]>>) to share option slices across renders without per-frame collection or linear slice comparisons. .option_content(|option, highlighted, window, cx| ...) supplies decorative row content. The original label provides the accessible name and searchable text. Use scroll_state() to read or move the retained GPUI ListState or set_scroll_state(&scroll, cx) to attach one owned by the caller. The viewport constructs only visible rows and overscan, including custom content. Menu width matches the field by default. Use .match_anchor_width(false) for an independent width, which defaults to 240 px, and .popup_width(width) to override it. Width and height fit the available window area. .appearance(MenuSurfaceStyle) configures the menu shape, theme roles, outline and elevations. .container_color(color) overrides its container tint.

Menu::new owns its visibility by default, and Menu::new_with(id, trigger, |window, cx| ...) builds items lazily only when the menu is open. Any IntoElement can attach a secondary-click context menu in postfix style via MaterialElementExt::context_menu(id, items) or lazily via MaterialElementExt::context_menu_with(id, |window, cx| ...). Calling .context() positions the popup at the secondary-click pointer location (clamped to the viewport, unless overridden by .position(...)), repositions smoothly on subsequent secondary clicks inside the trigger, leaves the trigger’s own primary Enter/Space actions intact, and also opens anchored to the trigger on Shift+F10 or the ContextMenu key. Use .disabled(true) to render only the trigger without attaching menu activation. Add .open(open) and .on_open_change(|requested, window, cx| ...) to let the caller own visibility. Apply the requested value when desired and render again. A caller update to open applies visibility and focus without sending change callbacks. .on_dismiss(|window, cx| ...) reports a close request from a user action. Menu::composed supplies the displayed open value and an activation callback to a custom trigger.

Keep each MenuItem ID stable and provide a label for accessibility. Its .content, .leading, .supporting, .trailing, and .selection_icon builders accept repeatable element factories for visual content. Use .tone(SemanticTone) or .destructive() (shorthand for SemanticTone::Danger) to tint the label and leading icon with a semantic role while preserving disabled styling and explicit MenuItemStyle precedence. Use .shortcut(text) to render a desktop shortcut hint in the trailing slot (LabelSmall in OnSurfaceVariant, or disabled color when disabled) unless an explicit .trailing(...) overrides it. Insert MenuItem::divider(id) for a non-interactive horizontal divider row inside a flat menu that is skipped by keyboard navigation. A menu row owns the keyboard and pointer action. Pass the checked value with .checked(value) and handle requests with .on_checked_change. Selected items continue to use .selected(value) with .on_activate.

Use .color(MenuColor::Vibrant) for the tertiary menu palette. A MenuItem::section(id, name, rows) draws a grouped surface and keeps its rows in the menu’s arrow-key order. Menu::content adds caller-authored content before the rows. A section’s .content replaces its visible heading.

Use MenuSurfaceStyle with Menu::appearance or MenuItem::group_appearance to configure the surface shape, padding, spacing, border and elevations. MenuItemStyle overrides menu-row shapes, spacing, padding, and color roles. Use .anchor and .offset for logical trigger placement or .position with a window-local point. .track_scroll accepts a caller-owned scroll handle.

Tooltips

Tooltip::plain (or MaterialElementExt::tooltip(id, text) in postfix style) and Tooltip::rich show after pointer hover (500 ms open / 200 ms close defaults, customizable via .show_delay(Duration) and .hide_delay(Duration)) or when the trigger receives keyboard focus via .track_focus(&focus). For a persistent rich tooltip, create an Entity<TooltipState> with cx.new(|_| TooltipState::new()) and attach it with .persistent(&state). Click or activate the trigger with the keyboard, or call state.show(cx) from the owner. A trigger button owns its accessible Invoke action. Call state.update(cx, |state, cx| state.show(cx)) in its on_activate callback so that action opens the tooltip as well. Persistent tooltips stay open when the pointer leaves. Call state.dismiss(cx) to close one programmatically and is_visible() to read its requested visibility.

.enable_user_input(false) leaves activation to the caller. Open tooltips can be dismissed with Escape from their trigger or content. Persistent tooltips also dismiss when a pointer presses outside. With .on_dismiss_request(callback), the owner of a persistent tooltip accepts the request by calling dismiss(cx). A transient tooltip closes on Escape and reports the request through the same callback. .focus_target(&focus) lets Tab move from the trigger to a caller-supplied control. .focusable(true) moves focus into the tooltip on opening. The default preserves focus. If focus is inside when the tooltip closes, it returns to the trigger or previously focused control.

Use .title_content, .body_content and .action_content for GPUI elements. Use .shortcut(text) to append a subtle formatted desktop shortcut hint beside plain tooltip text or in a rich tooltip header/body while keeping the constructor’s text as the accessible description. .link(label, callback) creates a link whose callback owns navigation. .placement(TooltipPlacement) selects a physical side or the logical Start or End, and .offset(pixels) sets the gap. The default prefers Above with a 4 px gap and flips when the surface needs room. .positioner(...) can return a TooltipPositioner using the measured trigger bounds, viewport and text direction.

Use .caret(TooltipCaret::default()) for the Material 16 × 8 px caret, or supply custom dimensions and a path. The caret is off by default. .max_width, .shape, .colors, .tonal_elevation, and .shadow_elevation configure the surface. Plain and rich tooltips default to a maximum width of 200 px and 320 px respectively within the available window. Unset colors and shape use the window’s Material palette and corner roles. Tonal elevation defaults to zero and shadow elevation defaults to Level 0 for plain and Level 2 for rich.

Labels

Use Label::new(id, anchor, description) to append an overlay to a control or other GPUI element. The description provides accessible text. .content(element) supplies custom decorative content in the label surface. The anchor keeps its own role, focus, and activation. The label surface leaves pointer input available to controls beneath it.

Attach .interaction_source(&source, control_id) using the source and ID observed by the owner of the control. A non-persistent label shows while that control is hovered, pressed, dragged, or has keyboard-visible focus. Disabled or detached controls clear interaction-driven visibility. The label stays hidden when no source is supplied. Pass .persistent(true) to keep it visible while its anchor is in view, regardless of interactions, and change that value on a later render to return to interaction-driven visibility. Escape and outside input remain with the surrounding controls.

The label uses the plain Tooltip surface and placement. It prefers Above with a 4 px gap and fits the available window. Use .placement(TooltipPlacement), .offset(pixels), .max_width(pixels), or .caret(TooltipCaret) to customize placement and the surface. The optional caret follows the resolved side.

Scrim

Place Scrim::new(id) in a positioned container, after the background content and before the foreground surface. It fills the container and uses the current window theme’s Scrim role at 32% opacity. Use .color(color) to supply a custom tint and .opacity(value) to multiply the tint’s alpha. Values clamp to 0–1 and NaN uses the default.

By default the scrim is decorative. It dims the content while leaving pointer input and accessibility traversal available. Add .on_click(|window, cx| ...) to block pointer input behind the scrim and handle pointer or accessibility activation. The scrim has no keyboard tab stop. Use .accessibility_label(label) to name the action for assistive technology. The default label is “Dismiss overlay.” The caller owns visibility, dismissal, and the modal focus and accessibility scope. Give modal content its own keyboard dismissal action.

Dialogs

Create an Entity<DialogState> once per dialog and call open(window, cx) and close(window, cx) to control an in-window dialog. Use Dialog::new(id, &state, title) for the default Material layout, or Dialog::alert(id, &state, title, description) for a basic alert with a description and no default cancel button. DialogVariant::FullScreen fills the content area below 600 logical px in width and uses the basic layout in wider windows. Tab and Shift+Tab stay in the modal. When nesting dialogs in the same window, give the inner dialog a higher .layer(index) and open it from the active dialog. Closing restores the previous focus while the dialog still owns focus.

Use .icon(element), .title_content(element), .description(text), and .body(element) to compose the icon, heading, supporting text, and body. The constructor’s title names the dialog for assistive technology. Use .show_title(false) to omit the visible heading. .confirm(label, validate) supplies the default confirmation, including Enter while the dialog container has focus; returning false keeps the dialog open. .on_confirm(label, action) is a non-validating shorthand that always closes the dialog after running action, .confirm_tone(SemanticTone) tints the default confirmation button in both basic and full-screen layouts, and .confirm_disabled(bool) / .confirm_loading(bool) disable or show an inline busy spinner on the default confirmation button while suppressing Enter confirmation. DialogState::focus_handle() and DialogState::scroll_handle() expose the retained container focus and body scroll handles. .confirm_content(|confirm| ...) and .dismiss_content(|dismiss| ...) build independent controls. Wire their pointer, keyboard, and accessible activation to the supplied DialogAction::activate(window, cx) using a control such as Button. A custom confirmation can use the same validator, and owns its keyboard shortcut. .show_cancel(false) omits the default Cancel button or compact Close icon.

Use Dialog::unstructured(id, &state, accessible_name).body(element) for a modal with caller-defined structure. It supplies focus, an accessible dialog name, a bounded viewport and dismissal policy. The caller specifies its own padding, scrolling, heading, actions and surface. .body_content(|confirm, dismiss| ...) builds custom content with both activation handles. .width(pixels) sets the maximum width of a centered dialog, within the available space. Set instance .shape, .colors(DialogColors), .tonal_elevation, and .shadow_elevation for the surface and slots. .scrim_color and .scrim_opacity customize the in-window backdrop. A transparent scrim still blocks pointer input behind the dialog.

DialogProperties controls Escape and outside-click dismissal independently. Both default to enabled. .on_dismiss_request(|reason, window, cx| ...) can reject Escape, outside clicks, and native window-close requests by returning false. .on_close(|reason, window, cx| ...) receives a single accepted user close, with reason Confirm, Cancel, Escape, OutsideClick, or WindowClose. For a programmatic close, read last_close_reason() on the state to obtain Programmatic. The callback receives the dialog’s window. State changes and focus restoration happen independently of the callback.

Call Dialog::open_window(&state, parent, options, cx, |state, window, cx| ...) from the active parent to request a separate GPUI dialog window and build its contents in that window. Window bounds, title bar and resizability come from WindowOptions. The system owns parent modality, window chrome and native resize behavior. Windows disables the active parent, macOS uses a window sheet, and Linux modality follows the compositor. Escape and the system close control use the same dismissal policy as the in-window shell. Outside-click dismissal and a scrim apply to in-window dialogs. Use the in-window path for consistent owner-local modality across platforms.

Bottom sheets

Create an Entity<BottomSheetState> with BottomSheetState::new(initial_value, cx) and render it with Sheet::bottom(id, &state, name, content). The available BottomSheetValue values are Hidden, PartiallyExpanded, and Expanded. Use .enabled_values(values) and .confirm_value_change(|target| ...) when constructing the state. Disabled targets and rejected transitions leave the active stop in place.

Call show(window, cx) to open at the partial stop when available. partial_expand(window, cx), expand(window, cx), and hide(window, cx) animate to an explicit stop, as does animate_to(value, window, cx). snap_to(value, window, cx) applies a stop immediately. Read available_values(), current_value(), target_value(), is_animating(), visible_height(), and offset() from the state. Offset is the downward travel in logical pixels from the expanded position. Reduced motion settles immediately.

Standard sheets take part in the caller’s layout. Scaffold::bottom_sheet(sheet) puts a Standard sheet under its main content and above bottom navigation. The sheet fits the measured content column. Its visible height counts toward the scaffold’s occupied bottom inset. The existing ScaffoldInsets minimum still governs remaining body padding. Modal sheets overlay the window and confine focus until they dismiss. User dismissal observes .properties(DialogProperties), .on_dismiss_request, and the state’s transition guard. .on_close reports an accepted user dismissal once. Programmatic hiding restores the opener without reporting a user dismissal.

Set .extent(height) for the expanded height and .peek_height(height) for the partial stop. Standard sheets default to a 56 px peek. Modal partial height is capped at half the viewport by default. Width defaults to 640 logical px and can be changed with .max_width(width). Set .content_insets(ScaffoldInsets) to add logical padding to the scrolling sheet body. Use the shared Sheet shape, colors, scrim and elevation builders.

The named resize handle supports pointer dragging and can cycle through available stops with the keyboard or assistive technology. Up and Down move between stops, and Home and End choose the lowest or highest available stop. Use .handle_label(label) to set the accessible name. Replace its decoration with .handle_content(element) or use .show_handle(false) for a text action. .drag_enabled(false) keeps the explicit action available. .drag_thresholds(BottomSheetThresholds) configures position and release velocity, with defaults of 56 logical px and 125 logical px per second. Escape, pointer capture loss, and resizing during a drag restore a valid stop. Scrolling inside the body stays independent of the handle.

Side sheets

Build a side sheet with Sheet::new(id, &state, name, content) and .edge(SheetEdge::Start) or .edge(SheetEdge::End). The edge follows the window’s direction. Standard sheets take part in the caller’s layout and leave nearby content interactive. Place the sheet next to the primary content on the corresponding logical edge. Modal sheets overlay the window and confine focus until closed. Retain a DialogState and call open(window, cx) and close(window, cx) for modal visibility. When nesting modal sheets, give the inner sheet a higher .layer(index).

Use .placement(SheetPlacement::Detached) to inset a floating sheet from the window or layout slot. Detached margins default to 16 logical px and .margins(SheetMargins { top, bottom, start, end }) overrides them. Docked sheets sit flush with their edge. .extent(width) selects the side sheet width up to 400 logical px by default (configurable via .max_width(width)), within the available space. The default width is 320 logical px. .edge_divider(true) separates a docked Standard sheet from the adjacent content.

Use .header_content(element) to replace the visible title, or .show_header(false) to omit the visible header row on either bottom or side sheets while retaining the constructor’s name as the accessible label. .back(label, callback) supplies a named navigation button and .back_content(element) supplies a caller-owned alternative. Back navigation leaves the sheet open unless its callback closes it. Modal sheets include a Close action. Use .close_label(label) to name it, .show_close(false) to omit it, or .close_content(|close| ...) to build a named control whose activation calls close.activate(window, cx). On a Standard sheet, .on_close delegates removal of the sheet to the caller and enables the default Close action. Use .footer(element) for fixed actions below the scrolling body and .footer_divider(true) to separate them from the body.

.properties(DialogProperties) controls Escape and outside-click closing for the modal sheet. .on_dismiss_request(|reason, window, cx| ...) can veto a user close, including the Close action. .on_close(|reason, window, cx| ...) reports one accepted modal close or the Standard Close action. The reason is Cancel, Escape, or OutsideClick. Programmatic modal closure records Programmatic in DialogState::last_close_reason(). A modal returns focus to the prior control while it still owns focus. The modal backdrop blocks pointer and scroll input even with zero opacity or outside dismissal disabled.

Set .shape, .container_role, .content_role, and .colors(SheetColors) for the surface, content, heading, dividers, and scrim. .tonal_elevation, .shadow_elevation, and .scrim_opacity apply per instance. The Standard side sheet uses Surface and the modal side sheet uses Surface Container Low. Docked modal sheets round the inner corners and detached sheets round all four. Custom slot controls retain their own appearance and semantics.

Component Supported variants and behavior Material 3
AppBar, AppBarRow, AppBarColumn, BottomAppBar Small, Centered, Medium Flexible, Large Flexible, and customizable TwoRows top app bars with responsive action overflow, plus an 80 dp bottom app bar with actions, embedded FAB slot, and hide-on-scroll behavior. App bars · Bottom app bar
Tabs Fixed or scrolling Primary and Secondary tabs with leading icons, custom content and badges, configurable indication, and retained scrolling. Tabs
NavigationBar, NavigationRail, NavigationDrawer Short navigation bar with equal-weight or centered destinations, vertical or horizontal icons, and custom labels and badges. Rail with collapsed, expanded, hidden, and modal presentation. Full-width Standard and Modal navigation drawers with sections, dividers, and pill indicators. Navigation bar · Navigation rail · Navigation drawer
Stepper Horizontal and vertical multi-step progress and linear or non-linear step navigation with active, completed, upcoming, error, and disabled step states. Stepper
Breadcrumbs Desktop path navigation with caller-owned segments, RTL-mirrored separators, current-item semantics, and automatic middle-segment collapse into an anchored Material Menu. Navigation
AdaptiveNavigation Adapts navigation type and animated visibility, with customizable slots and styling. Breakpoints
Scaffold Combines navigation, app bars, content, a positioned FAB, and snackbars. Resolves content insets from occupied space. Scaffold
ListDetail, SupportingPane, Feed Canonical list, detail, supporting and feed layouts with an adaptive three-pane scaffold. Canonical layouts
VerticalDragHandle A vertical handle for horizontal pane resizing with separate resting, pressed, and dragged appearances. Parts of layout · Compose VerticalDragHandle

Adaptive navigation

Use AdaptiveNavigation::new(scaffold, items, width) with the available logical width. The default chooses ShortBarCompact with vertical destinations below 600 px, ShortBarMedium with horizontal destinations from 600 to 839 px, and RailCollapsed from 840 px. Navigation occupies the bottom or logical start of the existing Scaffold. Keep collection and destination IDs stable, and commit NavigationItems::on_select through the caller’s .selected(id).

Use .navigation_type(AdaptiveNavigationType) to select any of those presentations, RailExpanded, or None. Use .navigation_policy(|info| ...) to choose from available size, width class, and window direction. .available_size(size) supplies the actual bounded scaffold size when it differs from the viewport. With None, the suite leaves the scaffold’s existing slots in place.

Create an Entity<AdaptiveNavigationState> with an initial AdaptiveNavigationVisibility::Shown or Hidden and attach it with .state(&state). Observe current_value(), target_value(), is_animating(), and the visible fraction progress(). Call show(cx), hide(cx), or toggle(cx) for a transition from the current fraction. Call snap_to(value, cx) to settle immediately. The default transition lasts 240 ms and honors reduced motion. .transition_duration(...) changes its duration. The scaffold reserves the visible portion of the navigation as it slides from the bottom or logical start. Hiding removes the slot from the focus and accessibility trees at settlement. If focus is inside the hidden slot it moves to the next available control. Showing the slot keeps focus on the active control and restores the standard destinations’ last enabled keyboard stop when the caller’s selection has stayed the same.

Set per-item styles, icon positioning, badge content, and interaction sources on NavigationItem. Use .navigation_bar(|kind, bar| ...) or .navigation_rail(|kind, rail| ...) for per-presentation layout and appearance, including a retained NavigationRailState, optional modal session, arrangement, shape, or color settings. Call .navigation_content(|kind, default| ...) to replace the navigation region or place additional elements around its standard content. The custom region owns its names, tab stops, and focus handles. Keep those handles and element IDs stable across presentation changes. If custom content supplies a modal, its owner coordinates the modal session with suite visibility.

Adaptive multi-pane layouts

Create one Entity<AdaptivePaneState> per layout with AdaptivePaneState::new(PaneDestination::new(role)). Use AdaptivePaneLayout::new(id, size, &state) for custom composition or ListDetail::adaptive(...) and SupportingPane::adaptive(...) for canonical order. Supply the available logical viewport size and stable pane IDs. Register the content with .pane(PaneRole, AdaptivePane), including Tertiary for the extra pane. Keep business state, focus handles, and scroll handles in the caller. The ordinary ListDetail, SupportingPane, and Feed constructors keep their existing behavior; Feed exposes Role::List with optional .accessible_label(label) and maps WidthClass breakpoints to 1, 2, 3, or 4 columns while preserving its ScrollHandle anchor across column-count changes.

PaneLayoutDirective::for_size(size) chooses one horizontal pane at compact and medium widths, up to two at expanded widths, and up to three at large widths. A tall single-column viewport also allows a second vertical partition. Use .directive(directive) to set the horizontal and vertical limits, gaps, default preferred width and height, and logical excluded width intervals. AdaptivePane can set its preferred width and height, minimum width, and logical PaneMargins. The layout fits the available space, mirrors logical placement in RTL, and clips pane content at its bounds.

An excess pane can hide or Reflow under a visible role in a single-column layout with spare vertical capacity. Levitate presents the active pane above the layout using its preferred dimensions, the available viewport, and a logical PaneOverlayAlignment. Use .adapt_with(...) to select the strategy from the viewport and directive. A levitated pane takes pointer input inside its bounds. .levitate_scrim(element) adds a blocking backdrop and keeps Tab traversal inside the pane. Provide .entry_focus(&focus) for a preferred keyboard entry point.

Use .separator(start_role, end_role, PaneSeparator::new(label)) for a named resize handle between adjacent horizontal panes. The handle accepts pointer dragging, physical Left and Right with logical RTL mapping, Home and End, and accessible range adjustment. .anchors(...) provides PaneExpansionAnchor::Proportion(fraction), FromStart(px), or FromEnd(px). Anchors measure the logical horizontal partition with gutters removed. A completed drag snaps to the nearest configured anchor. Page Up and Page Down move to the next and previous anchors in logical order. The last applied width persists after interruption. .handle(...) customizes the Material handle and .keyboard_step(...) changes its input increment. Use set_expansion or clear_expansion on the retained state to move or reset a boundary programmatically.

Navigate with navigate_to(PaneDestination) and optional content keys. current_destination() and history() report the retained destinations. The back policies choose the latest entry or skip to a different layout, role, or content key. Use can_navigate_back, navigate_back, and seek_back with a PaneBackBehavior. The application assigns a Back button or key binding. set_history_aware chooses whether previously visited roles influence the responsive layout.

Use current_value(), target_value(), and progress() to observe presentation. snap_to, animate_to, and seek_to accept explicit PaneLayoutValue placements. follow_navigation resumes automatic adaptation and cancels a back preview. Changes retarget from the displayed geometry. The default transition lasts 240 ms and .transition_duration(...) sets a different duration. Reduced motion settles automatic changes immediately. History retains the same domain destinations when the viewport changes.

App bars

AppBar::new(id, title) defaults to a Small app bar and uses the title as its accessible toolbar name. .title_alignment(AppBarAlignment) and .subtitle_alignment(AppBarAlignment) set independent logical Start, Center, or End alignment. The Centered variant defaults both to Center. Set .title_max_lines(lines) and .subtitle_max_lines(lines) to wrap text up to the specified number of lines. The default is one line. Use .title_content(element) or .subtitle_content(element) for rich headings. The navigation, actions, and search slots retain their own layout. Search replaces the first-row heading.

Use .logo(element) to replace the text in a Small or Centered app bar, place a logo above the expanded heading of a flexible app bar, or put it before search. AppBarVariant::TwoRows places the expanded heading below navigation and actions. .title_for_rows(|expanded| ...) and .subtitle_for_rows(|expanded| ...) build the heading for the displayed row. .second_row(element) adds supplemental content to the expanded heading. Keep heading, logo, and supplemental content presentation-only. Put commands in navigation or actions.

Use .colors(AppBarColors) to override container, scrolled container, navigation, title, subtitle, and action colors independently. Slot content inherits its color and independently styled controls keep their explicit colors. .content_padding(AppBarPadding) sets logical insets in each row. Set .collapsed_height(height) and .expanded_height(height) in logical pixels. The expanded height includes both rows and is at least the collapsed height. The first row can grow to fit its slots. The default collapsed height is 64 dp and flexible variants use their Material expanded dimensions. Invalid sizes fall back to defaults.

Pass .track_scroll(&handle) for a GPUI content scroll handle or .scroll_state(&state) for a retained Entity<AppBarScrollState>. A caller-owned state can use set_content_offset(offset, cx) when it supplies its own positive distance from the top. With an attached handle the handle supplies that distance. Read content_offset(), height_offset(), height_offset_limit(), collapsed_fraction(), and overlapped_fraction() from the state. Without an explicit strategy, a tracked flexible bar collapses by its distance from the top. Choose .scroll_behavior(AppBarScrollBehavior::Pinned) for a fixed height that still responds with scrolled color, EnterAlways to reveal on reversal, or ExitUntilCollapsed to stay collapsed on reversal until the content returns to the top. The linked content owns scrolling and retains its input paths. .scroll_enabled(false) pauses scroll-driven updates. Call set_collapsed_fraction(fraction, cx) to position the bar or settle(velocity, cx) when scrolling ends. A positive velocity chooses collapse, a negative velocity chooses expansion where the strategy permits it, and zero chooses the nearest endpoint. .scroll_motion(MotionSpec) overrides settling motion. Reduced motion settles immediately.

AppBarRow::new(id, items) and AppBarColumn::new(id, items) lay out horizontal or vertical actions and move items that do not fit into a Material menu. Use AppBarItem::clickable(id, label, icon_factory) with .on_activate(...) and .disabled(bool) for shared inline and overflow commands. Use AppBarItem::custom(id, inline, |menu| ...) to supply a custom inline element and its own MenuItem. Give items stable IDs. A custom .overflow_indicator(|menu| ...) supplies the visual content of the built-in keyboard-focusable trigger. Set its name with .overflow_label(label). AppBarMenuState exposes is_showing(), show(window, cx), and dismiss(window, cx). .max_item_count(count) caps visible items including the trigger. The row mirrors in RTL. The hidden actions are accessible in the open menu.

Tabs

Tabs::new(NavigationItems::new(id, name, items)) defaults to fixed Primary tabs. Choose .variant(TabVariant::Secondary) for secondary tabs and .scrollable(true) when the row should scroll horizontally. Give each NavigationItem a stable ID. The caller applies selection with NavigationItems::selected(id) and handles requests from .on_select(...). Left and Right move focus in logical order, Home and End move to the first and last enabled tabs, and activation requests selection. Disabled tabs are skipped during keyboard navigation.

Use NavigationItem::icon_position(NavigationItemIconPosition::Start) for a leading icon that mirrors in RTL. The default Top places the icon above its label. Use .label_content(element) for a rich label or for an arbitrary tab body when there is no icon. The constructor still supplies the tab’s accessible name. .badge(Badge::standalone()) attaches a badge at the upper trailing edge of the icon or label. A badge’s optional .accessible_label(...) becomes the tab’s description. Keep the visual slots decorative so the tab owns focus and activation.

Set .colors(TabsColors) for the row container, shared content tint, and built-in divider. Override per-tab selected, unselected, or disabled icon and label colors with NavigationItem::colors(NavigationItemColors). The selected label can use different colors for Top and Start. Selected indicator color can also be set per tab. Pass a caller-owned Entity<InteractionSource> to NavigationItem::interaction_source(&source) and read state under ElementId::from((collection_id, destination_id)). IDs and interaction attachments follow tabs when they move or are removed.

Set .indicator_style(TabIndicatorStyle) for height, logical shape, color and motion. TabIndicatorWidth::Default keeps the preset width. Tab covers the selected tab, Content uses its measured icon-and-label width, and Fixed(width) uses a logical-pixel width capped at the tab width. Content width uses a 24 dp minimum where space permits. The configured indicator animates its position and width on selection changes. Reduced motion applies the target immediately. .indicator_content(|layout: TabIndicatorLayout| ...) replaces the visual indicator and receives the selected ID, resolved bounds, content width, and tint. Its content is clipped to the indicator bounds and row viewport. .divider(element) replaces the bottom divider across the viewport. Use gpui::Empty for either custom slot to omit that decoration.

On a scrolling row, .edge_padding(pixels) sets space at both logical ends and .min_tab_width(pixels) sets the minimum resolved tab width. Defaults are 52 and 90 dp. Invalid lengths use the defaults, and large overrides are bounded by window width. Attach an external .scroll_handle(&handle) or let the row retain its own handle. The row reveals a new selection or focus target and accounts for reordered tabs and changed viewport or tab geometry. Ordinary redraws preserve the caller’s or user’s current scroll offset.

Short navigation bar

NavigationBar::new(items) defaults to .layout(NavigationBarLayout::Vertical) and .arrangement(NavigationBarArrangement::EqualWeight). Equal-weight items share the width. Centered groups items around the middle of the bar and lets longer labels use more space, up to their equal share. Layout specifies the default icon position for each item. .icon_position(NavigationItemIconPosition::Top) places the icon above its label, and Start places it on the logical leading side. Both positions can appear in the same bar and Start mirrors in right-to-left windows.

Create each NavigationItem::new(id, label) with a stable ID and an accessible name. .label_content(element) replaces the visible label with decorative content and retains that name. Supply .badge(Badge::standalone()) for a dot or configure a standalone badge with custom content. The badge overlaps the upper trailing edge of the icon, or the label when there is no icon. A badge with .accessible_label(...) supplies the destination’s accessible description. The destination retains its name and one focus stop.

Use .colors(NavigationBarColors) to override the bar container and the shared content fallback. Use .colors(NavigationItemColors) on a destination to override selected and unselected icon and label colors, disabled icon and label colors, or the selected indicator. The selected label tint can differ for Top and Start positions. Item overrides take precedence, and omitted values use the bar fallback or the window theme. Disabled colors take precedence over selected colors for the label and icon.

Pass a caller-owned Entity<InteractionSource> to each observed item with .interaction_source(&source). Read its state under ElementId::from((collection_id, destination_id)), where the collection ID is an ElementId and the destination ID is a SharedString. Removed items release their state. The bar retains one tab stop, skips disabled destinations, and mirrors left and right arrow movement in right-to-left windows. Home and End move to the first and last enabled items. Pointer, keyboard, and accessibility activation report a destination through NavigationItems::on_select; the caller commits it through .selected(id).

Use NavigationRail::new(id, items) with controlled NavigationItems. The default collapsed rail is 96 logical pixels wide. .mode(RailMode::Expanded) defaults to 240, and .expanded_width(width) accepts 220–360 logical pixels. RailMode::Hidden releases the layout space. Width fits the window, and the logical start edge and Start icons follow RTL.

Attach .state(&state) with a retained Entity<NavigationRailState> initialized to a RailMode. Observe current_value(), target_value(), is_animating(), and progress(). Use expand(cx), collapse(cx), toggle(cx), hide(cx), or animate_to(mode, cx). Retargeting starts at the displayed width. snap_to(mode, cx) and reduced motion settle immediately. Configure the default 240 ms transition on the state with .transition_duration(...).

Use .header(element), .fab(element), or .destination_content(|mode| ...) for caller-supplied content. The custom destination region owns its names, selection and keyboard behavior. With the standard collection, use .divider_after(destination_id, element), NavigationItem::label_content, and NavigationItem::badge for scoped content and named badge descriptions. Arrow keys move focus through enabled destinations. .icon_position(...) overrides Top or Start. .indicator_padding(collapsed, expanded) applies logical NavigationRailPadding within the indicator while preserving the destination’s interaction target.

.arrangement(NavigationRailArrangement) distributes the standard destinations over spare vertical space. Use .destination_spacing(...), .content_padding(...), .header_spacing(...), and .expanded_header_top_padding(...) for logical insets and gaps. .shapes(NavigationRailShapes) overrides collapsed, expanded, and modal shapes. .colors(NavigationRailColors) supplies normal and modal container and content colors, plus the scrim color and opacity.

Use .modal(&dialog) with a retained DialogState to overlay an expanded rail through the side-sheet session. The docked mode remains available after dismissal. .modal_options(RailModalOptions) configures Escape and outside dismissal, layer, placement, detached margins, and hiding a collapsed rail. .on_dismiss_request(...) can veto a user dismissal. .on_modal_close(...) receives the accepted close reason once. The modal holds focus, blocks background pointer and scroll input, and restores its entry focus while it still owns focus.

Bottom app bar

BottomAppBar::new(id) provides an 80 dp Material 3 bottom bar (SurfaceContainer, Elevation::Level2) that mounts directly in Scaffold::bottom_bar(...) or standalone layouts. Add up to four leading actions with .action(element) or .actions(iter) and place an embedded floating action button at the logical trailing end with .fab(element). Use .height(pixels), .padding(BottomAppBarPadding), .elevation(Elevation), .colors(BottomAppBarColors), and .accessible_label(label) (landmark Role::Toolbar) to customize geometry and appearance. Attach .scroll_behavior(AppBarScrollBehavior, &state) (and optional .track_scroll(&handle)) to reuse AppBarScrollState for hide-on-scroll behavior (EnterAlways, ExitUntilCollapsed, or Pinned). Layout and logical padding mirror in RTL.

NavigationDrawer::new(id, items) renders a standalone Material 3 navigation drawer defaulting to 360 dp wide (configurable via .width(pixels)). Use .mode(NavigationDrawerMode::Standard) for a docked SurfaceContainerLow panel or .mode(NavigationDrawerMode::Modal) with .modal_state(&dialog_state) to present the drawer through a modal Sheet (SheetEdge::Start) with scrim, focus trap, Escape/outside dismissal, .modal_properties, .on_dismiss_request, .on_closed, and focus restoration. Organize destinations using NavigationItems, .section(header, items), .entries(...), .divider_before(item_id), .headline(text), .header(element), and .footer(element). Destinations render in a vertical scrollable list with 56 dp pill active indicators, trailing badges, single roving Tab stop (Up/Down, Home/End, Enter/Space), and RTL mirroring.

Stepper

Stepper::new(id, steps) displays horizontal (StepperOrientation::Horizontal, default) or vertical (StepperOrientation::Vertical) multi-step workflows from StepItem definitions. Set .active_step(index) to mark steps before the index as Completed, at the index as Active, and after the index as Upcoming unless overridden per step with StepItem::status(StepStatus). Each step supports .supporting(text), .icon(element), .editable(bool), and vertical .content(element) displayed beneath the active step. Provide .on_select(|index, window, cx| ...) to enable step navigation; linear steppers allow activating completed, active, error, or editable steps while .non_linear(true) allows selecting any enabled step. Steps expose status-inclusive accessible names, mirror in RTL, and use roving keyboard focus (Left/Right in horizontal, Up/Down in vertical, Home/End, Enter/Space).

Breadcrumbs::new(id, items) renders desktop path navigation (navigation feature, landmark Role::Navigation, default .accessible_label("Breadcrumb")) from caller-owned BreadcrumbItem entries (.icon(element), .disabled(bool)). Ancestor segments are keyboard-accessible buttons that report their item ID through .on_select(|id, window, cx| ...), while the trailing current segment is non-navigable and exposes current-page semantics. Separators default to Icon::new(IconName::ChevronRight).size(px(16.)).mirror_in_rtl(true) and can be customized with .separator(|| ...). Set .colors(BreadcrumbsColors) to override ancestor, current, separator, and disabled tints. When segments exceed .max_items(count) or the available width, middle segments collapse automatically into an anchored Material Menu triggered by an ellipsis (…) button while preserving the first segment and trailing/current segments; activating a collapsed item from the menu invokes the same .on_select callback. Segment order and separators mirror in RTL.

Vertical drag handle

Place VerticalDragHandle::new(id) on the boundary between two panes. Use .sizes(DragHandleSizes), .colors(DragHandleColors), and .shapes(DragHandleShapes) to override individual resting, pressed, and dragged values. The window theme supplies the Outline role for the 4 × 48 resting capsule and On Surface for the 12 × 52 pressed and dragged marks with Medium corners. Visual dimensions use logical pixels. The input target stays at least 48 × 48 and accommodates the largest configured mark in every state. Hover and keyboard focus add feedback while keeping their own interaction states.

Use .on_resize(label, width, min..=max, callback) to give the boundary a name, the current logical start pane width, bounds, and a handler for requested widths. The caller applies or rejects each request and determines the layout. Arrow keys move the focused splitter left or right, Home and End request the minimum and maximum widths, and .keyboard_step(px(...)) changes the default 8-pixel step. Accessibility exposes the vertical divider as a named, writable range control with the role description “splitter,” because the current bridge treats its native Splitter role as read-only. The numeric value is the start pane width. The window theme maps physical mouse and touch motion to logical widths in both LTR and RTL. Escape, focus loss, and pointer cancellation end the drag. The caller keeps the last accepted width.

Pass .interaction_source(&source) to observe hover, press, drag, and visible keyboard focus with a shared Entity<InteractionSource>. Use distinct IDs when observing multiple handles. Run cargo gallery vertical-drag-handle to try the split-pane example.

Scaffold

Scaffold::new(id, content) reserves the measured space occupied by the independent .app_bar, .rail, and .bottom_bar slots. The app owns those slots, the FAB and the snackbar host. Keep a stable ID and give the scaffold a bounded size. Use .content_insets(ScaffoldInsets { top, start, bottom, end }) for the minimum distance, in logical pixels, from each scaffold edge to the usable content. Each occupied edge counts toward that minimum. The normal constructor applies any remaining padding inside the content area.

Use Scaffold::with_layout(id, |layout, window, cx| ...) to receive the current layout before building content. ScaffoldContentLayout exposes the body bounds, measured occupied space, remaining padding, and text direction. Apply only padding to the content or a scroll child because the scaffold already reserved occupied. Use ScaffoldInsets::resolve(direction) to convert logical start and end to physical edges. The content builder runs during layout and receives the current measurements when a slot changes size or the window resizes.

Set .fab_position(ScaffoldFabPosition) to Start, Center, or End within the available content width. End is the default. These positions keep the FAB above the bottom bar and above the snackbar when the snackbar slot is present. EndOverlay places the FAB at the scaffold’s bottom edge over the bar, inside the requested bottom inset. The snackbar clears both the bottom bar and the FAB. Start and end mirror with the window direction. The FAB and snackbar are overlays, so they do not contribute to occupied content space.

Optional components

Core components are enabled by default through full. Disable default features on gpui-material (or gpui-material-components) to compile only the lightweight core (Text, Icon, IconName, Avatar, AvatarGroup, EmptyState, Skeleton, Badge, Divider, DisplayScrollbar, ControlSize, SemanticTone, MaterialElementExt, ScaffoldInsets, MenuSurfaceStyle, and init_components) plus the groups you enable:

Core feature Components Implied groups
actions Button, ButtonTone, ToggleButton, IconButton, IconToggleButton, Fab, ExtendedFab, button styles —
selection Checkbox, Radio, RadioGroup, Switch, Chip, ChipGroup, Slider —
inputs TextField, TextFieldState, TextAreaState, ExposedDropdown, ExposedDropdownState —
surfaces Card, DropTarget, List, ListItem, SwipeToDismiss, VerticalDragHandle (plus SwitchTile with selection and ChoiceTile with feedback) actions
feedback Banner, CircularProgress, LinearProgress, LoadingIndicator, PullToRefresh, Dialog, Sheet, BottomSheet*, Menu, Snackbar, SnackbarHost, Tooltip, Label actions
navigation AppBar, AppBarRow, AppBarColumn, BottomAppBar, Breadcrumbs, Tabs, NavigationBar, NavigationRail, NavigationDrawer, Stepper, AdaptiveNavigation, Scaffold, ListDetail, SupportingPane, Feed, AdaptivePane actions, feedback
full All core component groups above (default) All core groups

Enable optional component families on the gpui-material dependency. Each family activates only the core component groups it uses. Import date pickers, time pickers and scroll fields from gpui_material::date_time.

Feature Component Supported variants and behavior Material 3
expressive-groups ButtonGroup, SplitButton Standard and Connected button groups, and split buttons with independent content, appearance, and activation. Button groups · Split button
toolbars FabMenu, Toolbar FAB menus with controlled expansion, trigger and item slots, and horizontal alignment. Floating and docked toolbars with arbitrary controls, configurable appearance and scroll behavior. FAB menu · Toolbars
search SearchBar, SearchView Collapsed search bars and customizable Docked, Full-screen and Contained search views. Search
date-time DatePicker, TimePicker, TimePickerDialog, VibrantTimePickerDialog, TimePickerPanel, TimeScroll, ScrollField Single dates and date ranges in Docked, Modal, Modal Input, or responsive FullScreen pickers, with standalone panel and dialog composition. Dial, text input, and wrapping scroll time pickers with 12- and 24-hour formats. Standalone scrolling selection. Date pickers · Time pickers
carousel Carousel, CarouselParallax Multi-browse, Uncontained, Uncontained Multi-aspect Ratio, Hero, Centered Hero, and Full-screen. Standalone scroll parallax for arbitrary GPUI content. Carousel

Window chrome

Enable the optional window-chrome feature and import TitleBar, CaptionButtons, CaptionButtonLabels, ChromePlatform, TitleBarColors, CaptionButtonColors, title_bar_window_options, and title_bar_window_options_with_height from gpui_material::window_chrome across Windows, macOS, and Linux.

Pass title_bar_window_options(options) (or title_bar_window_options_with_height(options, height)) to MaterialRoot::open_window so GPUI renders into the title-bar area. The helper preserves the supplied window title, bounds, minimum size, and capability flags. On Windows and macOS it enables appears_transparent; on macOS it also computes a vertically centered default traffic_light_position when unset; on Linux it requests WindowDecorations::Client when window_decorations is unset.

Render TitleBar::new(id) at the top of the window view. By default it uses a 48 logical-pixel height, follows the window Material theme’s typography (TypeRole::TitleSmall and resolved theme font families), reads the live window title, and includes a drag region and platform-appropriate chrome:

Customize TitleBar with .height(px(...)), .title(text), .title_role(TypeRole), .title_font(Font), .title_font_family(name), .title_font_size(px(...)), .leading(element), .content(element), .trailing(element), .traffic_light_padding(px(...)), .colors(TitleBarColors), .caption_colors(CaptionButtonColors), .caption_labels(CaptionButtonLabels), .caption_button_width(px(...)), .show_caption_buttons(bool), .on_close(handler), and .platform(ChromePlatform). Use CaptionButtons::new(id) with .labels(CaptionButtonLabels) directly to place localized vector window control buttons in a custom layout. All caption buttons expose accessible names, keyboard activation, and AccessibleAction::Click. Windows title bar guidance

Enable the search feature and retain one Entity<SearchState> per search entry. Place SearchBar::new(id, label, &state) directly in a layout or in AppBar::search(...). Its default presentation is Docked. Use SearchViewVariant::FullScreen for an edge-to-edge editor or FullScreenContained for a full-window view with a contained editor. .widths(collapsed, focused) sets the trigger and focused editor widths in logical pixels. Without an override the trigger is sized to its content. .trigger_content(element) replaces the visible trigger label. .leading(element) and .trailing(element) add independent controls or an avatar beside the trigger. Pass .track_focus(&focus) on SearchBar to bind a caller-owned trigger handle, or call SearchState::trigger_focus() to access the retained default trigger handle.

.expanded_view(|view| ...) configures the same SearchView that can be composed directly. .input(|field| ...) gives the caller the retained editor’s TextField for custom content, leading and trailing actions, placeholder, prefix, suffix, colors, and interaction source. Include that field in the returned element to preserve editing, focus, IME and the search provider. Use SearchState::with_editor(...) to attach a caller-owned TextFieldState, or editor() to access the default entity.

.docked_size(width, height) defaults to 440 by 424 logical pixels and is clamped to the viewport. .result_gap(px(...)) separates the editor and result surfaces in Docked search. .popup_options(SearchPopupOptions) configures the logical anchor, gap below the trigger, dismissal and optional scrim for the docked popup. .window_options(SearchWindowOptions) sets logical insets, dismissal and scrim for the full-window presentation. These options configure a popup or overlay in the editor’s existing GPUI window. .style(SearchStyle) supplies independent trigger, container, content, divider, input, shape and elevation overrides. Omitted values retain the window defaults.

Provider requests carry a revision. Complete them with complete(&request, outcome, cx) and apply only accepted results. Search emits a separate submit or select event and the application owns navigation. Use .group(label) and .icon(IconName) on SearchResult for consecutively grouped result headers and leading icons. .result_row(|row, result, window, cx| ...) customizes each visible Material row. The generated list retains virtualization and navigates across the full model by stable IDs (Up/Down/Home/End, plus pressing Down from the search input to focus the first visible result). Use scroll_state() to access the current viewport or set_scroll_state(&scroll, cx) to attach a retained GPUI ListState. .filters(element) adds content above the provider results. Use .result_content(|state, window, cx| ...) to render a results region, results() to read the accepted outcome, and select_result(...) to select a custom row.

open and close settle immediately. Use animate_to(SearchValue, duration, window, cx) or snap_to(fraction, window, cx) for controlled transitions. progress(), current_value(), target_value(), and is_animating() report the displayed and requested state. Supply .motion(SearchMotion) to animate trigger activation and dismissal. Reduced motion settles at the requested endpoint. Dismissal restores the entry focus. Escape first honors active IME composition.

An app bar can use its existing scroll state and behavior with the search slot. For a standalone bar, attach .scroll_behavior(&state) with one retained SearchScrollState. Supply the content offset with set_content_offset, or link a viewport with .track_scroll(&handle). Enter-always scrolling hides the collapsed bar on forward movement and reveals it when scrolling reverses. The active search remains available while the content scrolls.

Button groups

ButtonGroup::new(id, name, items) uses stable item IDs and provides one Tab stop. Left and Right move focus without changing selection. Disabled members are skipped, and visual order and arrow keys follow the window direction. Use ButtonGroup::connected(id, name, items) or .variant(ButtonGroupVariant::Connected) to join consecutive members. Standard and Connected use a 12 and 2 logical pixel gap, respectively. .spacing(width) overrides the gap, .alignment(ButtonGroupAlignment) sets logical horizontal arrangement, and .vertical_alignment(ButtonGroupVerticalAlignment) defaults to Top. An item can set its own vertical alignment. Set .tone(SemanticTone) on ButtonGroup or per ButtonGroupItem to apply semantic palettes across both visible members and overflow MenuItem rows.

ButtonGroupItem::new(id, name) uses the group’s .selection(mode, selected_ids) and .on_change(...) when selection is enabled. For common single-choice controls, .single_select(selected, |id, window, cx| ...) configures ButtonGroupSelection::SingleRequired and passes the newly selected SharedString directly, while .single_optional_select(selected, |id, window, cx| ...) configures ButtonGroupSelection::Single and passes Option<SharedString>. Single and Multiple allow deselection. The Required modes keep the last selected member. The application applies requests and supplies the current selection. Use .action(callback) for a command in any group or .toggle(selected, callback) for a separately controlled toggle. .on_activate(...) supplies a command for groups in Actions mode.

Use .leading_icon(|| ...) for a labeled icon button, .icon_only(|| ...) for an icon in place of its label, or .content(width, || ...) for decorative content with a preferred logical width. The constructor’s name is used for accessibility and the default overflow row. .icon_width(IconButtonWidth) chooses the icon-only footprint. .appearance(ButtonVariant) and .style(ButtonGroupItemStyle) override the member preset, resting, pressed and checked shapes, colors, border, elevation and logical padding. .shape(ButtonShape::Square) switches the group from its default Round outer shape. .connected_shapes(ButtonGroupConnectedShapes) supplies state shapes for leading, middle, trailing or only segments. Individual shape fields take precedence.

.weight(weight) gives a member a proportional share of space remaining after unweighted members and minimum target widths. The default weight is zero. .expanded_ratio(ratio) defaults to 0.15 and applies to Standard button groups: a pressed member borrows width from its visible neighbors, while Connected groups keep neighbor widths fixed. .compression_limit(px(...)) sets how much width a member can lend, with a default floor of 24 logical pixels. When a labeled button is compressed narrower than its preferred width, it shrinks horizontal content padding first (down to 4 logical pixels per side, or a smaller caller-supplied padding) before ellipsizing the label. .interaction_source(&source) observes a visible member under ElementId::from((group_id, item_id)) and uses the same press state for width animation. Reduced motion applies the width targets immediately.

Members that do not fit use the overflow menu. Its rows preserve member names, availability, selected states and callbacks. .overflow_trigger(width, |open| ...) replaces the trigger’s visible content while .overflow_label(...) supplies its accessible name. .overflow_content(|| ...) adds decorative content before the generated menu rows. .overflow_item_content(|| ...) customizes a member’s overflow row. .overflow_open(open) makes the owner responsible for the displayed open value. Apply requests from .on_overflow_open_change(...) to update it. Omitting the open value lets the group handle menu visibility.

Split buttons

SplitButton::new(id, leading_name, trailing_name, menu_items) names the two segments for accessibility. The leading command uses .on_activate(...). Use .leading_icon(element) for an icon beside the label, .leading_icon_only(element) for an icon in place of the label, or .leading_content(element) for arbitrary content. The trailing segment defaults to a menu arrow. Use .trailing_icon(element) for an icon sized to its tier or .trailing_content(element) for arbitrary trailing content. Each segment uses its most recent content setter. Keep elements in these slots presentational so each segment owns its focus, name, and activation.

The trailing segment opens the supplied menu by default and restores trigger focus when the menu closes. Use .on_trailing_activate(callback) for an independent command or .trailing_toggle(selected, callback) for a controlled toggle. The last trailing action or toggle setter wins and takes the place of the constructor menu. Toggle activation requests the next value without changing the supplied selection. .disabled(true) disables the leading command. .trailing_disabled(true) disables the trailing segment independently. An empty menu disables the default menu trigger. The segments mirror in RTL. Keyboard traversal visits the leading segment before the trailing segment.

The Filled, Filled Tonal, Elevated, and Outlined presets provide the base appearance at each Material size. .tone(SemanticTone), .leading_tone(SemanticTone), and .trailing_tone(SemanticTone) apply semantic palettes to both segments or each segment independently. .spacing(width) sets the gap between segments. The default is 2 dp. Use .leading_style(SplitButtonSegmentStyle) and .trailing_style(SplitButtonSegmentStyle) to override logical resting, pressed, and checked corners with ButtonShapes, state pigments with ButtonColors, stroke with ButtonBorder, shadows with ButtonElevations, and logical insets with ButtonPadding. Omitted fields keep the segment defaults. A selected trailing toggle or open menu uses the checked appearance. The menu trigger retains button semantics. The default checked shape rounds the inner trailing corners. Checked colors fall back to the enabled colors, and disabled colors take precedence. Reduced motion applies the resulting shape immediately.

Pass caller-owned entities through .leading_interaction_source(&source) and .trailing_interaction_source(&source) to observe either segment. They report under ElementId::from((id, "primary")) and ElementId::from((id, "secondary")) respectively. The same entity can observe both keys. Replacing an attachment clears that segment’s snapshot from its previous source.

FAB menus

FabMenu::new(id, open_name, icon, items) retains its own expansion state by default. Use .expanded(expanded) when the caller owns the state and .on_expanded_change(|requested, window, cx| ...) to receive requests. The trigger requests the opposite value. Escape, an outside press, and item activation request false. An item invokes its command once even if the caller keeps the menu expanded. Focus moves to the first enabled item when expansion is applied and returns to the trigger after an accepted close if the menu still owns focus. .track_focus(&handle) uses the caller’s trigger focus handle.

.alignment(FabMenuAlignment) places the popup and aligns the item pills at logical Start, Center, or End. The default is End. Start and End mirror with the window’s text direction. Use .open_icon(element) and .close_icon(element) for custom icons or .open_content(element) and .close_content(element) for arbitrary decorative trigger content. The last content setter for each state takes precedence. The constructor name and .close_label(name) label the same accessible trigger in its collapsed and expanded states.

.trigger_style(FabMenuTriggerStyle) supplies FabMenuTriggerAppearance values for collapsed and expanded. Each endpoint can override size, logical shape, icon size, container color, content color, and elevation. Omitted fields use the selected FAB size and palette. The trigger interpolates between endpoints. Positive finite dimensions are capped by available space. Invalid dimensions use the defaults. Reduced motion applies the requested endpoint immediately. Keep the trigger slots decorative so the button owns focus and activation.

Use FabMenuItem::new(id, name, icon) for a labeled action or FabMenuItem::custom(id, name, content) for an arbitrary presentation. .icon(element) replaces the icon and .content(element) replaces the visible label. The item’s accessible name remains the constructor name. .colors(FabMenuItemColors) overrides enabled and disabled container and content colors. .disabled(true) keeps the item visible and skips it during activation and keyboard movement.

Control trigger visibility independently with .visible(visible) and configure scale, alpha, and logical pivot with .visibility_animation(FabVisibilityAnimation). Hiding immediately removes the trigger and menu actions from focus navigation and accessibility. It releases the trigger’s layout space after the fade. A controlled .expanded(true) takes effect again when the trigger becomes visible.

Toolbars

Toolbar::new(id, name, actions) defaults to a horizontal floating bar in the Standard palette. Construct items with ToolbarAction::new(id, label, IconName) or ToolbarAction::with_icon(id, label, || ...) for custom icons; both inline buttons and collapsed overflow MenuItems render the action’s icon. .content(element) inserts arbitrary content before the generated actions, including an editable text field. .leading_content(element) and .trailing_content(element) add slots before and after that region. They follow .expanded(expanded) and content scrolling unless .leading_expanded(bool) or .trailing_expanded(bool) specifies an independent value. A focused slot stays mounted until its control loses focus. Embedded controls own their input and keyboard behavior. Generated actions retain their directional focus navigation, and secondary actions that collapse move into the labeled overflow menu.

Choose .placement(ToolbarPlacement::Docked) for a docked strip. .arrangement(ToolbarArrangement) supplies logical Start, Center, End, SpaceBetween, SpaceAround, or SpaceEvenly when a horizontal docked strip has free space. .spacing(pixels) sets its minimum spacing and defaults to 4 dp. Choose .expanded_height(pixels) for a fixed expanded height on a horizontal docked strip. Without those overrides, the bar uses its existing layout. Horizontal order and logical padding mirror in RTL. Vertical slots retain top-to-bottom order. Give the toolbar a bounded main-axis size so it can scroll to a focused control when the available space shrinks.

Use .padding(ToolbarPadding { top, start, bottom, end }), .shape(CornerShape), .colors(ToolbarColors), and .elevations(ToolbarElevations) for instance appearance. Floating bars keep their rounded default and docked bars keep their square default. Toolbar colors control the surface, inherited content tint, and selected action pigments. Elevation follows expansion and defaults to zero. .fab(...) places an independently named and focused FAB beside a floating bar. .fab_color(FabColor) and .fab_colors(ButtonColors) configure that FAB separately. .fab_content(position, element) uses an independently authored control in the same slot. A docked bar takes primary actions through its content or action list.

Attach .track_scroll(&handle) to use a scrolling view’s vertical offset or .scroll_state(&state) with a retained Entity<ToolbarScrollState> and call set_content_offset(offset, cx). The handle takes precedence when both are set. Supply a positive logical-pixel distance from the content’s top. .scroll_behavior(ToolbarScrollBehavior) configures expansion and collapse thresholds, which default to 40 dp from the last direction change. With exit_direction set, forward scrolling slides the strip toward logical Start, End, Top, or Bottom, and reverse scrolling brings it back. The strip keeps its layout footprint, detaches its controls at the hidden endpoint, and remains exposed while a descendant has focus. The adjacent FAB stays available. Without an exit direction, scrolling changes expansion only.

Read content_offset(), offset(), offset_limit(), and collapsed_fraction() from the retained state. offset() is the nonnegative travel toward the chosen edge. set_collapsed_fraction(fraction, cx) applies a position immediately. Call settle(velocity, cx) when an application-owned gesture ends. Positive velocity moves toward exit. The fling configuration projects that velocity over its duration and chooses the nearest endpoint. Use snap_motion and ToolbarFling::motion to set endpoint motion. New scroll input interrupts settling from the displayed position. .transition_motion(MotionSpec) controls expandable slots and elevation. Reduced motion applies the target state immediately.

Date pickers

Retain one Entity<DatePickerState> per picker. DatePicker::new(id, label, &state, value) supplies an opening control (disable it with .disabled(true), and read its default focus handle via DatePickerState::trigger_focus()). The application owns the committed DateSelection. Each open initializes the draft from the current value. A complete docked selection commits immediately and a modal commits after validation and confirmation. DatePickerVariant::FullScreen fills the content area in compact windows and uses the basic dialog at wider sizes. ModalInput opens with retained text editors.

Use DatePicker::panel(id, label, &state) to embed a calendar or editor in another layout. Control its initial draft and mode on the retained state. DatePicker::dialog(id, label, &state, value) renders the modal portion for a caller-owned trigger. Open it with state.open(value, variant, &locale, window, cx). Call close(window, cx) for programmatic closure. .focus_target(&focus) selects the initial control for the built-in trigger. The default focuses the calendar or the first editor. A caller-owned trigger can focus a control after opening.

Set .initial_month(date), .date_bounds(range), .disabled_dates(predicate), and .disabled_years(predicate) when building state. The month display normalizes to the first of the month and stays within bounds. Disabled years remain visible in calendar navigation with unavailable dates and cannot be chosen in the year list. Read or set the displayed month with displayed_month() and set_displayed_month(date, cx). Read draft(cx) and change it with set_draft(DatePickerDraft, window, cx). A range draft may have a start date before its end is chosen. Call selection() on the draft to read a complete candidate value. The setter rejects invalid or disabled endpoints. display_mode() and set_display_mode(mode, window, cx) switch between Calendar and Input. Use .show_mode_toggle(false) to omit the toggle. input_editors(cx) returns the retained start editor and an end editor for a range.

Use .docked_anchor(|field| ...) for a customizable anchored TextField. Include the supplied field to retain the Base editor, its accessibility and calendar trigger. Its trailing action opens the calendar. Enter accepts a valid typed value after IME composition has finished. In a range field, separate endpoints with “ – ”. DatePickerLocale formats and parses input and localizes the first weekday and calendar labels. .accessible_date_format(|date| ...) customizes the spoken day and selection labels independently of the editable date format.

Set .title_content and .headline_content to replace the visible title and selection readout. The named opener and calendar status keep their accessible descriptions. Use .confirm_content(|confirm| ...) and .dismiss_content(|dismiss| ...) to supply modal actions and connect their activation to the provided DialogAction. The confirmation action validates the current draft and keeps an incomplete or invalid picker open. .properties(DialogProperties) controls Escape and outside dismissal. .on_dismiss_request can reject Escape and outside dismissal, and .on_close reports the accepted reason once. Programmatic closure updates last_close_reason(cx). Set .colors(DatePickerColors) for the container, title, headline, navigation, year/day states and input editor.

Time pickers

TimePicker::new(id, label, &state, value) shows a trigger that opens the standard dialog and initializes a fresh minute-precision draft from the application’s committed value. It defaults to Dial, 24-hour format, and automatic layout. Use .variant(TimePickerVariant::Input) or .variant(TimePickerVariant::Scroll) to choose the starting mode, .format(TimeFormat::TwelveHour) for AM/PM, .disabled(bool) to disable the trigger, .show_mode_toggle(bool), .colors(DialogColors), .properties(DialogProperties), .on_dismiss_request(...), .on_close(...), and .on_confirm(...) to configure dialog behavior and apply the confirmed draft in the application. Read the trigger focus handle via TimePickerState::trigger_focus(). Dial supports automatic, horizontal, and vertical layout. The clock face stays clockwise in both window directions, while field order mirrors with direction.

Create one Entity<TimePickerState> with cx.new(|cx| TimePickerState::new(window, cx)) for each picker. To compose a standalone picker, mount TimePickerPanel::new(id, &state) for the mode in state, TimePickerPanel::dial(id, &state) or TimePickerPanel::input(id, &state) for a fixed panel, or TimeScroll::new(id, &state) for two vibrant scrolling fields. Mount one panel for each retained state. Use .layout(...) for a dial and .mode_toggle_content(...) to place a control beside standalone inputs or wheels. The scroll fields wrap each hour or minute independently. Each field has its own accessible name, current value, focus, and arrow keys. The draft reads a scroll selection after its wheel settles. Reduced motion settles it immediately.

Read the last valid value(), hour() (0–23), minute() (0–59), segment(), mode(), and format() from the entity. Use set_value, set_hour, or set_minute for external edits. An out-of-range number is rejected and the editable value is left as is. Use set_segment, set_mode, set_format, and set_locale to change the presentation or active field. TimePickerLocale accepts number format and parse hooks, a separator, field and period names, and a validation message. During text entry, hour_input(cx) and minute_input(cx) can contain incomplete values. Use set_hour_input and set_minute_input to supply raw localized text externally. Each valid edit updates its part of the draft. Read is_pm() for the current period and is_hour_input_valid(cx), is_minute_input_valid(cx), or is_input_valid(cx) for validation. Entering another mode restores valid text from the draft. While an input method has marked text, confirmation and mode changes wait for the composition to finish. An Escape handled by the picker ends that composition first and keeps the dialog open.

For application-owned triggers, mount TimePickerDialog::new(id, title, &state) or VibrantTimePickerDialog::new(id, name, &state) and call state.open(value, window, cx) from the trigger. The vibrant dialog uses the surface container and large rounded corners. Its name is announced even when the title is visually hidden. Both use the retained mode and supply matching picker panels by default. Match the retained mode to a fixed panel supplied through .body(...) so focus and validation follow that panel. Use .body(...) for custom controls, .title_content(...) to replace the visible title, and .mode_toggle_content(|action| ...) to replace the mode control. Call the supplied action’s activate(window, cx) to switch mode and transfer focus. .show_mode_toggle(false) and .show_dismiss(false) omit their default controls. Use .confirm_content(|action| ...) and .dismiss_content(|action| ...) to wire custom controls to the same dialog actions. .properties(...) configures Escape and outside-click dismissal. .on_dismiss_request(...) can veto those requests, and .on_close(...) receives the accepted user close reason once. Cancel, Escape, and outside click do not confirm. Invalid input keeps the dialog open, marks the invalid field, and focuses the first invalid field on confirmation. Accepted close restores prior focus through the Material dialog. Programmatic state.close(window, cx) closes without a user close callback.

Use .style(TimePickerStyle) on pickers, panels, or dialogs to override time-field and period-selector shapes, the panel and clock colors, the clock hand and labels, selected and unselected time and period colors, the period outline, outlined text field colors, and wheel colors. Unset colors and shapes use the preset and the current window theme. Use .shape(...) and .colors(DialogColors) on the dialog to override its shell separately.

Scroll fields

Create one Entity<ScrollFieldState> per field with cx.new(|cx| ScrollFieldState::new(item_count, index, cx)) and pass it to ScrollField::new(id, name, &state). Call selected_option() to read the option closest to the center, target_option() for the destination, and is_scroll_in_progress() while scrolling or settling. Observe the entity to update other views. scroll_to_option(index, cx) moves immediately and animate_scroll_to_option(index, cx) follows the window’s motion scheme and system reduced motion. Both clamp an out-of-range index. set_item_count(count, cx) adjusts the available options and clamps the destination. A count of zero leaves the field empty with no selected or target option.

The field centers the current option within a three-row viewport. Click a row or use the wheel, touchpad, Up and Down keys, or accessibility actions to change the selection. The wheel wraps from the last item to the first and back. Pass .item_content(|index, selected, enabled| ...) to render a decorative GPUI element for a row. The default content pads the index to at least two digits. The constructor’s name labels the field, and .value_description(|index| ...) describes the destination for assistive technology while the field scrolls and the centered option at rest. Give the field a name that describes its purpose and bounds where useful.

Use .colors(ScrollFieldColors) to override the container, option, and selected option colors for enabled and disabled states. The default palette uses SurfaceContainerLowest, Outline, and OnSurface. .disabled(true) settles an active user scroll and prevents further user changes. The caller can still position the field through its state. Attach a caller-owned InteractionSource with .interaction_source(&source) to observe the field’s interaction presentation independently of its selection.

Carousels

Use Carousel::new(id, label, items) with stable, unique item IDs. Create an optional Entity<CarouselState> with cx.new(|_| CarouselState::new(initial_index)) and attach it with .state(&state). Observe the entity to read current_item(), current_item_id(), and the signed current_item_offset_fraction() from the nearest item. The position follows the target ID when items move and falls back to its clamped former index if the target is removed. The initial index and requests made while empty take effect when items arrive. Use scroll_to_item(index, cx) to jump or animate_scroll_to_item(index, cx) to follow the window motion policy. Both clamp to the available indices. Use one state per carousel. Without an attached state the carousel retains its position under its element ID.

Set .alignment(CarouselAlignment::Start) or .alignment(CarouselAlignment::Center) for Multi-browse, Hero, and Centered Hero. Centered Hero defaults to the center and the other contained layouts to the leading edge. All six layouts support .item_spacing(px(...)) and .content_padding(CarouselPadding { start, end, top, bottom }). Start and end are logical edges. Horizontal layouts default to 8 px spacing, 16 px leading padding, and 8 px cross-axis padding. Contained layouts also have 16 px trailing padding. Full-screen defaults to 16 px spacing and zero padding. .small_item_widths(min, max) sets positive bounds for small keylines, which default to 40–56 px. A narrow viewport can reduce the layout to one focal item.

.user_scroll_enabled(false) turns off wheel, trackpad, keyboard navigation, and accessibility scrolling. Item activation and programmatic navigation remain available. By default the contained layouts and Full-screen snap to the nearest keyline. Uncontained layouts scroll freely unless .snap_scrolling(true) is set. .fling_behavior(...) chooses free scrolling, nearest snapping, single-item advance, or a custom resting item computed from CarouselFlingContext. Line-wheel detents and accessibility scroll commands request discrete items. Animated positioning and snapping honor reduced motion.

Wrap arbitrary content in CarouselParallax::new(content) inside a scrollable layout. The effect uses the current GPUI clip bounds as the viewport, or window-coordinate bounds passed to .viewport(bounds). Use .axis(Axis::Vertical) for a vertical layout. As the item enters or exits, the effect progressively clips and translates its content without changing its layout size. Reduced motion keeps the viewport clip and skips the additional parallax translation. Use .shape(CornerShape) and .border(CarouselBorder) for matching corner geometry and a border. GPUI clips content to rectangular bounds. Rounded corners are covered with the Material Surface color or an opaque .backdrop(color). Match this color to a uniform parent background. Use square corners to keep patterned or transparent backgrounds visible.

Close