1.1.7 • Published 4 years ago

react-spoiler-tag v1.1.7

Weekly downloads
1
License
MIT
Repository
github
Last release
4 years ago

Install

npm install react-spoiler-tag

or

yarn add react-spoiler-tag

Basic Usage

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

const SomeComponent = () => {
  return <Spoiler text='Super secret spoiler!' />
}

With prop

<Spoiler text="Super secret spoiler!" />

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.

<Spoiler>Super secret <a>link</a>!</Spoiler>

Props

<Spoiler
  text="Super secret spoiler!"
  textColor="#000"
  hiddenColor="#2a2a2a"
  revealedColor="#9a9a9a"
  ariaLabelShowText="To reveal spoiler text click here."
  ariaLabelHideText="To hide spoiler text again click here."
/>

text - (Optional) Text to be covered by the spolier effect - <string>

color - (Optional) CSS color value for the text. Default: "inherit" - <string>

hiddenColor - (Optional) CSS background-color value for the hidden background color. Default: "#444" - <string>

revealedColor - (Optional) CSS background-color value for the revealed background color. Default: "#e2e2e2" - <string>

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

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

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

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago