Styles

Styles

Styles are what Elodin is all about and thus the main building blocks of any Elodin file.
Simply put, they are a map of visual properties for a single specific component.

button.elo

style Button {
paddingLeft: 10
paddingRight: 10
width: percentage(50)
fontSize: 15
lineHeight: 1.3
}

Properties

Type-safety: The compiler will automatically throw an error and skip compilation if invalid properties are found.
This helps to ensure solid and type-safe styles.

Most properties are ported from React Native and can be implemented in most platforms as they're quite basic.
Layout is built using the flexbox layout model. If you're not familiar with that, make sure to check out React Native's flexbox documentation which is a great resource.
All properties are also available in CSS, so if you're coming from a web background - lucky you!

PropertyValue
alignContent
flexStart
,
flexEnd
,
center
,
stretch
,
spaceBetween
,
spaceAround
alignItems
flexStart
,
flexEnd
,
center
,
stretch
,
baseline
alignSelf
auto
,
flexStart
,
flexEnd
,
center
,
stretch
,
baseline
backgroundColorIdentifier,
rgb()
,
rgba()
,
hsl()
,
hsla()
borderBottomColorIdentifier,
rgb()
,
rgba()
,
hsl()
,
hsla()
borderBottomLeftRadiusInteger, Float,
percentage()
borderBottomRightRadiusInteger, Float,
percentage()
borderBottomWidthInteger, Float,
percentage()
borderColorIdentifier,
rgb()
,
rgba()
,
hsl()
,
hsla()
borderLeftColorIdentifier,
rgb()
,
rgba()
,
hsl()
,
hsla()
borderLeftWidthInteger, Float,
percentage()
borderRadiusInteger, Float,
percentage()
borderRightColorIdentifier,
rgb()
,
rgba()
,
hsl()
,
hsla()
borderRightWidthInteger, Float,
percentage()
borderStyle
solid
,
dashed
,
dotted
,
none
borderTopColorIdentifier,
rgb()
,
rgba()
,
hsl()
,
hsla()
borderTopLeftRadiusInteger, Float,
percentage()
borderTopRightRadiusInteger, Float,
percentage()
borderTopWidthInteger, Float,
percentage()
borderWidthInteger, Float,
percentage()
bottomInteger, Float,
percentage()
direction
ltr
,
rtl
flexBasisInteger, Float,
percentage()
,
auto
flexDirection
row
,
rowReverse
,
column
,
columnReverse
flexGrowInteger
flexShrinkInteger
flexWrap
wrap
,
nowrap
heightInteger, Float,
percentage()
justifyContent
flexStart
,
flexEnd
,
center
,
spaceBetween
,
spaceAround
,
spaceEvenly
leftInteger, Float,
percentage()
marginInteger, Float,
percentage()
marginBottomInteger, Float,
percentage()
marginLeftInteger, Float,
percentage()
marginRightInteger, Float,
percentage()
marginTopInteger, Float,
percentage()
maxHeightInteger, Float,
percentage()
maxWidthInteger, Float,
percentage()
minHeightInteger, Float,
percentage()
minWidthInteger, Float,
percentage()
opacity
percentage()
paddingInteger, Float,
percentage()
paddingBottomInteger, Float,
percentage()
paddingLeftInteger, Float,
percentage()
paddingRightInteger, Float,
percentage()
paddingTopInteger, Float,
percentage()
position
relative
,
absolute
rightInteger, Float,
percentage()
topInteger, Float,
percentage()
widthInteger, Float,
percentage()
colorIdentifier,
rgb()
,
rgba()
,
hsl()
,
hsla()
fontFamilyString
fontStyle
normal
,
italic
fontWeight
100
,
200
,
300
,
400
,
500
,
600
,
700
800
,
900
letterSpacingInteger, Float
lineHeightInteger, Float
textAlign
auto
,
left
,
right
,
center
,
justify
textAlign
none
,
underline
,
lineThrough

Raw Properties

Apart from built-in properties, we sometimes want to specify a platform specific property.
For example, the CSS

box-shadow
property is not available in Elodin, but if we know that we're building something for the web, we still might want to use it. This can be achieved by using raw properties.

Warning: Do not abuse raw properties. They're an escape hatch rather than a solid feature.
Keep in mind that they lack type-safety and might break other targets.

Raw properties are specified by a leading

__
and always take a RawValue value.

button.elo

style Button {
__boxShadow: raw("0 2px 6px rgb(80, 80, 80)")
paddingLeft: 10
paddingRight: 10
}