Skip to content

Commit fcc85ea

Browse files
committed
Explain how attributes are accesible from component's template
1 parent 360058a commit fcc85ea

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,24 @@ Then you can use these helpers from your templates
131131
<% end %>
132132
```
133133

134+
### 5. Using attributes inside your components
135+
136+
When calling a component you can pass any attribute you like.
137+
138+
```eex
139+
<%= button type: :submit do %>
140+
Submit form!
141+
<% end %>
142+
```
143+
144+
Inside the component's template these attributes are going to be available in the `@attrs` map.
145+
146+
```eex
147+
<button type="<%= @attrs.type %>>
148+
<%= @content %>
149+
</button>
150+
```
151+
134152
## Configuration
135153

136154
You can configure where to put the components by editing your application

0 commit comments

Comments
 (0)