pub struct CssStyle {Show 76 fields
pub display: Option<Display>,
pub position: Option<Position>,
pub top: Option<LengthPercentage>,
pub right: Option<LengthPercentage>,
pub bottom: Option<LengthPercentage>,
pub left: Option<LengthPercentage>,
pub width: Option<Size>,
pub height: Option<Size>,
pub min_width: Option<Size>,
pub min_height: Option<Size>,
pub max_width: Option<Size>,
pub max_height: Option<Size>,
pub margin: Option<Edges>,
pub padding: Option<Edges>,
pub border: Option<BorderEdges>,
pub box_sizing: Option<BoxSizing>,
pub aspect_ratio: Option<f32>,
pub flex_direction: Option<FlexDirection>,
pub flex_wrap: Option<FlexWrap>,
pub justify_content: Option<JustifyContent>,
pub align_items: Option<AlignItems>,
pub align_self: Option<AlignSelf>,
pub align_content: Option<AlignContent>,
pub gap: Option<Gap>,
pub flex_grow: Option<f32>,
pub flex_shrink: Option<f32>,
pub flex_basis: Option<Size>,
pub order: Option<i32>,
pub grid_template_columns: Option<Vec<GridTrack>>,
pub grid_template_rows: Option<Vec<GridTrack>>,
pub grid_column: Option<GridLine>,
pub grid_row: Option<GridLine>,
pub grid_auto_flow: Option<GridAutoFlow>,
pub justify_items: Option<JustifyItems>,
pub justify_self: Option<JustifySelf>,
pub font_family: Option<String>,
pub font_size: Option<Length>,
pub font_weight: Option<FontWeight>,
pub font_style: Option<FontStyle>,
pub line_height: Option<LineHeight>,
pub letter_spacing: Option<Length>,
pub text_align: Option<TextAlign>,
pub color: Option<Color>,
pub white_space: Option<WhiteSpace>,
pub overflow_wrap: Option<OverflowWrap>,
pub text_overflow: Option<TextOverflow>,
pub text_decoration: Option<TextDecoration>,
pub text_autofit: Option<bool>,
pub background: Option<Background>,
pub border_radius: Option<BorderRadius>,
pub box_shadow: Option<Vec<BoxShadow>>,
pub text_shadow: Option<Vec<TextShadow>>,
pub opacity: Option<f32>,
pub mix_blend_mode: Option<BlendMode>,
pub clip_path: Option<ClipPath>,
pub material: Option<Material>,
pub gradient_border: Option<GradientBorder>,
pub backdrop_blur: Option<f32>,
pub inner_shadow: Option<InnerShadow>,
pub filter: Option<Vec<FilterFn>>,
pub backdrop_filter: Option<Vec<FilterFn>>,
pub transform: Option<Vec<TransformFn>>,
pub transform_origin: Option<TransformOrigin>,
pub perspective: Option<Length>,
pub perspective_origin: Option<TransformOrigin>,
pub depth: Option<f32>,
pub layout_surface: Option<LayoutSurface>,
pub overflow: Option<Overflow>,
pub overflow_x: Option<Overflow>,
pub overflow_y: Option<Overflow>,
pub z_index: Option<i32>,
pub visibility: Option<Visibility>,
pub animation: Vec<AnimationEffect>,
pub transition: Option<StyleTransition>,
pub audio_reactive: Option<AudioReactive>,
pub expr: ComputedStyle,
}Expand description
Top-level CSS style block. All fields are optional; None means “not set”
and lets the cascade fill in inherited / initial values.
§Deserialize is hand-written, not derived
See computed’s module doc for why: a "= ..." expression on
opacity/width/height/a covered transform leaf has to survive
deserialization without retyping the field it was written on (every
other property still deserializes through the ordinary derived logic,
via the private CssStyleWire mirror below — #[serde(remote = "CssStyle")] lets that derive construct a real CssStyle directly, so
this hand-written impl only has to do two things: peel "= ..." strings
off the raw JSON first (computed::extract), then hand the cleaned
JSON to the derived logic and attach the extracted computed::ComputedStyle
afterwards. Serialize stays derived, unaffected — expr is
#[serde(skip)] and never round-trips through JSON.
Fields§
§display: Option<Display>§position: Option<Position>§top: Option<LengthPercentage>§right: Option<LengthPercentage>§bottom: Option<LengthPercentage>§left: Option<LengthPercentage>§width: Option<Size>§height: Option<Size>§min_width: Option<Size>§min_height: Option<Size>§max_width: Option<Size>§max_height: Option<Size>§margin: Option<Edges>§padding: Option<Edges>§border: Option<BorderEdges>§box_sizing: Option<BoxSizing>§aspect_ratio: Option<f32>§flex_direction: Option<FlexDirection>§flex_wrap: Option<FlexWrap>§justify_content: Option<JustifyContent>§align_items: Option<AlignItems>§align_self: Option<AlignSelf>§align_content: Option<AlignContent>§gap: Option<Gap>§flex_grow: Option<f32>§flex_shrink: Option<f32>§flex_basis: Option<Size>§order: Option<i32>§grid_template_columns: Option<Vec<GridTrack>>§grid_template_rows: Option<Vec<GridTrack>>§grid_column: Option<GridLine>§grid_row: Option<GridLine>§grid_auto_flow: Option<GridAutoFlow>§justify_items: Option<JustifyItems>§justify_self: Option<JustifySelf>§font_family: Option<String>§font_size: Option<Length>§font_weight: Option<FontWeight>§font_style: Option<FontStyle>§line_height: Option<LineHeight>§letter_spacing: Option<Length>§text_align: Option<TextAlign>§color: Option<Color>§white_space: Option<WhiteSpace>§overflow_wrap: Option<OverflowWrap>§text_overflow: Option<TextOverflow>§text_decoration: Option<TextDecoration>§text_autofit: Option<bool>When true on text/gradient_text, the effective font-size is
shrunk (never grown) until the content fits the box it was assigned,
instead of overflowing it. This is what lets an author declare “this
text must fit here” and closes ContentOverflowsBox as a possible
validator failure for that node — see apply_fixes
(rustmotion/src/cli/commands/validate.rs)’s comment on why it
deliberately refuses to auto-fix that violation today: growing the
box, shrinking the font, and shortening the copy are all legitimate
fixes, and picking one was never this tool’s call to make silently.
text-autofit removes that ambiguity by having the author pick
“shrink the font” up front.
Which box. Two independent axes, each opt-in on its own:
- Width: the box’s resolved width — its own
width/max-widthif set, else whatever it inherited from its parent (exactly the valuetext/gradient_textalready wrap against — seeTextIntrinsic/Text::paint). Always present once the node is laid out, so the width axis is always a candidate for shrinking. - Height: only when the node’s own box resolves to a definite
height (an explicit
height, or a parent that hands it one, e.g. a fixedflex-basis) — never an implicit/inherited one. A box that grows to fit its content has, by construction, nothing to overflow on the height axis, so there is nothing to shrink for. SeeTextIntrinsic::measure/Text::paint’scontent_heightfor exactly how this is read (the same taffy-resolved, padding/border- already-subtracted content-box value on both the pre-layout measure path and the post-layout paint path — this is what guarantees the two agree on the target, not just the algorithm).
white-space: nowrap. Does not change: nowrap still means “never
break this into multiple lines”. text-autofit composes with it
rather than overriding it — a nowrap line combined with
text-autofit: true shrinks the one line until it fits the box’s
width (this is text/gradient_text’s answer to Remotion’s
fitText()), it does not start wrapping.
The floor. Never shrinks below TEXT_AUTOFIT_MIN_FONT_PX — the
same calibrated legibility ratio check_legibility
(rustmotion/src/cli/commands/geometry.rs) already enforces, not a
new threshold. If the content still doesn’t fit at the floor, the
floor size is used anyway (illegible-but-smallest beats an even
larger overflow) and the geometry validator’s ContentOverflowsBox
still fires — text-autofit narrows that failure class, it does not
silence it.
background: Option<Background>§border_radius: Option<BorderRadius>§box_shadow: Option<Vec<BoxShadow>>§text_shadow: Option<Vec<TextShadow>>§opacity: Option<f32>§mix_blend_mode: Option<BlendMode>§clip_path: Option<ClipPath>§material: Option<Material>Glossy surface treatment: a highlight on the lit side, a specular
edge along it, and a soft shade opposite. All three are derived from
the scene’s light, so several materials in one scene agree about
where the light is.
Follows the node’s box, clipped by border-radius and by
clip-path when set — not by a shape component’s own geometry,
which paints itself. Give the box the silhouette.
gradient_border: Option<GradientBorder>Gradient-colored border painted instead of border when present.
{ "colors": [...], "width": 2, "angle": 0 } — angle follows the same
convention as background linear gradients.
backdrop_blur: Option<f32>Deprecated: use backdrop-filter: [{ "fn": "blur", "radius": N }].
inner_shadow: Option<InnerShadow>Deprecated: use box-shadow with "inset": true.
filter: Option<Vec<FilterFn>>§backdrop_filter: Option<Vec<FilterFn>>§transform: Option<Vec<TransformFn>>§transform_origin: Option<TransformOrigin>§perspective: Option<Length>§perspective_origin: Option<TransformOrigin>§depth: Option<f32>Parallax plane depth for the scene camera (issue #90). 0 = locked plane (the camera does not affect it), 1 = normal plane (default), above 1 = amplified foreground. v1: effective on direct children of the scene root only (each top-level child is one plane whose depth governs its whole subtree). Not inherited via cascade.
layout_surface: Option<LayoutSurface>Projects this container’s direct children onto a cylinder or sphere
instead of the flat plane taffy laid them out on (issue #387). Layout
itself is untouched — columns and rows are still computed flat — this
only bends where each child is painted, around one vanishing point
shared by the whole container, which is what makes it different from
giving every child its own transform/perspective: those never
agree on a horizon, so a tilted grid of them stays a flat trapezoid.
See rules/layout-surface.md.
overflow: Option<Overflow>§overflow_x: Option<Overflow>§overflow_y: Option<Overflow>§z_index: Option<i32>§visibility: Option<Visibility>§animation: Vec<AnimationEffect>§transition: Option<StyleTransition>Smoothing for timeline style-state changes. Supported properties:
opacity; color on text/counter; background (solid colour only)
and border-radius (single uniform, absolute-px value only) — see
box_builder.rs’s transition_keyframes/
resolve_transition_css_overrides. Everything else — including a
background/border-radius value outside the shape those two
support (gradients, per-corner radii, %/em/rem/vw/vh) —
still snaps at the step’s at; rustmotion validate’s
check_transition_smoothing (validate_schema.rs) reports exactly
which property and why whenever it would otherwise snap silently.
audio_reactive: Option<AudioReactive>§expr: ComputedStyleThe "= ..." expressions computed::extract pulled off this
node’s opacity/width/height/covered transform leaves at
deserialize time — never part of the wire format (#[serde(skip)]:
it neither reads from nor writes to JSON), populated only by
CssStyle’s own hand-written Deserialize impl below. See
computed’s module doc.
Implementations§
Source§impl CssStyle
impl CssStyle
pub fn font_size_px_or(&self, default: f32) -> f32
pub fn font_size_px(&self) -> Option<f32>
pub fn color_str(&self) -> Option<&str>
pub fn color_str_or<'a>(&'a self, default: &'a str) -> &'a str
pub fn font_family_str(&self) -> Option<&str>
pub fn font_family_or<'a>(&'a self, default: &'a str) -> &'a str
pub fn letter_spacing_px(&self) -> f32
pub fn line_height_for(&self, font_size: f32) -> f32
pub fn font_size_px_ctx(&self, ctx: &LengthContext, default: f32) -> f32
pub fn letter_spacing_px_ctx(&self, ctx: &LengthContext) -> f32
pub fn line_height_for_ctx(&self, font_size: f32, ctx: &LengthContext) -> f32
pub fn typography_px_ctx( &self, ctx: &LengthContext, default_font_size: f32, ) -> (f32, f32, f32)
pub fn opacity_or(&self, default: f32) -> f32
pub fn border_radius_px(&self) -> Option<f32>
pub fn border_radius_px_or(&self, default: f32) -> f32
pub fn padding_px(&self) -> (f32, f32, f32, f32)
pub fn margin_px(&self) -> (f32, f32, f32, f32)
pub fn background_color_str(&self) -> Option<&str>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for CssStyle
impl<'de> Deserialize<'de> for CssStyle
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl JsonSchema for CssStyle
impl JsonSchema for CssStyle
Source§fn schema_name() -> String
fn schema_name() -> String
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for CssStyle
Auto Trait Implementations§
impl Freeze for CssStyle
impl RefUnwindSafe for CssStyle
impl Send for CssStyle
impl Sync for CssStyle
impl Unpin for CssStyle
impl UnsafeUnpin for CssStyle
impl UnwindSafe for CssStyle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more