Styling

Components use CSS styles + flexbox layout.

Layout Styles

propertytypesupported?
shadowColorColorβœ…
shadowOffset{ width: number, height: number }βœ…
shadowOpacitynumberβœ…
shadowSpreadnumberβ›”
shadowRadiusnumberβœ…
widthnumber | percentageβœ…
heightnumber | percentageβœ…
topnumber | percentageβœ…
leftnumber | percentageβœ…
rightnumber | percentageβœ…
bottomnumber | percentageβœ…
minWidthnumber | percentageβœ…
maxWidthnumber | percentageβœ…
minHeightnumber | percentageβœ…
maxHeightnumber | percentageβœ…
marginnumber | percentageβœ…
marginVerticalnumber | percentageβœ…
marginHorizontalnumber | percentageβœ…
marginTopnumber | percentageβœ…
marginBottomnumber | percentageβœ…
marginLeftnumber | percentageβœ…
marginRightnumber | percentageβœ…
paddingnumber | percentageβœ…
paddingVerticalnumber | percentageβœ…
paddingHorizontalnumber | percentageβœ…
paddingTopnumber | percentageβœ…
paddingBottomnumber | percentageβœ…
paddingLeftnumber | percentageβœ…
paddingRightnumber | percentageβœ…
positionabsolute | relativeβœ…
flexDirectionrow | row-reverse | column | column-reverseβœ…
flexWrapwrap | nowrapβœ…
justifyContentflex-start | flex-end | center | space-between | space-aroundβœ…
alignItemsflex-start | flex-end | center | stretchβœ…
alignSelfauto | flex-start | flex-end | center | stretchβœ…
overflowvisible | hidden | scrollβœ…
flexnumberβœ…
flexGrownumberβœ…
flexShrinknumberβœ…
flexBasisnumber | percentageβœ…
aspectRationumberβœ…
zIndexnumberβ›”
backfaceVisibilityvisible | hidden⛔️
backgroundImagestring | {uri: string} βœ…
backgroundColorColorβœ…
borderColorColorβœ…
borderTopColorColorβ›”
borderRightColorColorβ›”
borderBottomColorColorβ›”
borderLeftColorColorβ›”
borderRadiusnumber | percentageβœ…
borderTopLeftRadiusnumber | percentageβœ…
borderTopRightRadiusnumber | percentageβœ…
borderBottomLeftRadiusnumber | percentageβœ…
borderBottomRightRadiusnumber | percentageβœ…
borderStylesolid | dotted | dashedβ›”
borderWidthnumber | percentageβœ…
borderTopWidthnumber | percentageβ›”
borderRightWidthnumber | percentageβ›”
borderBottomWidthnumber | percentageβ›”
borderLeftWidthnumber | percentageβ›”
opacitynumberβœ…

Type Styles

propertytypesupported?
ColorColorβœ…
fontFamilystringβœ…
fontSizenumberβœ…
fontStylenormal | italic | solidβœ…
fontWeight'normal' | 'bold' | '100' | '200' | ... | '900'βœ…
textDecorationLinenone | underline | line-throughβœ…
textShadowOffset{ width: number, height: number }βœ…
textShadowRadiusnumberβœ…
textShadowColorColorβœ…
letterSpacingnumber | percentageβœ…
lineHeightauto | number | percentageβœ…
textAlignauto | left | right | center | justifyβœ…
writingDirectionauto | ltr | rtl⛔️
opacitynumberβœ…
percentagepoints | percentagesβœ…

Styles can be passed to components as plain objects.

import { View, StyleSheet } from 'react-figma';
// inline props
<View
style={{
backgroundColor: 'hotPink',
width: 300,
}}
/>
// plain JS object
const style = {
backgroundColor: 'hotPink',
width: 300,
}
<View style={style} />
// StyleSheet
const styles = StyleSheet.create({
foo: {
backgroundColor: 'hotPink',
width: 300,
}
})
<View style={styles.foo} />
<View style={[styles.foo, styles.bar]} />

You can use variables in your styles just like a standard React application:

const colors = {
Haus: '#F3F4F4',
Night: '#333',
Sur: '#96DBE4',
Peach: '#EFADA0',
Pear: '#93DAAB',
};
<View>
{Object.keys(colors).map(name => (
<View
key={name}
style={{
flex: 1,
backgroundColor: colors[name],
}}
/>
))}
</View>;

Inheritance

It's possible to enable a CSS-like inheritance.

Available under the flag process.env.REACT_FIGMA_STYLE_INHERITANCE_ENABLED.

An example:

<View style={{ fontSize: 50, fontWeight: 'bold', fontFamily: 'Roboto' }}>
<View style={{ fontSize: 48 }}>
<View style={{ width: 200, height: 100, backgroundColor: '#dd55aa' }} />
<Text style={{ color: '#ffffff' }}>text</Text>
</View>
</View>

The text got a combined style:

({fontWeight: 'bold', fontFamily: 'Roboto', fontSize: 48, color: '#ffffff' })

Inherited styles props:

  • color
  • fontFamily
  • fontSize
  • fontStyle
  • fontVariant
  • fontWeight
  • textAlign
  • lineHeight
  • letterSpacing

Supported components:

  • Frame (and View)
  • Page
  • Text (as a recipient)

Warning! Inheritance is not compatible with React Native.

Web defaults

Available under the flag process.env.REACT_FIGMA_WEB_DEFAULTS_ENABLED.

On the Web defaults mode, react-figma will try to simulate Web default behavior:

  • A text with display: block should get full width (width: 100%)
  • A container with display: flex should get flexDirection: row
  • alignItems: stretch for containers by default