Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-awesome-slider

> 前端框架
Open source

A performant, lightweight React slider/carousel for media and content transitions, featuring 60fps animations, modular styling, optional HOCs, and fullpage navi

3.0K stars0 likes2 views
WebsiteGitHub

About

A performant, lightweight React slider/carousel for media and content transitions, featuring 60fps animations, modular styling, optional HOCs, and fullpage navi

React <AwesomeSlider />

@rcaferati/react-awesome-slider provides a fast, production-ready slider/carousel with optional HOCs:

  • AwesomeSlider — animated media/children slider
  • withAutoplay — autoplay wrapper
  • withCaptionedImages — caption overlay wrapper
  • withAnimatedLettering — “screens → <p> lines” wrapper
  • Navigation utilities — Provider, Link, withNavigationContext, withNavigationHandlers

This README is updated for the current v5 patterns (functional core + CSS variables + optional CSS Modules support).


Preview


Installation

bash
npm install @rcaferati/react-awesome-slider

Peer dependencies:

  • react >= 18
  • react-dom >= 18

Quick Start

Plain CSS (no CSS Modules)

javascript
import React from 'react';
import AwesomeSlider from '@rcaferati/react-awesome-slider';
import '@rcaferati/react-awesome-slider/styles.css';

export default function Example() {
  return (
    <AwesomeSlider>
      

      

    </AwesomeSlider>
  );
}

Media mode

javascript
import React from 'react';
import AwesomeSlider from '@rcaferati/react-awesome-slider';
import '@rcaferati/react-awesome-slider/styles.css';

export default function Example() {
  return (
    <AwesomeSlider
      media={[
        { source: '/img/0.jpg', slug: 'a' },
        { source: '/img/1.jpg', slug: 'b' },
      ]}
    />
  );
}

AwesomeSlider Props (current)

Prop Type Default Description
media MediaItem[] [] Slides as objects ({ source, slug, preload? }).
children ReactNode null Slides as React children (supports data-src / data-slug).
selected number | string 0 Active slide index (number) or slug (string).
name string 'awesome-slider' Instance name (useful when multiple sliders are present).
animation string | null null Animation key (cubeAnimation, fallAnimation, etc). Omit for default side animation.
buttons boolean true Show next/prev buttons.
bullets boolean true Show bullets.
organicArrows boolean true Use the organic arrow shape styling.
infinite boolean true Wrap-around navigation.
fillParent boolean false Fill parent bounds (fullscreen layouts).
startupScreen ReactNode null Optional startup screen shown before first slide.
startup boolean true If startupScreen is set, whether to auto-start into the first slide.
startupDelay number 0 Delay before auto-start.
transitionDelay number 0 Delay before starting transition animation (ms).
controlsReturnDelay number 0 Delay to remove the “controls active” class after transitions (ms).
mobileTouch boolean true Enables touch/swipe navigation.
cssModule object | object[] | null null CSS module map(s) used to map class names.
className string | null null Extra className(s) added to the root element.
style React.CSSProperties {} Inline styles, including CSS variable overrides.
onFirstMount (info) => void null Called once after mount with getInfo() payload.
onTransitionStart (info) => void null Called on transition start.
onTransitionEnd (info) => void null Called on transition end.
onTransitionRequest (info) => void null Called when the user requests a transition (next/prev/bullet).
onTransitionReject (info) => void null Called when a transition is rejected (for example, busy/loading).
onLoadStart (payload) => void null Optional custom preload hook. Call payload.next() when ready.

getInfo() payload (high level)

getInfo() is used by the event callbacks and includes, best-effort:

  • slides — slide count
  • currentIndex — current index
  • currentMedia — current media item
  • currentSlide — active slide element (when available)
  • element — slider root element

HOCs

Autoplay

javascript
import React from 'react';
import AwesomeSlider from '@rcaferati/react-awesome-slider';
import withAutoplay from '@rcaferati/react-awesome-slider/autoplay';
import '@rcaferati/react-awesome-slider/styles.css';

const AutoplaySlider = withAutoplay(AwesomeSlider);

export default function Example() {
  return (
    <AutoplaySlider
      play={true}
      cancelOnInteraction={false}
      interval={6000}
      media={[
        { source: 'https://picsum.photos/id/1018/1200/600' },
        { source: 'https://picsum.photos/id/1015/1200/600' },
      ]}
    />
  );
}

Captioned Images

…

Animated Lettering

…

Adaptive Controls

Adaptive Controls is currently part of the repository work and Storybook examples, but it is not listed as a public package export in the current package exports map.

That means:

  • it is available in the source repository
  • it is not currently documented here as a stable public import path from the npm package

If and when it becomes a public export, it should be documented with its exact import path.


Fullpage Navigation Utilities

These are designed for SPA / “slides-as-routes” setups.

Provider

javascript
import React from 'react';
import { Provider } from '@rcaferati/react-awesome-slider/navigation';

export default function App({ children }) {
  return (
    <Provider slug={window.location.pathname} defaultSlug="home">
      {children}
    </Provider>
  );
}

Link

javascript
import React from 'react';
import { Link } from '@rcaferati/react-awesome-slider/navigation';

export default function Nav() {
  return (
    <nav>
      <Link href="/home">Home</Link>
      <Link href="/about">About</Link>
      <Link href="/contact">Contact</Link>
    </nav>
  );
}

withNavigationHandlers

Wrap a slider so URL ↔ slider selection stays aligned.

javascript
import React from 'react';
import AwesomeSlider from '@rcaferati/react-awesome-slider';
import { withNavigationHandlers } from '@rcaferati/react-awesome-slider/navigation';

const SliderWithNav = withNavigationHandlers(AwesomeSlider);

export default function Page() {
  return <SliderWithNav />;
}

withNavigationContext

If you need raw navigation state + setter injected into a component:

javascript
import React from 'react';
import { withNavigationContext } from '@rcaferati/react-awesome-slider/navigation';

function Status(props) {
  const { fullpage } = props;
  return <pre>{JSON.stringify(fullpage.navigation, null, 2)}</pre>;
}

export default withNavigationContext(Status);

Recommended patterns (current)

✅ Prefer media for stable routing

If you use slugs + navigation handlers, keep media entries stable and include slug.

✅ Keep animations modular

  • Always load styles.css
  • Load one extra animation CSS only when that animation is selected
  • If you use animation module objects with cssModule, still import the matching .css file

✅ Customize via CSS variables first

Theme, contrast, and visual polish are usually easiest via the exposed custom properties.

✅ Use CSS module exports only when your bundler supports them

For the widest compatibility:

  • use styles.css
  • use captioned.css
  • use lettering.css
  • use custom-animations/*.css

Use @rcaferati/react-awesome-slider/styles or @rcaferati/react-awesome-slider/custom-animations/* module exports only when your bundler setup expects JS style-module entries, and pair them with the corresponding CSS file imports.


Author

Rafael Caferati
Website: https://caferati.dev
GitHub: https://github.com/rcaferati


License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptcarouselcarousel-componentfullpage-navigation-hocgallery

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架