导言
一个允许您使用 CSS 的库, 在您的 React and React Industrial 项目中, 以现代, 强大和灵活的方式使用 . gluestack-style 允许您使用 JavaScript 编写 CSS,这使得您能够利用两种语言的力量和表达力. 凭借其简单而直观的API,可以轻松地创建动态风格,响应性设计,并处理应用程序的主题.
文档
您可以在以下表格中查找每个组件的详细文档,包括道具和示例清单: https://gluestack.io/style/docs/getting-启动/安装 网站.
安装
用于 @gluestack-style/react,你只需要安装
@gluestack-style/react 软件包及其同行依赖性:
$ yarn add @gluestack-style/react react-native-web react-native-svg
# or
$ npm i @gluestack-style/react react-native-web react-native-svg
使用量
用来使用 @gluestack-style/react 在项目中,请遵循这些步骤:
- 用
StyledProvider国家 @ gluestack 风格/ 反应。 。 。 .
import { StyledProvider } from '@gluestack-style/react';
// Do this at the root of your application
function App({ children }) {
return <StyledProvider>{children}</StyledProvider>;
}
- 现在你可以用
@gluestack-style/react样式styled函数由库提供。 例如:
import React from 'react';
import { styled } from '@gluestack-style/react';
const StyledButton = styled(
Pressable,
{
bg: '$red500',
p: '$3',
},
{}
);
const StyledButtonText = styled(Text, {}, {});
export const App = () => {
return (
<StyledProvider>
<StyledButton>
<StyledButtonText>Button</StyledButtonText>
</StyledButton>
</StyledProvider>
);
};
更多关于如何启动的指南 这里。 。 。 .