redraw/attribute

Types

pub type Attribute =
  attribute.Attribute
pub type Dir {
  Ltr
  Rtl
}

Constructors

  • Ltr
  • Rtl
pub type InnerHTML
pub type Translate {
  Yes
  No
}

Constructors

  • Yes
  • No

Constants

pub const attribute: fn(String, a) -> Attribute

Functions

pub fn accept(types: List(String)) -> Attribute
pub fn accept_charset(types: List(String)) -> Attribute
pub fn access_key(value: String) -> Attribute
pub fn action(url: String) -> Attribute
pub fn alt(value: String) -> Attribute
pub fn aria(key: String, value: String) -> Attribute

Set aria attribute on the node. Should be used like aria("valuenow", "75").

pub fn auto_capitalize(value: String) -> Attribute
pub fn autocomplete(name: String) -> Attribute
pub fn autofocus(should_autofocus: Bool) -> Attribute
pub fn autoplay(should_autoplay: Bool) -> Attribute
pub fn checked(is_checked: Bool) -> Attribute
pub fn class(value: String) -> Attribute
pub fn class_name(value: String) -> Attribute

Alias of class.

pub fn cols(val: Int) -> Attribute
pub fn content_editable(value: Bool) -> Attribute

If true, the browser lets the user edit the rendered element directly. This is used to implement rich text input libraries like Lexical. React warns if you try to pass React children to an element with content_editable(True) because React will not be able to update its content after user edits.

pub fn controls(visible: Bool) -> Attribute
pub fn dangerously_set_inner_html(
  inner_html: InnerHTML,
) -> Attribute

Overrides the innerHTML property of the DOM node and displays the passed HTML inside. This should be used with extreme caution! If the HTML inside isn’t trusted (for example, if it’s based on user data), you risk introducing an XSS vulnerability.

Documentation

pub fn data(key: String, value: String) -> Attribute

Data attributes let you attach some string data to the element, for example data("fruit", "banana"). In React, they are not commonly used because you would usually read data from props or state instead.

pub fn dir(value: Dir) -> Attribute

Specifies the text direction of the element.

pub fn disabled(is_disabled: Bool) -> Attribute
pub fn download(filename: String) -> Attribute
pub fn draggable(value: Bool) -> Attribute

Specifies whether the element is draggable. Part of HTML Drag and Drop API.

pub fn enctype(value: String) -> Attribute
pub fn enter_key_hint(value: String) -> Attribute

Specifies which action to present for the enter key on virtual keyboards.

pub fn for(value: String) -> Attribute

For

pub fn form_action(action: String) -> Attribute
pub fn form_enctype(value: String) -> Attribute
pub fn form_method(method: String) -> Attribute
pub fn form_novalidate(value: Bool) -> Attribute
pub fn form_target(target: String) -> Attribute
pub fn height(val: Int) -> Attribute
pub fn hidden(value: Bool) -> Attribute

Specifies whether the element should be hidden.

pub fn href(url: String) -> Attribute
pub fn html_for(value: String) -> Attribute

Alias of for.

pub fn id(value: String) -> Attribute

Specifies a unique identifier for this element, which can be used to find it later or connect it with other elements. Generate it with useId to avoid clashes between multiple instances of the same component.

pub fn inner_html(html: String) -> InnerHTML

The inner_html data should be created as close to where the HTML is generated as possible. This ensures that all raw HTML being used in your code is explicitly marked as such, and that only variables that you expect to contain HTML are passed to dangerously_set_inner_html. It is not recommended to create the object inline like html.div([attribute.dangerously_set_inner_html(attribute.inner_html(markup))], [])

Documentation

pub fn input_mode(value: String) -> Attribute

Specifies what kind of keyboard to display (for example, text, number or telephone).

pub fn is(value: String) -> Attribute

If specified, the component will behave like a custom element.

pub fn item_prop(value: String) -> Attribute

Specifies which property the element represents for structured data crawlers.

pub fn lang(value: String) -> Attribute

Specifies the language of the element.

pub fn loop(should_loop: Bool) -> Attribute
pub fn max(val: String) -> Attribute
pub fn method(method: String) -> Attribute
pub fn min(val: String) -> Attribute
pub fn msg(uri: String) -> Attribute
pub fn name(name: String) -> Attribute
pub fn novalidate(value: Bool) -> Attribute
pub fn open(is_open: Bool) -> Attribute
pub fn pattern(regex: String) -> Attribute
pub fn placeholder(text: String) -> Attribute
pub fn readonly(is_readonly: Bool) -> Attribute
pub fn ref(ref: Ref(Option(a))) -> Attribute

A ref object from redraw.use_ref. Your ref will be filled with the DOM element for this node. Contrarily to JS React, when using a Ref, you’re forced to use an optional type here. Because when using this function, you want to get a reference from a real DOM node, meaning at the initialization of the reference, you won’t have any data. Use ref_ when you want full control over the ref you send to the Component.

pub fn ref_(ref: fn(a) -> Nil) -> Attribute

A ref callback function. The callback will be provided with the DOM element for this node. Use this function to get control on the ref provided by the DOM node or the component.

pub fn rel(relationship: String) -> Attribute
pub fn required(is_required: Bool) -> Attribute
pub fn role(value: String) -> Attribute

Specifies the element role explicitly for assistive technologies.

pub fn rows(val: Int) -> Attribute
pub fn selected(is_selected: Bool) -> Attribute
pub fn slot(value: String) -> Attribute

Specifies the slot name when using shadow DOM.

pub fn spell_check(value: Bool) -> Attribute

If explicitly set to true or false, enables or disables spellchecking.

pub fn src(value: String) -> Attribute
pub fn step(val: String) -> Attribute
pub fn style(styles: List(#(String, String))) -> Attribute
pub fn suppress_content_editable_warning(
  value: Bool,
) -> Attribute
pub fn suppress_hydration_warning(value: Bool) -> Attribute
pub fn tab_index(value: Int) -> Attribute

Overrides the default Tab button behavior. Avoid using values other than -1 and 0.

pub fn target(value: String) -> Attribute
pub fn title(value: String) -> Attribute

Specifies the tooltip text for the element.

pub fn translate(value: Translate) -> Attribute

Passing No excludes the element content from being translated.

pub fn type_(name: String) -> Attribute
pub fn value(val: String) -> Attribute
pub fn width(val: Int) -> Attribute
pub fn wrap(mode: String) -> Attribute
Search Document