Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rax-checkbox

Package Overview
Dependencies
Maintainers
5
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rax-checkbox

Checkbox component for Rax.

  • 1.1.0-0
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-35.71%
Maintainers
5
Weekly downloads
 
Created
Source

npm 描述: CheckBox 是基础的选择框,选择框用图片实现,支持用户使用自己的图片进行替换

安装

$ npm install rax-checkbox --save

引用

import CheckBox from "rax-checkbox";

属性

注: 1、支持列表中的 browser代表 h5 weex代表 weex miniApp代表小程序

属性类型默认值必填描述支持
defaultCheckedbooleanfalse默认选中状态browser weex
checkedboolean-选中状态browser weex
checkedImagestring选中图片browser weex
uncheckedImagestring非选中图片browser weex
containerStyleCSSProperties-选择框容器样式browser weex
checkboxStyleCSSProperties-选择框图片样式browser weex
onChange(checked: boolean) => void-选择事件browser weex

基本示例

// demo
/** @jsx createElement */
"use strict";
import { createElement, render, useState } from "rax";
import DU from "driver-universal";
import Checkbox from "rax-checkbox";
import View from "rax-view";
import Text from "rax-text";

const App = () => {
  const [checked, setChecked] = useState(false);
  const [controlledCheckboxMsg, setControlledCheckboxMsg] = useState("");
  const [unControlledCheckboxMsg, setUncontrolledCheckboxMsg] = useState("");
  return (
    <View>
      <Text>Controlled: {controlledCheckboxMsg}</Text>
      <Checkbox
        checked={checked}
        onChange={hasChecked => {
          setControlledCheckboxMsg(`onChange => ${hasChecked}`);
        }}
      >
        {value => <Text>{value}</Text>}
      </Checkbox>
      <View
        style={{
          paddingLeft: 15,
          paddingRight: 15,
          backgroundColor: "#1890FF",
          width: 200,
          borderRadius: 15,
          alignItems: "center",
          justifyContent: "center"
        }}
        onClick={() => {
          setChecked(!checked);
        }}
      >
        <Text style={{ color: "#fff" }}>Click Me!</Text>
      </View>
      <Text>Uncontrolled: {unControlledCheckboxMsg}</Text>
      <Checkbox
        defaultChecked
        onChange={hasChecked => {
          setUncontrolledCheckboxMsg(`onChange => ${hasChecked}`);
        }}
      >
        {value => <Text>{value}</Text>}
      </Checkbox>
    </View>
  );
};

render(<App />, document.body, {
  driver: DU
});

Keywords

FAQs

Package last updated on 15 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc