pub struct CssStyle {Show 73 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 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 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>,
}Expand description
Top-level CSS style block. All fields are optional; None means “not set”
and lets the cascade fill in inherited / initial values.
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.
auto_scroll (codeblock/terminal). Unrelated: text-autofit
is only read by text/gradient_text’s own painter/intrinsic —
codeblock/terminal never look at this field, so there is no
precedence to resolve between the two; auto_scroll keeps scrolling
(never shrinking) exactly as documented in CLAUDE.md.
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>§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.
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>Implementations§
Source§impl CssStyle
impl CssStyle
Sourcepub fn font_size_px_or(&self, default: f32) -> f32
pub fn font_size_px_or(&self, default: f32) -> f32
font-size in px, falling back to default when unset.
Sourcepub fn font_size_px(&self) -> Option<f32>
pub fn font_size_px(&self) -> Option<f32>
font-size in px if set as a length.
Sourcepub fn color_str(&self) -> Option<&str>
pub fn color_str(&self) -> Option<&str>
color as a hex string (only Color::String returns Some).
Sourcepub fn color_str_or<'a>(&'a self, default: &'a str) -> &'a str
pub fn color_str_or<'a>(&'a self, default: &'a str) -> &'a str
color as a hex string with default fallback.
Sourcepub fn font_family_str(&self) -> Option<&str>
pub fn font_family_str(&self) -> Option<&str>
font-family string.
Sourcepub fn font_family_or<'a>(&'a self, default: &'a str) -> &'a str
pub fn font_family_or<'a>(&'a self, default: &'a str) -> &'a str
font-family string with default fallback.
Sourcepub fn letter_spacing_px(&self) -> f32
pub fn letter_spacing_px(&self) -> f32
letter-spacing in px, defaulting to 0.
Sourcepub fn line_height_for(&self, font_size: f32) -> f32
pub fn line_height_for(&self, font_size: f32) -> f32
line-height resolution. For Number (unitless) returns
n * font_size; for Length(px) returns the px value; otherwise
returns 1.3 * font_size.
Sourcepub fn font_size_px_ctx(&self, ctx: &LengthContext, default: f32) -> f32
pub fn font_size_px_ctx(&self, ctx: &LengthContext, default: f32) -> f32
font-size resolved against ctx, correctly handling
%/em/rem/vw/vh — unlike Self::font_size_px_or. em/%
resolve against ctx.font_size, which the caller should set to the
parent’s actual computed font-size in px for correctness (see the
module note above on why nothing does that yet).
Sourcepub fn letter_spacing_px_ctx(&self, ctx: &LengthContext) -> f32
pub fn letter_spacing_px_ctx(&self, ctx: &LengthContext) -> f32
letter-spacing resolved against ctx, correctly handling
%/em/rem/vw/vh — unlike Self::letter_spacing_px. Per
CSS, em here means the element’s own font-size, so pass a ctx
whose font_size is the already-resolved own font-size (e.g. via
Self::font_size_px_ctx), not the parent’s — see
Self::typography_px_ctx for a helper that gets this right
automatically.
Sourcepub fn line_height_for_ctx(&self, font_size: f32, ctx: &LengthContext) -> f32
pub fn line_height_for_ctx(&self, font_size: f32, ctx: &LengthContext) -> f32
line-height resolved against ctx, correctly handling
%/em/rem/vw/vh — unlike Self::line_height_for.
LineHeight::Number (unitless, e.g. 1.5) is unaffected — it always
means n * font_size regardless of any context. For
LineHeight::Length, % is special-cased to CSS’s actual rule for
this property (relative to the element’s own font-size, not
ctx.parent_size like % normally means): a generic
ParsedLength::resolve would silently resolve it against the wrong
base otherwise. Same own-vs-parent em caveat as
Self::letter_spacing_px_ctx applies.
Sourcepub fn typography_px_ctx(
&self,
ctx: &LengthContext,
default_font_size: f32,
) -> (f32, f32, f32)
pub fn typography_px_ctx( &self, ctx: &LengthContext, default_font_size: f32, ) -> (f32, f32, f32)
Resolve font-size, letter-spacing, and line-height together in
one call, honouring CSS’s two different em bases (see the module
note above font_size_px_ctx): font-size’s own em resolves
against ctx.font_size (conventionally the parent’s font-size),
while letter-spacing’s and line-height’s em resolve against the
just-computed own font-size, not ctx.font_size again. Returns
(font_size_px, letter_spacing_px, line_height_px).
Sourcepub fn opacity_or(&self, default: f32) -> f32
pub fn opacity_or(&self, default: f32) -> f32
opacity with default 1.0.
Sourcepub fn border_radius_px(&self) -> Option<f32>
pub fn border_radius_px(&self) -> Option<f32>
border-radius resolved as a single uniform px value (drops per-corner).
Sourcepub fn border_radius_px_or(&self, default: f32) -> f32
pub fn border_radius_px_or(&self, default: f32) -> f32
border-radius as px, defaulting to default.
Sourcepub fn padding_px(&self) -> (f32, f32, f32, f32)
pub fn padding_px(&self) -> (f32, f32, f32, f32)
Resolved padding tuple (top, right, bottom, left) in px.
Sourcepub fn margin_px(&self) -> (f32, f32, f32, f32)
pub fn margin_px(&self) -> (f32, f32, f32, f32)
Resolved margin tuple (top, right, bottom, left) in px.
Sourcepub fn background_color_str(&self) -> Option<&str>
pub fn background_color_str(&self) -> Option<&str>
background as a hex/keyword string when set as a plain color.
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