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!
Property | Value |
---|---|
alignContent | , , , , ,
|
alignItems | , , , ,
|
alignSelf | , , , , ,
|
backgroundColor | Identifier, , , ,
|
borderBottomColor | Identifier, , , ,
|
borderBottomLeftRadius | Integer, Float,
|
borderBottomRightRadius | Integer, Float,
|
borderBottomWidth | Integer, Float,
|
borderColor | Identifier, , , ,
|
borderLeftColor | Identifier, , , ,
|
borderLeftWidth | Integer, Float,
|
borderRadius | Integer, Float,
|
borderRightColor | Identifier, , , ,
|
borderRightWidth | Integer, Float,
|
borderStyle | , , ,
|
borderTopColor | Identifier, , , ,
|
borderTopLeftRadius | Integer, Float,
|
borderTopRightRadius | Integer, Float,
|
borderTopWidth | Integer, Float,
|
borderWidth | Integer, Float,
|
bottom | Integer, Float,
|
direction | ,
|
flexBasis | Integer, Float, ,
|
flexDirection | , , ,
|
flexGrow | Integer |
flexShrink | Integer |
flexWrap | ,
|
height | Integer, Float,
|
justifyContent | , , , , ,
|
left | Integer, Float,
|
margin | Integer, Float,
|
marginBottom | Integer, Float,
|
marginLeft | Integer, Float,
|
marginRight | Integer, Float,
|
marginTop | Integer, Float,
|
maxHeight | Integer, Float,
|
maxWidth | Integer, Float,
|
minHeight | Integer, Float,
|
minWidth | Integer, Float,
|
opacity |
|
padding | Integer, Float,
|
paddingBottom | Integer, Float,
|
paddingLeft | Integer, Float,
|
paddingRight | Integer, Float,
|
paddingTop | Integer, Float,
|
position | ,
|
right | Integer, Float,
|
top | Integer, Float,
|
width | Integer, Float,
|
color | Identifier, , , ,
|
fontFamily | String |
fontStyle | ,
|
fontWeight | , , , , , , , ,
|
letterSpacing | Integer, Float |
lineHeight | Integer, Float |
textAlign | , , , ,
|
textAlign | , ,
|
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}