Skip to main content

herogpui_components/
lib.rs

1//! HeroGPUI components — a faithful Rust/GPUI port of the HeroUI v3 component
2//! library. One module per `@heroui/*` package.
3//!
4//! Every component and builder type is `#[must_use]`: a builder that is built
5//! and then dropped renders nothing, so the compiler says so.
6//!
7//! ```compile_fail
8//! #![deny(unused_must_use)]
9//! # use herogpui_components::Button;
10//! # fn render() {
11//! Button::new("save").label("Save"); // dropped: `unused_must_use` fires
12//! # }
13//! ```
14//!
15//! The same statement, used:
16//!
17//! ```
18//! #![deny(unused_must_use)]
19//! # use herogpui_components::Button;
20//! # fn render() -> Button {
21//! Button::new("save").label("Save")
22//! # }
23//! ```
24#![allow(clippy::type_complexity)]
25// Every public item is documented; `clippy -D warnings` keeps it that way.
26#![warn(missing_docs)]
27
28pub mod a11y;
29pub mod accordion;
30pub mod alert;
31pub mod alert_dialog;
32// Reached by path (`herogpui::anim::…`); not re-exported at the root.
33pub mod anim;
34pub mod assets;
35pub mod autocomplete;
36pub mod avatar;
37pub mod avatar_group;
38pub mod badge;
39pub mod breadcrumbs;
40pub mod button;
41pub mod button_group;
42pub mod calendar;
43mod calendar_keys;
44pub mod calendar_system;
45pub mod calendar_view;
46pub mod card;
47pub mod checkbox;
48pub mod chip;
49pub mod close_button;
50pub mod color_picker;
51pub mod combo_box;
52pub mod command_palette;
53pub mod context_menu;
54pub mod date_constraints;
55pub mod date_picker;
56pub mod disclosure;
57pub mod drawer;
58pub mod dropdown;
59pub mod field;
60pub mod filter;
61pub mod form;
62#[cfg(feature = "gallery-source")]
63pub mod gallery_source;
64pub mod hover_card;
65pub mod i18n;
66pub mod icon;
67pub mod icons;
68pub mod input;
69pub mod input_group;
70pub mod input_otp;
71pub mod kbd;
72pub mod link;
73pub mod list_box;
74pub mod list_nav;
75mod matches;
76pub mod menu_bar;
77pub mod meter;
78pub mod modal;
79pub mod number_field;
80pub mod pagination;
81pub mod picker_item;
82pub mod popover;
83pub mod progress;
84pub mod radio_group;
85pub mod range_calendar;
86pub mod resizable;
87pub mod scroll_shadow;
88pub mod scrollbar;
89pub mod select;
90pub mod selection;
91pub mod separator;
92pub mod sidebar;
93pub mod skeleton;
94pub mod slider;
95pub mod spinner;
96pub mod surface;
97pub mod switch;
98mod system_locale;
99pub mod table;
100pub mod tabs;
101pub mod tag_group;
102pub mod textarea;
103pub mod time_field;
104pub mod title_bar;
105pub mod toast;
106pub mod toggle_button;
107pub mod toolbar;
108pub mod tooltip;
109pub mod traits;
110pub mod tree_view;
111pub mod typography;
112pub(crate) mod util;
113pub mod validation;
114pub mod virtual_list;
115
116// The shared v3 prop vocabularies, re-exported so `herogpui::components::*`
117// is enough to build a UI.
118pub use herogpui_core::{
119    Backdrop, Color, FieldVariant, Orientation, Placement, PlacementAlign, Prominence,
120    SelectionBehavior, SelectionMode, Size, SizeXl, Variant,
121};
122
123pub use accordion::*;
124pub use alert::*;
125pub use alert_dialog::*;
126pub use assets::*;
127pub use autocomplete::*;
128pub use avatar::*;
129pub use avatar_group::*;
130pub use badge::*;
131pub use breadcrumbs::*;
132pub use button::*;
133pub use button_group::*;
134pub use calendar::*;
135pub use calendar_view::*;
136pub use card::*;
137pub use checkbox::*;
138pub use chip::*;
139pub use close_button::*;
140pub use color_picker::*;
141pub use combo_box::*;
142pub use command_palette::*;
143pub use context_menu::*;
144pub use date_constraints::*;
145pub use date_picker::*;
146pub use disclosure::*;
147pub use drawer::*;
148pub use dropdown::*;
149pub use field::*;
150pub use filter::*;
151pub use form::*;
152pub use hover_card::*;
153
154/// `formatOptions` for the components that take it, re-exported so a caller
155/// reaches it beside the component it configures.
156pub use herogpui_core::{CurrencySign, NumberFormat, NumberStyle, UnitDisplay};
157pub use icon::*;
158pub use icons::*;
159pub use input::*;
160pub use input_group::*;
161pub use input_otp::*;
162pub use kbd::*;
163pub use link::*;
164pub use list_box::*;
165pub use menu_bar::*;
166pub use meter::*;
167pub use modal::*;
168pub use number_field::*;
169pub use pagination::*;
170pub use picker_item::*;
171pub use popover::*;
172pub use progress::*;
173pub use radio_group::*;
174pub use range_calendar::*;
175pub use resizable::*;
176pub use scroll_shadow::*;
177pub use scrollbar::*;
178pub use select::*;
179pub use selection::*;
180pub use separator::*;
181pub use sidebar::*;
182pub use skeleton::*;
183pub use slider::*;
184pub use spinner::*;
185pub use surface::*;
186pub use switch::*;
187pub use table::*;
188pub use tabs::*;
189pub use tag_group::*;
190pub use textarea::*;
191pub use time_field::*;
192pub use title_bar::*;
193pub use toast::*;
194pub use toggle_button::*;
195pub use toolbar::*;
196pub use tooltip::*;
197pub use traits::{Disableable, Selectable, Sizable};
198pub use tree_view::*;
199pub use typography::*;
200pub use util::{app_focus_root, FieldFocus, InteractiveState, SelectionValue};
201pub use validation::*;
202pub use virtual_list::*;
203
204/// The helpers HeroGPUI supports for building custom widgets that match the
205/// components: v3's radius scale read from the active theme, the field
206/// metrics, the interactive cursor, the focus-visible modality, and the
207/// vanilla-GPUI workarounds the components themselves use.
208///
209/// Everything else the components share stays private to this crate, so its
210/// signatures can change without a breaking release.
211pub mod extend {
212    pub use crate::util::{
213        app_focus_root, container_radius, control_radius, cursor_interactive, field_radius,
214        focus_visible, hairline_radius, inner_fill_radius, interactive_cursor, key_radius,
215        mark_radius, micro_radius, set_focus_visible, shift_wheel_scroll_x, small_radius,
216        soft_radius, FIELD_HEIGHT, FIELD_ICON, FIELD_TEXT,
217    };
218}
219
220/// Overlay-stack primitives exercised by this crate's own behavior tests.
221/// Not public API: no semver guarantee, and it may change in any release.
222#[doc(hidden)]
223pub mod __private {
224    /// The system date/time locale chain the date and time fields read, so
225    /// the behavior tests can expect what the running machine's region says.
226    pub use crate::system_locale::time_locale_tags;
227    pub use crate::util::{
228        dismiss_on_press_outside_with_token, overlay_phase, overlay_scope, overlay_scope_with_exit,
229        DismissResult, OverlayPhase, OverlayToken,
230    };
231}