rsx! macro.
Global Attributes
Global attributes can be used on any HTML element.class
Theclass attribute specifies one or more CSS class names for an element.
id
Theid attribute defines a unique identifier for an element.
style
Thestyle attribute contains CSS styling declarations.
title
Thetitle attribute provides advisory information about the element.
lang
Thelang attribute defines the language of the element’s content.
dir
Thedir attribute specifies the text direction.
ltr (left-to-right), rtl (right-to-left), auto
Reference: MDN
hidden
Thehidden attribute indicates that the element is not yet, or is no longer, relevant.
tabindex
Thetabindex attribute controls keyboard navigation order.
accesskey
Theaccesskey attribute provides a keyboard shortcut.
contenteditable
Thecontenteditable attribute indicates whether the element’s content is editable.
draggable
Thedraggable attribute indicates whether the element can be dragged.
spellcheck
Thespellcheck attribute indicates whether to enable spell checking.
translate
Thetranslate attribute specifies whether content should be translated.
ARIA Attributes
ARIA attributes improve accessibility. They all use the global attributes system.role
Therole attribute defines the semantic role of an element.
Data Attributes
Custom data attributes store extra information.CSS Style Attributes
Dioxus provides direct style attribute support in the “style” namespace:Layout
display, position, top, left, right, bottom, width, height, min_width, max_width, min_height, max_height
Flexbox
flex, flex_direction, flex_wrap, flex_grow, flex_shrink, flex_basis, justify_content, align_items, align_content, align_self, order
Grid
grid, grid_template_columns, grid_template_rows, grid_template_areas, grid_column, grid_row, grid_area, grid_gap, column_gap, row_gap
Spacing
margin, margin_top, margin_right, margin_bottom, margin_left, padding, padding_top, padding_right, padding_bottom, padding_left
Typography
font, font_family, font_size, font_weight, font_style, line_height, text_align, text_decoration, text_transform, letter_spacing, word_spacing, white_space
Colors and Backgrounds
color, background, background_color, background_image, background_position, background_size, background_repeat, background_attachment, opacity
Borders
border, border_width, border_style, border_color, border_radius, border_top, border_right, border_bottom, border_left, box_shadow
Transforms and Animations
transform, transition, animation, animation_name, animation_duration, animation_timing_function, animation_delay, animation_iteration_count
Positioning
position, top, right, bottom, left, z_index
Overflow
overflow, overflow_x, overflow_y
Form Attributes
Input Attributes
type, name, value, placeholder, required, disabled, readonly, autofocus, autocomplete, maxlength, minlength, pattern, min, max, step, multiple, accept
Button Attributes
type, name, value, disabled, autofocus, form, formaction, formenctype, formmethod, formnovalidate, formtarget
Select Attributes
name, required, disabled, multiple, size, autofocus, form
Textarea Attributes
name, rows, cols, placeholder, required, disabled, readonly, maxlength, minlength, wrap, autocomplete, autofocus, form, spellcheck
Link Attributes
Anchor (a) Attributes
href, target, rel, download, hreflang, type, ping
Target Values: _blank (new tab), _self (same frame), _parent (parent frame), _top (full window)
Link Element Attributes
rel, href, type, media, crossorigin, integrity, hreflang, sizes, referrerpolicy, fetchpriority, as
Media Attributes
Image Attributes
src, alt, width, height, loading, decoding, crossorigin, ismap, usemap, srcset, sizes, referrerpolicy, fetchpriority
Audio/Video Attributes
src, controls, autoplay, loop, muted, preload, poster (video only), width, height, crossorigin
Preload Values: none, metadata, auto
Table Attributes
scope, colspan, rowspan, abbr
td Attributes: colspan, rowspan
Scope Values: row, col, rowgroup, colgroup
Special Attributes
dangerous_inner_html
Sets raw HTML content (use with caution - XSS risk).Attribute Naming
In Dioxus, attribute names follow Rust naming conventions:- Hyphenated HTML attributes use underscores:
font-sizebecomesfont_size - Reserved Rust keywords are prefixed with
r#:typebecomesr#type,loopbecomesr#loop - JavaScript-style names (camelCase) are converted:
classNameis justclass
Dynamic Attributes
Attributes can be computed dynamically:Conditional Attributes
Use unterminated if expressions:See Also
- HTML Elements - Complete list of HTML elements
- Event Handlers - Event handling reference
- RSX Syntax - Learn more about the RSX macro