Documentation / Reference

fragment

Group a sequence of views without adding a host element.

Construction

Use fragment<V: View>(children: impl IntoIterator<Item = V>) -> impl View. Import constructors and common modifiers from refract::prelude::*.

fragment.rs
use refract::prelude::*;

let labels = fragment(["Recent", "Saved", "Archived"].into_iter().map(text));
let column = v_stack().gap(8.0).child(labels);

Grouping and identity

A fragment returns a group description. Its children participate in the surrounding composition without an extra box. Iterator items share a concrete type; use AnyView when heterogeneous items need type erasure.

Use keys on reorderable children to preserve their mounted identities. A fragment has no independent layout or paint box unless a modifier introduces one.

View-specific reference

fragment has no builder-specific methods. Its children are supplied at construction. Common ViewExt modifiers remain available, but styling the group can add a box and change its layout relationship with the parent.

Common view modifiers

Dimensions, paint, labels, and disabled state preserve each concrete builder type, so their builder methods can be interleaved. padding and frame return wrappers; configure the inner element before adding those. ViewExt supplies the shared API for composed views.

See View Modifiers for shared methods and modifier ordering. Focus bindings and callbacks preserve concrete builders; see focus modifiers and Input & Focus for requests, observation, and indicators.

Source reference

The implementation is in crates/core/src/view/mod.rs. Primitive and layout builders are in crates/core/src/view/primitives.rs. Shared modifiers are in crates/core/src/view/modifiers.rs. Style values and validation are in crates/core/src/style.rs.