Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dazulu/react-spoiler-tag

React component to cover text you do not want visible until user interaction
https://github.com/dazulu/react-spoiler-tag

Last synced: 19 days ago
JSON representation

React component to cover text you do not want visible until user interaction

Awesome Lists containing this project

README

        


React Spoiler Text Component




Lightweight, accessible React component to hide text until the user clicks.


example of component in action






## Install

```bash
npm install react-spoiler-tag
```

or

```bash
yarn add react-spoiler-tag
```

## Basic Usage

```jsx
import { Spoiler } from 'react-spoiler-tag'
import 'react-spoiler-tag/dist/index.css'

const SomeComponent = () => {
return
}
```

### With prop

```html

```

### With children

Passing in children is supported, **however**, as of now only with lines of text in mind. Wrapping complex entities like a card, list, image, table, etc. will yield undesired results.

```html
Super secret link!
```

## Props

```html

```

`text` - (Optional) Text to be covered by the spolier effect - ``

`color` - (Optional) CSS _color_ value for the text. Default: _"inherit"_ - ``

`hiddenColor` - (Optional) CSS _background-color_ value for the hidden background color. Default: _"#444"_ - ``

`revealedColor` - (Optional) CSS _background-color_ value for the revealed background color. Default: _"#e2e2e2"_ - ``

`ariaLabelShowText` - (Optional) Text for screenreaders when component is focused in hidden state. Default: _"To reveal spoiler text click here."_ - ``

`ariaLabelHideText` - (Optional) Text for screenreaders when component is focused in revealed state. Default: _"To hide spoiler text again click here."_ - ``

## Note on accessibility (a11y)

It is highly recommended to make use of the props `ariaLabelShowText` and `ariaLabelHideText`, if you are serving this component in other languages, as the default text for them is in English.

## Roadmap

- Support complex children content

## License

MIT © [dazulu](https://github.com/dazulu)