lustre/attribute
Types
Functions
pub fn accept_charset(types: List(String)) -> Attribute(a)
pub fn attribute(name: String, value: String) -> Attribute(a)
Create an HTML attribute. This is like saying element.setAttribute("class", "wibble")
in JavaScript. Attributes will be rendered when calling element.to_string
.
Note: there is a subtle difference between attributes and properties. You can read more about the implications of this here.
pub fn autocomplete(name: String) -> Attribute(a)
pub fn class(name: String) -> Attribute(a)
Note: unlike most attributes, multiple
class
attributes are merged with any existing other classes on an element.
pub fn form_action(action: String) -> Attribute(a)
pub fn form_enctype(value: String) -> Attribute(a)
pub fn form_method(method: String) -> Attribute(a)
pub fn form_novalidate(value: Bool) -> Attribute(a)
pub fn form_target(target: String) -> Attribute(a)
pub fn map(attr: Attribute(a), f: fn(a) -> b) -> Attribute(b)
The Attribute
type is parameterised by the type of messages it can produce
from events handlers. Sometimes you might end up with an attribute from a
library or module that produces a different type of message: this function lets
you map the messages produced from one type to another.
pub fn none() -> Attribute(a)
Create an empty attribute. This is not added to the DOM and not rendered when
calling element.to_string
, but it is useful for
conditionally adding attributes to an element.
pub fn novalidate(value: Bool) -> Attribute(a)
pub fn on(
name: String,
handler: fn(Dynamic) -> Result(a, List(DecodeError)),
) -> Attribute(a)
pub fn placeholder(text: String) -> Attribute(a)
pub fn property(name: String, value: a) -> Attribute(b)
Create a DOM property. This is like saying element.className = "wibble"
in
JavaScript. Properties will be not be rendered when calling
element.to_string
.
Note: there is a subtle difference between attributes and properties. You can read more about the implications of this here.
pub fn style(properties: List(#(String, String))) -> Attribute(a)
Note: unlike most attributes, multiple
style
attributes are merged with any existing other styles on an element. Styles added later in the list will override styles added earlier.