Module encre_css::preflight

source ·
Expand description

Define the default set of base CSS styles used to make websites consistent across browsers.

By default, this base CSS is included in the generated CSS and you can customize it by manually setting the Config::preflight configuration field to Preflight::new_full() and by using Preflight::ring_color, Preflight::border_color, Preflight::placeholder_color, Preflight::font_family_sans or Preflight::font_family_mono.

use encre_css::{Preflight, Config};

let mut config = Config::default();
config.preflight = Preflight::new_full()
    .border_color("#444");

assert!(encre_css::generate([], &config).starts_with("*, ::before, ::after {
  box-sizing: border-box;
  border-width: 0;
  border-style: solid;
  border-color: #444;
}"));

You can also use your own default CSS using Preflight::new_custom.

use encre_css::{Preflight, Config};

let mut config = Config::default();
config.preflight = Preflight::new_custom("html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
}");

assert_eq!(encre_css::generate([], &config), "html, body {
  width: 100vw;
  height: 100vh;
  margin: 0;
}");

Finally you can disable it using Preflight::new_none.

use encre_css::{Preflight, Config};

let mut config = Config::default();
config.preflight = Preflight::new_none();

assert_eq!(encre_css::generate([], &config), "");

Based on Tailwind’s default preflight.

Enums§

OSZAR »