cosmic

Module widget

source
Expand description

The COSMIC widget library

This module contains a wide variety of widgets used throughout the COSMIC app ecosystem.

§Overview

Add widgets to your application view by calling the modules and functions below. Widgets are constructed by chaining their property methods using a functional paradigm. Modules may contain additional functions for constructing different variations of a widget. Each module will typically have one widget with the same name as the module, which will be re-exported here.

use cosmic::prelude::*;
use cosmic::{cosmic_theme, theme, widget};

const REPOSITORY: &str = "https://github.com/pop-os/libcosmic";

let cosmic_theme::Spacing { space_xxs, .. } = theme::active().cosmic().spacing;

let link = widget::button::link(REPOSITORY)
    .on_press(Message::LaunchUrl(REPOSITORY))
    .padding(0);

let content = widget::column()
    .push(widget::icon::from_name("my-app-icon"))
    .push(widget::text::title3("My App Name"))
    .push(link)
    .align_items(Alignment::Center)
    .spacing(space_xxs);

Widgets may borrow data from your application struct, and should do so to avoid allocating.

let text = widget::text::body(&self.cached_text);

Use the cosmic::Apply trait to embed widgets into other widgets which accept them.

let button = widget::icon::from_name("printer-symbolic")
    .apply(widget::button::icon)
    .on_press(Message::Print);

Modules§

  • A container which constraints itself to a specific aspect ratio.
  • Button widgets for COSMIC applications.
  • A widget that displays an interactive calendar.
  • Canvases can be leveraged to draw interactive 2D graphics.
  • Checkboxes can be used to let users make binary choices.
  • Widgets for selecting colors with a color picker.
  • A container which aligns its children in a column.
  • Combo boxes display a dropdown list of searchable and selectable options.
  • Containers let you align a widget inside their boundaries.
  • An overlayed widget that attaches a toggleable context drawer to the view.
  • A context menu is a menu in a graphical user interface that appears upon user interaction, such as a right-click mouse operation.
  • An element to distinguish a boundary between two elements.
  • Displays a list of options in a popover menu on select.
  • Responsively generates rows of widgets based on the dimensions of its children.
  • Arrange widgets with a grid layout.
  • Lazily-generated SVG icon widget for Iced.
  • Images display raster graphics in different formats (PNG, JPG, etc.).
  • A MenuBar widget for displaying [MenuTree]s
  • Navigation side panel for switching between views.
  • A button for toggling the navigation side panel.
  • Pane grids let your users split regions of your application and organize layout dynamically.
  • A widget showing a popup in an overlay positioned relative to another widget.
  • Progress bars visualize the progression of an extended computer operation, such as a download, file transfer, or installation.
  • Create choices using radio buttons.
  • A container which aligns its children in a row.
  • A widget providing a conjoined set of linear items that function in conjunction as a single button.
  • A selection of multiple choices appearing as a conjoined button.
  • Sliders let users set a value by moving an indicator.
  • A control for incremental adjustments of a value.
  • Svg widgets display vector graphics in your application.
  • A collection of tabs for developing a tabbed interface.
  • Text editors display a multi-line text input for text editing.
  • A text input widget from iced widgets plus some added details.
  • A widget that displays toasts.
  • Sliders let users set a value by moving an indicator.

Structs§

Traits§

  • A piece of logic that can traverse the widget tree of an application in order to query or update some widget state.
  • A component that displays information and allows interaction.

Functions§

Type Aliases§