npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-material-ui-carousel-with-customizable-icons

v2.1.2

Published

A Generic, extendible Carousel UI component for React using Material UI

Downloads

11

Readme

React Material UI Carousel

Description

A Generic, extendible Carousel UI component for React using Material UI
It switches between given children using a smooth animation.
Provides next and previous buttons. Also provides interactible bullet indicators.

Live Demo

Take a look at this interactible Live Demo

Installation

npm install react-material-ui-carousel --save

Note:

You will need to have material-ui installed, in order to use this library/component

npm install @material-ui/core
npm install @material-ui/icons

Usage Example

import React from 'react';
import Carousel from 'react-material-ui-carousel'
import {Paper} from '@material-ui/core'
import FiberManualRecordIcon from '@material-ui/icons/FiberManualRecord'
import NavigateBeforeIcon from '@material-ui/icons/NavigateBefore'
import NavigateNextIcon from '@material-ui/icons/NavigateNext'

function Example(props)
{
    var items = [
        {
            name: "Random Name #1",
            description: "Probably the most random thing you have ever seen!"
        },
        {
            name: "Random Name #2",
            description: "Hello World!"
        }
    ]

    return (
        <Carousel 
            IndicatorIcon={FiberManualRecordIcon}
            NextIcon={NavigateNextIcon}
            PrevIcon={NavigateBeforeIcon}
        >
            {
                items.map( (item, i) => <Item key={i} item={item} /> )
            }
        </Carousel>
    )
}

function Item(props)
{
    return (
        <Paper>
            <h2>{props.item.name}</h2>
            <p>{props.item.description}</p>

            <Button className="CheckButton">
                Check it out!
            </Button>
        </Paper>
    )
}

Next & Prev Usage

    <Carousel
        next={ (next, active) => console.log(`we left ${active}, and are now at ${next}`); }
        prev={ (prev, active) => console.log(`we left ${active}, and are now at ${prev}`); }
    >
        {...}
    </Carousel>

    // OR

    <Carousel
        next={ () => {/* Do stuff */} }
        prev={ () => {/* Do other stuff */} }
    >
        {...}
    </Carousel>

    // And so on...

Note: onChange works in a similar fashion. See Props below.

Props

| Prop name | Type | Default | Description | | ------------------------- | ------------------------------------------------------------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | className | string | "" | Defines custom class name(s), that will be added to Carousel element | | autoPlay | boolean | true | Defines if the component will auto scroll between children | | interval | number | 4000 | Defines the interval in ms between active child changes (autoPlay) | | indicators | boolean | true | Defines the existence of bullet indicators | | animation | "fade" \| "slide" | "fade" | Defines the animation style of the Carousel | | timeout | number \| {appear? number, enter?: number, exit?: number} | 500 | Defines the duration of the animation | | navButtonsAlwaysVisible | boolean | false | Defines if the next/previous buttons will always be visible or not | | navButtonsAlwaysInvisible | boolean | false | Defines if the next/previous buttons will always be invisible or not | | fullHeightHover | boolean | true | Defines if the the next/previous button wrappers will cover the full height of the Item element and show buttons on full height hover | | index | number | 0 | Defines which child (assuming there are more than 1 children) will be displayed. Next and Previous Buttons as well as Indicators will work normally after the first render. When this prop is updated the carousel will display the chosen child. Use this prop to programmatically set the active child. If (index > children.length) then if (strictIndexing) index = last element. index | | strictIndexing | boolean | true | Defines whether index can be bigger than children length | | indicatorProps | {className: string, style: React.CSSProperties} | undefined | Used to customize the non-active indicators | | activeIndicatorProps | {className: string, style: React.CSSProperties} | undefined | Used to customize the active indicator | | indicatorContainerProps | {className: string, style: React.CSSProperties} | undefined | Used to customize the indicators container/wrapper | | onChange | (index: number, active: number) => void (internally: Function) | () => {} | Function that is called after internal setActive() method. The setActive() method is called when the next and previous buttons are pressed, when an indicator is pressed, or when the index prop changes. First argument is the child we are going to display, while the second argument is the child that was previously displayed. Will be called in conjunction with and after next and prev props if defined. It will not get called in first render, except if changeOnFirstRender is defined | | changeOnFirstRender | boolean | false | Defines if onChange prop will be called when the carousel renders for the first time. In componentDidMount | | next | (next: number, active: number) => void (internally: Function) | () => {} | Function that is called after internal next() method. First argument is the child we are going to display, while the second argument is the child that was previously displayed | | prev | (prev: number, active: number) => void (internally: Function) | () => {} | Function that is called after internal prev() method. First argument is the child we are going to display, while the second argument is the child that was previously displayed | | IndicatorIcon | elementType | undefined | The React component that will be rendered for indicators. | | NextIcon | elementType | undefined | The React component that will be rendered for next button. | | PrevIcon | elementType | undefined | The React component that will be rendered for prev button. |

License

The MIT License.

Author

Learus