Module preflight

Module preflight 

Source
Expand description

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

Based on Tailwind’s default preflight.

§Full preflight

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 the various associated methods, e.g Preflight::font_family_sans or Preflight::font_family_mono.

use encre_css::{Preflight, Config};

let mut config = Config::default();
config.preflight = Preflight::new_full()
    .font_family_mono("'Fira Code'");

assert!(encre_css::generate([], &config).contains("code, kbd, samp, pre {
  font-family: 'Fira Code';"));

Using TOML:

preflight = { full = { font_family_mono = "'Fira Code'" } }

§Custom preflight

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;
}");

Using TOML:

preflight = { custom = "html, body { width: 100vw; height: 100vh; margin: 0; }" }

Note that newlines are not yet supported in TOML so it might be better to define it in Rust if you have a long custom preflight.

§Empty preflight

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!(encre_css::generate([], &config).is_empty());

Using TOML:

preflight = "none"

Enums§

Preflight
The set of default styles.