@ gluestack-ui/ 形式控制
安装
用于 @gluestack-ui/form-control,你只需要安装
@gluestack-ui/form-control 软件包 :
$ yarn add @gluestack-ui/form-control
# or
$ npm i @gluestack-ui/form-control
使用量
通过使用Form Control,开发者可以提供重要的上下文来形成元素. 此上下文可以包括元素是否无效,是否被禁用或是否需要. 以下是如何使用这个软件包来创建一个:
import {
Root,
Error,
ErrorText,
ErrorIcon,
Label,
LabelText,
LabelAstrick,
Helper,
HelperText,
} from '../components/core/form-control/styled-components';
import { createFormControl } from '@gluestack-ui/form-control';
const FormControl = createFormControl({
Root,
Error,
ErrorText,
ErrorIcon,
Label,
LabelText,
LabelAstrick,
Helper,
HelperText,
});
自定义窗体控制 :
所有这些组件的默认样式可以在组件/核心/形式控制文件中找到. 作为参考,你可以查看 源代码 样式 form-control 组件.
// import the styles
import {
Root,
Error,
ErrorText,
ErrorIcon,
Label,
LabelText,
LabelAstrick,
Helper,
HelperText,
} from '../components/core/form-control/styled-components';
// import the createFormControl function
import { createFormControl } from '@gluestack-ui/form-control';
// Understanding the API
const FormControl = createFormControl({
Root,
Error,
ErrorText,
ErrorIcon,
Label,
LabelText,
LabelAstrick,
Helper,
HelperText,
});
// Using the FormControl component
export default () => (
<FormControl>
<FormControlLabel>
<FormControlLabelText></FormControlLabelText>
</FormControlLabel>
<Input />
<FormControlHelper>
<FormControlHelperText></FormControlHelperText>
</FormControlHelper>
<FormControlError>
<FormControlErrorIcon>
<AlerCircleIcon />
</FormControlErrorIcon>
<FormControlErrorText></FormControlErrorText>
</FormControlError>
</FormControl>
);
更多关于如何启动的指南 这里。 。 。 .