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.

  1. Separate any arguments with a dash (-)
  2. Use labels for any named arguments (key:value)
ModifierClass
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.

AliasExpansion
pxpadding-horizontal
pypadding-vertical
ptpadding-top
prpadding-trailing
pbpadding-bottom
plpadding-leading
plpadding-leading
ppadding
w-frame-width:
h-frame-height:
min-w-frame-minWidth:
max-w-frame-maxWidth:
min-h-frame-minHeight:
max-h-frame-maxHeight:
fgforegroundStyle
bgbackground
overlay--overlay-content::
bg--background-content::
mask--mask-mask::
toolbar--toolbar-content::
safe-area-inset--safeAreaInset-content::

Summary

Functions

Link to this function

parse_arguments(arguments)

View Source
Link to this macro

sigil_RULES(arg, modifier)

View Source (macro)