pub struct Icon {
pub id: Option<NodeId>,
pub source: IconSource,
pub color: Option<Color>,
pub size: Option<f32>,
pub stroke: Option<Stroke>,
}Expand description
A vector icon rendered from an SVG path, file, or inline SVG content.
Icons default to the theme’s primary text colour and 24x24 layout points.
Use color(), size(), and stroke() to customise.
§Example
ⓘ
// From an SVG path string
Icon::path("M12 2L2 22h20L12 2z")
.size(20.0)
.color(theme.tokens.colors.primary)
// From a file
Icon::file("assets/icons/star.svg").size(16.0)
// From inline SVG
Icon::svg("<svg>...</svg>")Fields§
§id: Option<NodeId>Explicit node identity.
source: IconSourceThe vector graphic source.
color: Option<Color>Fill colour (falls back to the theme’s primary text colour).
size: Option<f32>Layout size in points (default: 24.0).
stroke: Option<Stroke>Optional stroke (when set, the fill is suppressed).
Implementations§
Source§impl Icon
impl Icon
pub fn path(path: impl Into<String>) -> Self
pub fn file(path: impl Into<String>) -> Self
pub fn svg(content: impl Into<String>) -> Self
pub fn new(path: impl Into<String>) -> Self
pub fn size(self, s: f32) -> Self
pub fn color(self, c: Color) -> Self
pub fn stroke(self, s: Stroke) -> Self
pub fn into_node(self) -> Node
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Icon
impl<'de> Deserialize<'de> for Icon
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>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for Icon
impl RefUnwindSafe for Icon
impl Send for Icon
impl Sync for Icon
impl Unpin for Icon
impl UnsafeUnpin for Icon
impl UnwindSafe for Icon
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.