You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/components/props.md
+27Lines changed: 27 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,33 @@ rx.box(
38
38
39
39
In the example above, the `class_name` prop of the `rx.box` component is assigned a list of class names. This means the `rx.box` component will be styled with the CSS classes `class-name-1` and `class-name-2`.
40
40
41
+
### ARIA and Data Attributes
42
+
43
+
Reflex supports accessibility attributes (ARIA) and data attributes using Python's snake_case convention (with underscore) instead of the HTML kebab-case (with dash). These are automatically converted to the proper format when rendered as HTML.
44
+
45
+
For example, `aria_label` becomes `aria-label` and `data_testid` becomes `data-testid` in the generated HTML.
46
+
47
+
```python demo
48
+
rx.button(
49
+
"Close",
50
+
aria_label="Close dialog",
51
+
data_testid="close-button",
52
+
)
53
+
```
54
+
55
+
### Custom Attributes
56
+
57
+
For cases where you need to add arbitrary HTML attributes that aren't covered by the built-in props, you can use `custom_attrs` as an escape hatch. This prop accepts a dictionary of attribute names and values.
Note that for ARIA and data attributes, it's recommended to use the underscore notation (`aria_label`, `data_testid`) instead of `custom_attrs` for better readability and consistency.
67
+
41
68
## Style Props
42
69
43
70
In addition to component-specific props, most built-in components support a full range of style props. You can use any [CSS property](https://www.w3schools.com/cssref/index.php) to style a component.
0 commit comments