RavenRS · Rust GUI
Chat
Edit and run the Chat RavenRS example in your browser. Explore its Rust code and download a Cargo project for desktop and WebAssembly.
One declarative Rust interface, GPU rendering, reactive state and semantic design tokens. Free and open source under MIT OR Apache-2.0.
Rust source
fn chat() -> impl View {
/// Keeps the messages, here while the page rebuilds. A real app keeps them in its state.
struct Conversation;
impl View for Conversation {
fn build(&self, cx: &mut BuildCx<'_>) -> NodeId {
let messages = cx.use_state(Vec::<ChatMessage>::new);
let answers = messages.clone();
let chat = Chat::new(messages.binding())
.placeholder("Ask something")
.intro("It does not know who answers: yours adds to the messages, now or later.")
.examples(["How do I start?", "Where are my files?"])
.on_send(move |text| {
// Marks, links and a file in the bubble are asked for message by message.
let reply = ChatMessage::assistant(format!("*You asked:* {text}"))
.formatted()
.media(ChatMedia::document("answer.pdf").size(48_000).on_open(|| {}))
.card(|| Box::new(Button::new("Open it").size(ButtonSize::Small)));
answers.update(|all| all.push(reply));
});
cx.child(&VStack::new((chat,)).height(380.0).width(420.0))
}
}
Conversation
}The interactive preview loads when JavaScript and WebGPU or WebGL2 are available. You can read the guide and examples here at any time.
More examples
AccordionAlertAnchorAppShellAreaChartAspectRatioAttachmentStripAudioPlayerButtonAvatarBadgeBarChartBarcodeBreadcrumbButtonButtonGroupCalendarCanvasCardCardViewCarouselChartChartCardChartReferenceChatCheckboxCodeBlockCodeEditorCollapseColorPairColorPickerColorSwatchColorWheelComboboxCommandPaletteCompareViewConfirmDialogContextMenuCountUpCropOverlayCurveEditorDataGridDatePickerDateRangePickerDateTimePickerDaySeparatorDialogDisclosureDividerDockAreaDocumentTabsDotDropdownMenuDropZoneEmptyStateEventCalendarExpressionEditorEyedropperFavoriteToggleFileBrowserFileUploadFilmstripFilterBuilderFloatingPanelFloatingToolbarFooterFormFieldFormLayoutGlassCardGridHelpTipHeroBannerHistogramHoverCardHStackIconIconButtonIconTileImageImageFieldImageLightboxInlineRenameInputOtpKbdLabelLinkListLookupFieldLottieMarqueeMaskedFieldMenubarMinimapModelPickerMovieAssistantMoviePlayerMultiProgressNinePointAnchorNumberFieldOverlayBadgePagedDocumentViewPageHeaderPaginationPlaygroundPopoverProgressBarPropertyRowProtractorQuadFieldRadioGroupRatingRecurrenceEditorReleaseNotesRibbonRichTextRubberBandRuleOfThirdsGridRulerSankeyChartSchedulerScrollEdgeArrowScrollLinkedScrollSceneScrollViewSectionSegmentedControlSelectSelectionBarSheetShimmerTextShortcutHintBarShortcutSheetSidebarSidebarBrandSkeletonSliderSortableListSpacerSpinnerSplashScreenSplitButtonSplitHandleSplitPanesSplitterStatStatusBarStepBadgeStepIndicatorStepperStickySwatchGridTableTabsTagBoxTextTextAreaTextFieldThemeEditorThemePickerThemeSwitcherTickerTileLayoutTimelineTimePickerTitleBarToasterToggleToggleButtonToggleGroupToolbarToolRailTooltipTransformHandlesTreeViewValueSliderVirtualListVStackWizardYearViewZoomControlZoomPanViewZStack