メインコンテンツへスキップ

stylex.create

スタイル オブジェクトのマップを受け取り、コンパイルされた StyleX スタイルのオブジェクトを返します。コンパイルされた StyleX スタイルは、キーとクラス名のマッピングです。

function create<T extends {[key: string]: RawStyles | (...any[]) => RawStyles}>(
styles: T,
): {[Key in keyof T]: StyleXStyles<T[Key]>};

使用例:

import * as stylex from '@stylexjs/stylex';

const styles = stylex.create({
root: {
backgroundColor: 'red',
padding: '1rem',
paddingInlineStart: '2rem',
},
dynamic: (r, g, b) => ({
color: `rgb(${r}, ${g}, ${b})`,
}),
});