You will build rich components — tables, virtual lists, dropdown menus, clipboard access — through the Universal Component Protocol (UCP), so the composition code stays framework-agnostic while an adapter crate supplies the native rendering.
Prerequisites: the ui feature (included by the gpui feature); for GPUI rendering the adapter ships quoin-ui-gpui automatically.
Understand the two layers
Section titled “Understand the two layers”UCP splits rich widgets into:
- Traits in
quoin-ui— abstract contracts such asTableAdapter,VirtualListAdapter,ButtonAdapter,TextInputAdapter,DropdownMenuAdapter,TabBarAdapter, andClipboard. - Adapter implementations — concrete per-framework crates such as
quoin-ui-gpuithat know how to render the widget natively.
Your code talks to the traits; the framework feature pulls in the implementation.
Render a button
Section titled “Render a button”ButtonVariant selects emphasis (primary, ghost, destructive) and density (ComponentSize::Small | Medium | Large):
use quoin_ui::{ButtonAdapter, ButtonVariant, ComponentSize};
let adapter = GpuiButtonAdapter::default();let button = adapter.render(Some("Click Me".into()), ButtonVariant { primary: true, size: ComponentSize::Medium, ..Default::default()});Declare a sortable data table
Section titled “Declare a sortable data table”Inside quoin_render!, the data_table element declares columns with keys, labels, and render closures; sorting and striping come from attributes:
data_table(rows: people, striped: true) { column(key: "name", label: "Name", render: |p: &Person| p.name.clone()) column(key: "age", label: "Age", render: |p: &Person| p.age.to_string())}SortDirection (None | Asc | Desc) models the per-column sort state on the TableAdapter side.
Render large lists efficiently
Section titled “Render large lists efficiently”virtual_list backs scrollable lists with the VirtualListAdapter contract so only visible rows render; scroll restoration is part of the node vocabulary (scroll_restoration).
Read and write the clipboard
Section titled “Read and write the clipboard”The Clipboard trait abstracts the system clipboard; the clipboard_button element wires a button that copies text and reports success:
clipboard_button(copy_text: "Copied!") { "Copy" }Theme tokens
Section titled “Theme tokens”QuoinTheme resolves theme color tokens for adapters, so UCP components pick up consistent colors across light and dark appearances without hard-coded hex values in your code.
Next steps
Section titled “Next steps”-
Universal Component Protocol ReferenceAll traits, node types, and variant enums.
-
Declarative UI MacrosWhere UCP elements fit inside quoin_render! trees.
