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
*Prerequisite:* We assume you have read and followed the [installation guide](/docs/install), either in a new or existing Rails application.
4
+
5
+
## General approach
6
+
7
+
Matestack components can easily be styled through the `attributes` parameter. In a growing application, you will most probably work with a (S)CSS framework/library and often style your pages and components through `id`s and `classes`. Inline styles allow for dynamic styling and can come in handy in certain use cases - as shown below:
8
+
9
+
```ruby
10
+
# [...]
11
+
12
+
defprepare
13
+
@colors= ['green', 'blue', 'red']
14
+
end
15
+
16
+
defresponse
17
+
components {
18
+
@colors.each do |color|
19
+
paragraph attributes: { style:"color: #{color};" }, text:"I will be displayed as #{color} text."
20
+
end
21
+
}
22
+
end
23
+
24
+
# [...]
25
+
```
26
+
## Accessing videos and images with inline styling
27
+
28
+
For now, we have to resort to an `ActionController` helper in order to work with our assets. See a working example below:
29
+
30
+
```ruby
31
+
# [...]
32
+
33
+
defresponse
34
+
components {
35
+
div attributes: { style:"background-image: url(#{ActionController::Base.helpers.asset_path('image.png')});" } do
0 commit comments