arc-ui 0.4.0

Physics-first native Rust desktop UI component library & charts for GPUI (120+ interactive components ported from Arc).
Documentation
//! Ported from Arc (MIT) © 2026 Elia Kuratli
//! Overlay components (`tooltip`, later `popover`, menus, dialogs).
//!
//! Arc puts every float in a portal; GPUI needs a window-level layer for that. [`ArcOverlay`] is a
//! `gpui_kit::base::Root` plugin that owns all floats and is installed once per application with
//! [`install`]. Triggers look it up through the window root, so any component can request a float
//! without owning one.

pub mod bottom_sheet;
pub mod context_menu;
pub mod dialog;
pub mod drawer;
pub mod dropdown_menu;
pub mod folder_float;
pub mod hover_card;
pub mod popover;
pub mod tooltip;
pub mod user_menu;

pub use bottom_sheet::{
    BottomSheet, SHEET_CLOSED_GAP, SHEET_EXTENSION, SHEET_FLICK_VELOCITY, SHEET_LOW_DIM,
    SHEET_MAX_WIDTH, SHEET_PROJECTION_SECS, SHEET_STRETCH_LIMIT, SheetStop, normalize_detents,
    resolve_sheet_release, sheet_backdrop_dim, sheet_rubber, sheet_stop_offset, sheet_unrubber,
};
pub use context_menu::{ContextMenu, ContextMenuItem};
pub use dialog::{
    ArcDialog, DIALOG_MAX_WIDTH, DIALOG_VIEWPORT_MARGIN, dialog_card_y_offset, swap_text_sample,
};
pub use drawer::{
    DRAWER_CONTAINED_WIDTH, DRAWER_FLING_VELOCITY, DRAWER_INNER_RADIUS, DRAWER_MAX_VERTICAL_SIZE,
    DRAWER_WIDTH, Drawer, DrawerSide, drawer_exit_opacity, drawer_pan_offset,
    drawer_should_dismiss,
};
pub use dropdown_menu::{DropdownItem, DropdownMenu};
pub use hover_card::{
    ArcHoverCard, HoverCardAlign, HoverCardProfile, HoverCardSide, HoverCardStat,
};
pub use popover::{ArcPopover, PopoverSide};
pub use tooltip::{ArcOverlay, ArcTooltip, TooltipMachine, TooltipSide, TooltipVisual};
pub use user_menu::{
    ThemePreference, UserMenu, UserMenuAlign, UserMenuItem, UserMenuUser, UserStatus,
};

use gpui_kit::{App, Context, Window, base::Root};

/// Registers the Arc overlay layer on every window opened afterwards.
///
/// Call once at startup, before opening windows (the gallery does this in `main`).
pub fn install(cx: &mut App) {
    Root::register_plugin::<ArcOverlay>(cx, ArcOverlay::new);
}

/// Looks up the registered overlay layer for the given window.
pub fn overlay_for(window: &Window, cx: &App) -> Option<gpui_kit::Entity<ArcOverlay>> {
    window
        .root::<Root>()
        .flatten()?
        .read(cx)
        .plugin::<ArcOverlay>()
}

/// Convenience for triggers: runs `f` against this window's overlay layer.
pub fn with_overlay(
    window: &mut Window,
    cx: &mut App,
    f: impl FnOnce(&mut ArcOverlay, &mut Context<ArcOverlay>),
) {
    let Some(overlay) = overlay_for(window, cx) else {
        return;
    };
    overlay.update(cx, f);
}