Skip to content

Commit

Permalink
Merge pull request #11 from dkonasov/autohide-docs
Browse files Browse the repository at this point in the history
docs for autohide
  • Loading branch information
dkonasov authored Apr 30, 2024
2 parents 15f2795 + 9cd97ce commit 976c58e
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions react-ux-semantics-docs/docs/docs/autohide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
sidebar_position: 2
title: Autohide
---

## General description

Basic hook, that allows you to manage visiblity state of smth, e.g. dialog, modal or popup. Additionaly, it automatically hides after specified amount of time (default is 5000 ms.)

## Usage example

```jsx
export const ComponentWithVisiblityManagement = () => {
const [ isToastVisible, showToast, hideToast ] = useAutohide(200);

return (
<>
<button type="button" onClick={showToast}>Click me!</button>
<Toast visible={isToastVisible} onClose={hideToast} />
</>
)
};
```

## API

### useAutohide

```ts
declare function useShowable(time: number): [boolean, () => void, () => void];
```

#### Arguments

|arg|type|description|
|:--|:---|:----------|
|`time`|`number`|An interval, after which visibility will be changed to false|


Returns a tuple with current visibility status, show function and hide function.

0 comments on commit 976c58e

Please sign in to comment.