Skip to main content

Function: flatten()

flatten<T>(style?): SizableStyleProps<T> extends U[] ? U : SizableStyleProps<T> | Omit<SizableStyleProps<T> extends U[] ? U : SizableStyleProps<T> & object & Record<"zIndex", unknown>, "zIndex">

Defined in: utils/style.ts:103

Flattens a style prop into a single style object.

Type Parameters​

T​

T extends object

Parameters​

style?​

StyleProp<SizableStyleProps<T>>

The style prop to flatten

Returns​

SizableStyleProps<T> extends U[] ? U : SizableStyleProps<T> | Omit<SizableStyleProps<T> extends U[] ? U : SizableStyleProps<T> & object & Record<"zIndex", unknown>, "zIndex">

Flattened style object

Example​

const flattenedStyle = Styler.flatten([
{ padding: 10 },
{ margin: 5 },
{ backgroundColor: 'red' }
]);