---
category: 2
title: 控制关闭状态
title_en: Controlled
---

 zh-CN

通过 `visible` 属性控制关闭状态。

 en-US

By using the `visible` prop, you can control the close state of Tag.

````jsx
import { Tag, Button } from 'parkball';

class Demo extends React.Component {
  state = {
    visible: true,
  }

  render() {
    return (
      <div>
        <Tag
          closable
          visible={this.state.visible}
          onClose={() => this.setState({ visible: false })}
        >
          Movies
        </Tag>
        <br />
        <Button
          size="small"
          onClick={() => this.setState({ visible: !this.state.visible })}
        >
          Toggle
        </Button>
      </div>
    );
  }
}

ReactDOM.render(<Demo />, mountNode);
````
