百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

css-to-react-native

> 编程语言
开源

将 CSS 文本转换为 React Native 样式表对象

1.2K stars0 点赞1 次浏览
访问官网GitHub

工具介绍

将 CSS 文本转换为 React Native 样式表对象

css-to-React-native 将 CSS 文本转换为 React Native 样式表对象。 ```css

font-size: 18px; line-height: 24px; color: red; js { fontSize: 18, lineHeight: 24, color: 'red', } 将所有数字类型的值转换为数字, 将字符串类型的值转换为字符串。 自动将间接值转换为 React Native 的等价值。css text-shadow-offset: 10px 5px; font-variant: small-caps; transform: translate(10px, 5px) scale(5); js { textShadowOffset: { width: 10, height: 5 }, fontVariant: ['small-caps'], // Fixes backwards transform order transform: [ { translateY: 5 }, { translateX: 10 }, { scale: 5 }, ] } 还允许简写值。css font: bold 14px/16px "Helvetica"; margin: 5px 7px 2px; js { fontFamily: 'Helvetica', fontSize: 14, fontWeight: 'bold', fontStyle: 'normal', fontVariant: [], lineHeight: 16, marginTop: 5, marginRight: 7, marginBottom: 2, marginLeft: 7, } ``` 简写值只接受 React Native 中支持的值, 因此 background 只接受颜色, backgroundColor 不接受图像, font 不接受 React Native 不支持的字体变体值。

React Native 的 box-shadow 和 filter 属性会被转换为 boxShadow 和 filter,因此支持取决于您的 React Native 版本。

CSS 输入 React Native 输出
align-content alignContent
background-color backgroundColor
border-top-left-radius borderTopLeftRadius
font-size fontSize
justify-content justifyContent
text-decoration-color textDecorationColor
text-shadow-radius textShadowRadius

该规则涵盖了标准的一对一映射

Try it here

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScript

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言