@ezflawless/components
TypeScript icon, indicating that this package has built-in type declarations

1.0.14 • Public • Published

components

Slider

A slideshow component for cycling through elements—images or slides of text—like a carousel.

How it works

It accepts an array of React Elements as children. It only renders the active element and two elements next to it.

Usage

const nextSlideButtonRef = useRef<HTMLButtonElement>(null)
const prevSlideButtonRef = useRef<HTMLButtonElement>(null)

const [key, setKey] = useState<Key | null>(null)
const [items, setItems] = useState<number[]>([1,2,3,4,5])

return (
    <div style={{position: 'relative'}}>
        <button ref={nextSlideButtonRef} style={{position: 'absolute', top: 50, right: 0,}}>Next</button>
        <button ref={prevSlideButtonRef} style={{position: 'absolute', top: 50, left: 0,}}>prev</button>
        <Slider
          nextButtonRef={nextSlideButtonRef}
          prevButtonRef={prevSlideButtonRef}
          onSlide={(newKey: SetStateAction<Key | null>, newIndex: any) => setKey(newKey)}
        >
        {items.map(item => (
            <div key={item}>
                {item}
            </div>
        ))}
        </Slider>
        <div style={{display: 'flex'}}>
          {items.map((item, index) => (
              <h6 key={item} style={{color: item === key ? 'red' : 'black'}}>
                {index + 1}
              </h6>
          ))}
        </div>
    </div>
)

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.140latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @ezflawless/components

Weekly Downloads

0

Version

1.0.14

License

ISC

Unpacked Size

89.3 kB

Total Files

54

Last publish

Collaborators

  • ezflawless