View Source LiveViewNative.SwiftUI.UtilityStyles (live_view_native_swiftui v0.3.0-rc.1)
Tailwind-style utility classes for LiveView Native.
Modifier Translation
Modifiers can easily be translated to classes.
- Separate any arguments with a dash (
-
) - Use labels for any named arguments (
key:value
)
Modifier | Class |
---|---|
padding(.leading, 32) | padding-leading-32 |
frame(width: 100, height: 100) | frameWidth:100-height:100 |
buttonStyle(.borderedProminent) | buttonStyle-borderedProminent |
Attribute References
To reference an attribute value, use [attr(attribute-name)]
:
<Group class="offset-y:[attr(offset)]" offset="5">
Complex Arguments
Complex types (such as a gradient ShapeStyle
) can be provided by writing out the full syntax as an argument.
<Rectangle class="fg(LinearGradient(colors:[.red,.blue],startPoint:.leading,endPoint:.trailing))" />
<Image class="font(.system(size:70))" />
[!NOTE] Spaces cannot be used within class names.
Spaces and Underscores
To include a space in a string argument, use and underscore ['Hello,_world!']
.
Any underscores will be replaced with a space.
<Group class="navigationTitle-['Hello_World']">
If you need to include an underscore character, escape it with _
.
<Group class="navigationTitle-['Hello_World']">
Shorthand
Some aliases are provided to make common classes easier to use.
Alias | Expansion |
---|---|
px | padding-horizontal |
py | padding-vertical |
pt | padding-top |
pr | padding-trailing |
pb | padding-bottom |
pl | padding-leading |
pl | padding-leading |
p | padding |
w- | frame-width: |
h- | frame-height: |
min-w- | frame-minWidth: |
max-w- | frame-maxWidth: |
min-h- | frame-minHeight: |
max-h- | frame-maxHeight: |
fg | foregroundStyle |
bg | background |
overlay-- | overlay-content:: |
bg-- | background-content:: |
mask-- | mask-mask:: |
toolbar-- | toolbar-content:: |
safe-area-inset-- | safeAreaInset-content:: |