Skip to main content

Style

Struct Style 

Source
pub struct Style {
    pub layout: Style,
    pub view: ViewStyle,
    pub text: TextStyle,
    pub paint: PaintStyle,
    pub animated: Vec<(AnimationProp, NodeId)>,
    pub z_index: i32,
    pub vertical_align: VerticalAlign,
    pub direction: Option<bool>,
    pub logical: Logical,
    pub perspective: Option<Points>,
    /* private fields */
}
Expand description

A complete node style, split by consumer.

Fields§

§layout: Style

Layout properties, consumed by taffy.

§view: ViewStyle

Visual properties of the native view.

§text: TextStyle

Text properties.

§paint: PaintStyle

SVG’s paint properties (inherited, as text properties are).

§animated: Vec<(AnimationProp, NodeId)>

Visual properties driven by native animation nodes; they override the static values while bound.

§z_index: i32

zIndex: stacking order among siblings (higher on top).

§vertical_align: VerticalAlign

verticalAlign: where the element sits in its line when it is inside a <Text>.

§direction: Option<bool>

direction: right to left (Some(true)), left to right, or inherited (None).

§logical: Logical

Start / end properties, placed by the resolved direction.

§perspective: Option<Points>

CSS’s perspective (perspective-*, Styled::perspective): the depth the view gives its children’s 3D transforms, seen from its center; the core composes it into their transforms.

Implementations§

Source§

impl Style

Source

pub fn object_fit(&self) -> Option<ResizeMode>

objectFit (the object-* classes set it too): how an image or a video fits its box; None leaves the element’s default.

Source

pub fn set_transform( &mut self, property: TransformProperty, steps: &[(TransformKind, f32, Option<NodeId>)], ) -> Result<(), StyleError>

Sets transform property property to steps in its place in the transform list, the other properties’ steps around it; a step with an animated value is bound to it.

Source

pub fn edit_effects(&mut self, f: impl FnOnce(&mut Effects))

Changes the effects lists (copying them if shared).

Source

pub fn set_box_shadows(&mut self, shadows: Vec<BoxShadow>)

Sets the box shadows (top layer first).

Source

pub fn set_background_images(&mut self, images: Vec<Gradient>)

Sets the gradient backgrounds (top layer first).

Source

pub fn set_filters(&mut self, filters: Vec<Filter>, backdrop: bool)

Sets the filters.

Source

pub fn set( &mut self, key: &str, value: StyleValue<'_>, ) -> Result<(), StyleError>

Sets one property using its React Native name.

Source

pub fn set_key( &mut self, key: StyleKey, value: StyleValue<'_>, ) -> Result<(), StyleError>

Sets one property.

Source

pub fn apply_value( &mut self, key: StyleKey, value: &PropertyValue, ) -> Result<(), StyleError>

Sets property key to value, parsed before (StyleKey::parse_value) or made typed (classes, Rust’s styles). A value of another property’s kind is rejected.

Trait Implementations§

Source§

impl Clone for Style

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Style

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Style

Source§

fn default() -> Self

React Native defaults, which differ from CSS (and taffy) defaults.

Auto Trait Implementations§

§

impl !Send for Style

§

impl !Sync for Style

§

impl Forget for Style

§

impl Freeze for Style

§

impl Move for Style

§

impl RefUnwindSafe for Style

§

impl Unpin for Style

§

impl UnsafeUnpin for Style

§

impl UnwindSafe for Style

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.