Struct egui::style::Style

source ·
pub struct Style {
    pub override_text_style: Option<TextStyle>,
    pub override_font_id: Option<FontId>,
    pub text_styles: BTreeMap<TextStyle, FontId>,
    pub drag_value_text_style: TextStyle,
    pub wrap: Option<bool>,
    pub spacing: Spacing,
    pub interaction: Interaction,
    pub visuals: Visuals,
    pub animation_time: f32,
    pub debug: DebugOptions,
    pub explanation_tooltips: bool,
    pub always_scroll_the_only_direction: bool,
Expand description

Specifies the look and feel of egui.

You can change the visuals of a Ui with Ui::style_mut and of everything with crate::Context::set_style.

If you want to change fonts, use crate::Context::set_fonts instead.


§override_text_style: Option<TextStyle>

If set this will change the default TextStyle for all widgets.

On most widgets you can also set an explicit text style, which will take precedence over this.

§override_font_id: Option<FontId>

If set this will change the font family and size for all widgets.

On most widgets you can also set an explicit text style, which will take precedence over this.

§text_styles: BTreeMap<TextStyle, FontId>

The FontFamily and size you want to use for a specific TextStyle.

The most convenient way to look something up in this is to use TextStyle::resolve.

If you would like to overwrite app text_styles

use egui::FontFamily::Proportional;
use egui::FontId;
use egui::TextStyle::*;

// Get current context style
let mut style = (*;

// Redefine text_styles
style.text_styles = [
  (Heading, FontId::new(30.0, Proportional)),
  (Name("Heading2".into()), FontId::new(25.0, Proportional)),
  (Name("Context".into()), FontId::new(23.0, Proportional)),
  (Body, FontId::new(18.0, Proportional)),
  (Monospace, FontId::new(14.0, Proportional)),
  (Button, FontId::new(14.0, Proportional)),
  (Small, FontId::new(10.0, Proportional)),

// Mutate global style with above changes
§drag_value_text_style: TextStyle

The style to use for DragValue text.

§wrap: Option<bool>

If set, labels buttons wtc will use this to determine whether or not to wrap the text at the right edge of the Ui they are in. By default this is None.

  • None: follow layout
  • Some(true): default on
  • Some(false): default off
§spacing: Spacing

Sizes and distances between widgets

§interaction: Interaction

How and when interaction happens.

§visuals: Visuals

Colors etc.

§animation_time: f32

How many seconds a typical animation should last.

§debug: DebugOptions

Options to help debug why egui behaves strangely.

Only available in debug builds.

§explanation_tooltips: bool

Show tooltips explaining DragValue:s etc when hovered.

This only affects a few egui widgets.

§always_scroll_the_only_direction: bool

If true and scrolling is enabled for only one direction, allow horizontal scrolling without pressing shift



impl Style


pub fn interact(&self, response: &Response) -> &WidgetVisuals

Use this style for interactive things. Note that you must already have a response, i.e. you must allocate space and interact BEFORE painting the widget!


pub fn interact_selectable( &self, response: &Response, selected: bool ) -> WidgetVisuals


pub fn noninteractive(&self) -> &WidgetVisuals

Style to use for non-interactive widgets.


pub fn text_styles(&self) -> Vec<TextStyle>

All known text styles.


impl Style


pub fn ui(&mut self, ui: &mut Ui)

Trait Implementations§


impl Clone for Style


fn clone(&self) -> Style

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more

impl Debug for Style


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

Formats the value using the given formatter. Read more

impl Default for Style


fn default() -> Self

Returns the “default value” for a type. Read more

impl<'de> Deserialize<'de> for Style
where Style: Default,


fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

impl PartialEq for Style


fn eq(&self, other: &Style) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

impl Serialize for Style


fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

impl StructuralPartialEq for Style

Auto Trait Implementations§


impl RefUnwindSafe for Style


impl Send for Style


impl Sync for Style


impl Unpin for Style


impl UnwindSafe for Style

Blanket Implementations§


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


fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more

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


fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more

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


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

Mutably borrows from an owned value. Read more

impl<T> From<T> for T


fn from(t: T) -> T

Returns the argument unchanged.


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


fn into(self) -> U

Calls U::from(self).

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


impl<T> Pointable for T


const ALIGN: usize = _

The alignment of pointer.

type Init = T

The type for initializers.

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more

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


type Owned = T

The resulting type after obtaining ownership.

fn to_owned(&self) -> T

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

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

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

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


type Error = Infallible

The type returned in the event of a conversion error.

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.

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


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

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,


impl<T> SerializableAny for T
where T: 'static + Any + Clone + Serialize + for<'a> Deserialize<'a> + Send + Sync,