pub struct Safelist(/* private fields */);Expand description
Configuration for the Config::safelist field.
It defines a list of selectors that are manually forced to be present in the generated CSS.
It should be used when you dynamically create selectors (for example, in Javascript
text-${ active ? "blue" : "gray" }-400, in this case, text-blue-400 and text-gray-400
should be added to the safelist).
§Example
use encre_css::Config;
let mut config = Config::default();
config.safelist.add("text-blue-400");
config.safelist.add("text-gray-400");
let generated = encre_css::generate(
[r#"<button class="bg-red-500">Click me</button>"#],
&config,
);
assert!(generated.ends_with(r#".bg-red-500 {
background-color: oklch(63.7% .237 25.331);
}
.text-blue-400 {
color: oklch(70.7% .165 254.624);
}
.text-gray-400 {
color: oklch(70.7% .022 261.325);
}"#));§Corresponding TOML configuration
safelist = ["text-blue-400", "text-gray-400"]Implementations§
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Safelist
impl<'de> Deserialize<'de> for Safelist
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
impl Eq for Safelist
impl StructuralPartialEq for Safelist
Auto Trait Implementations§
impl Freeze for Safelist
impl RefUnwindSafe for Safelist
impl Send for Safelist
impl Sync for Safelist
impl Unpin for Safelist
impl UnwindSafe for Safelist
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