Public API
twill keeps its public API centered on style primitives and backend adapters.
If you only need the backend-agnostic style engine, depend on twill-core directly. The
top-level twill crate is now a facade that re-exports the same core modules and optionally
adds GUI adapters.
Core entry points
Styletwill-coretwill::prelude::core::*twill::prelude::theme::*twill::prelude::arbitrary::*twill::prelude::traits::*twill::prelude::*MergeComputeValueResponsive
Tokens
Main token families:
Color,ColorFamily,Scale,ColorValueBackgroundColor,TextColor,BorderColor,OutlineColor,RingColorColorValueTokenand*ColorVarwrappers for typed arbitrary/custom-property valuesSemanticColor,SemanticThemeVars,DynamicSemanticThemeThemeVariantSpacing,Percentage,Container,BreakpointFontFamily,FontSize,FontWeight,LetterSpacing,LineHeightBorderRadius,BorderWidth,BorderStyle,OutlineStyle,RingWidthShadow,InsetShadow,DropShadow,TextShadowAnimationToken,TransitionDuration,TransitionProperty,Easing
Utilities
Common utility-style value types:
Padding,PaddingValue,PaddingVarMargin,MarginValue,MarginVarWidth,WidthVarHeight,HeightVarSizeConstraintsDisplay,Position,Overflow,ZIndexFlexContainer,FlexDirection,FlexGridContainer,GridTemplate
Recommended usage
#![allow(unused)]
fn main() {
use twill::prelude::core::*;
let card = Style::card()
.merged(Style::interactive())
.padding(Padding::all(Spacing::S4))
.hover(|style| style.shadow(Shadow::Md))
.at_lg(|style| style.padding(Padding::all(Spacing::S6)));
assert!(!card.is_empty());
}
Composition helpers
Prefer composing Style values instead of creating framework-specific wrapper types:
Style::surface()for structural spacing, radius, and elevationStyle::card()for semantic card/background/border defaultsStyle::interactive()for pointer/focus/disabled affordancesStyle::merged(...)when you want an immutable composition stepStyle::merge_in_place(...)when you want to extend a mutable style valueStyle::resolved_theme(...)plusresolved_light_theme(...)/resolved_dark_theme(...)when you want semantic aliases converted into concrete color tokensStyle::resolve_theme_in_place(...)when you want that resolution on a mutable style- Verbose builder aliases like
background_color(...),border_color(...),outline_color(...),ring_width(...),ring_color(...), andbox_shadow(...)when you want a more self-explanatory Rust-first call site
The wide twill::prelude::* remains available, but prelude::core::* plus opt-in
sub-preludes gives better IDE discoverability and smaller import scope.
Backend surface
Feature-gated backend modules:
twill::backends::eguitwill::backends::icedtwill::backends::slinttwill::eguitwill::icedtwill::slint
These modules convert Twill values into framework-specific primitives. Twill itself does not define components like Button or Card.
If you do not want the facade crate, use the dedicated adapter crates directly:
twill-eguitwill-icedtwill-slint
Backend-specific helper types:
twill::backends::ShadowColortwill::iced::TextDirectiontwill::slint::SlintCursor