6.0.0 • Published 6 years ago

react-ladda v6.0.0

Weekly downloads
8,449
License
MIT
Repository
github
Last release
6 years ago

react-ladda

Build Status Dependency Status NPM version Code Climate

A React wrapper for Ladda buttons. Example

Installation

react-ladda can be installed directly through npm:

$ npm install --save react-ladda

Usage

LaddaButton is a React component that renders a Ladda button. You can change the button's loading state and progress using the loading and progress props.

import React, { Component } from 'react';

import LaddaButton, { XL, SLIDE_UP } from 'react-ladda';

class App extends Component {

  state = { loading: false };

  toggle() {
    this.setState({
      loading: !this.state.loading,
      progress: 0.5,
    });
  }

  render() {
    return (
      <LaddaButton
        loading={this.state.loading}
        onClick={this.toggle}
        data-color="#eee"
        data-size={XL}
        data-style={SLIDE_UP}
        data-spinner-size={30}
        data-spinner-color="#ddd"
        data-spinner-lines={12}
      >
        Click Here!
      </LaddaButton>
    );
  }
};

ReactDOM.render(<App />, document.body);

Although this package doesn't include the styles for the Ladda buttons, there are many different ways to include them. The easiest way is to add the following tag to your document:

<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/Ladda/1.0.0/ladda.min.css">

Props

All of the native Ladda button options are supported through props:

PropTypeDescription
loadingbooleanDisplays the button's loading indicator
progressnumberNumber from 0.0 to 1.0
data-colorstringColor applied to the button (eg. #222)
data-sizestringA button size
data-stylestringA button style
data-spinner-sizenumberNumber representing the size of the spinner in pixels
data-spinner-colorstringColor applied to the spinner (eg. #eee)
data-spinner-linesnumberNumber of spokes in the spinner

Sizes and Styles

Ladda comes with a variety of different sizes and styles that you can use. Button sizes and styles can be directly imported from react-ladda:

import LaddaButton, { XS, EXPAND_LEFT } from 'react-ladda'

Sizes

  • XS
  • S
  • L
  • XL

Styles

  • CONTRACT
  • CONTRACT_OVERLAY
  • EXPAND_LEFT
  • EXPAND_RIGHT
  • EXPAND_UP
  • EXPAND_DOWN
  • SLIDE_LEFT
  • SLIDE_RIGHT
  • SLIDE_UP
  • SLIDE_DOWN
  • ZOOM_IN
  • ZOOM_OUT

Development

After cloning and running npm install, you can use the following npm commands for easier development:

CommandDescription
npm testRuns the test suite
npm run watchRuns the test suite and reruns when any source or test file changes
npm run lintLints both the source and test files
npm run buildCompiles the source into ES5 and outputs the results into dist

Contributions are more than welcome!

6.0.0

6 years ago

5.0.7

7 years ago

5.0.6

7 years ago

5.0.5

7 years ago

5.0.4

7 years ago

5.0.3

8 years ago

5.0.2

8 years ago

5.0.1

8 years ago

5.0.0

8 years ago

4.0.5

8 years ago

4.0.4

8 years ago

4.0.3

8 years ago

4.0.2

8 years ago

4.0.1

8 years ago

4.0.0

9 years ago

3.1.0

9 years ago

3.0.0

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.1

10 years ago

1.0.0

10 years ago

0.2.4

10 years ago

0.2.3

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago