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§
- A generic button which emits a message when pressed.
- A widget capable of drawing 2D graphics.
- A box that can be checked.
- A widget for searching and selecting a single value from a list of options.
- A widget that aligns its contents inside of its boundaries.
- A context menu is a menu in a graphical user interface that appears upon user interaction, such as a right-click mouse operation.
- A widget for selecting a single value from a list of selections.
- Responsively generates rows and columns of widgets based on its dimensions.
- Responsively generates rows and columns of widgets based on its dimmensions.
- An image which may be an SVG or PNG.
- The identifier of a generic widget.
- An element decorating some content.
- A frame that displays an image while keeping aspect ratio.
- An element decorating some content.
- A widget that only rebuilds its contents when necessary.
- Emit messages on mouse events.
- A collection of panes distributed using either vertical or horizontal splits to completely fill the space available.
- A bar that displays progress.
- A circular button representing a choice.
- A widget that is aware of its dimensions.
- An horizontal bar and a handle that selects a single value from a range of values.
- An amount of empty space.
- A vector graphics image.
- A multi-line text input.
- A field that can be filled with text.
- Represent the data used to display a
Toast
- An vertical bar and a handle that selects a single value from a range of values.
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§
- A widget that displays an interactive calendar.
- Creates a new
Canvas
. - Creates a new
Checkbox
. - A container which aligns its children in a column.
- Creates a new
ComboBox
. - Creates a new
Container
with the provided content. - 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.
- Displays a list of options in a popover menu on select.
- A text label whiich can transform into a text input on activation.
- Responsively generates rows of widgets based on the dimensions of its children.
- Arrange widgets with a grid layout.
- Creates a new
Space
widget that fills the available horizontal space. - Creates a new
Image
. - Creates a new inline
TextInput
. - Creates a new
Lazy
widget with the given dataDependency
and a closure that can turn this data into a widget tree. - A container intercepting mouse events.
- Navigation side panel for switching between views.
- Navigation side panel for switching between views. Can receive drag and drop events.
- Creates a
PaneGrid
with the givenpane_grid::State
and view function. - Creates a new
ProgressBar
. - Creates a new
Responsive
widget with a closure that produces its contents. - A container which aligns its children in a row.
- Creates a new search
TextInput
. - Creates a new secure
TextInput
. - Creates a new
Slider
. - Horizontal spin button widget.
- Creates a new
Text
widget with the provided content. - Creates a new
TextEditor
. - Creates a new
TextInput
. - Create a new Toaster widget.
- Creates a new
VerticalSlider
. - Creates a new
Space
widget that fills the available vertical space. - Vertical spin button widget.
Type Aliases§
- Sets the distribution of space between and around content items For Flexbox it controls alignment in the main axis For Grid it controls alignment in the inline axis
- A bunch of text.