适用于 React.js 的 Material Design 旋转组件。
Material Design spinner components for React.js.
Live example: https://tsuyoshiwada.github.io/react-md-spinner/
You can install the react-md-spinner from npm.
$ npm i -S react-md-spinner
# or
$ yarn add react-md-spinnerBecause it is made of 100% inline styles, you can start using it right away without setting.
import React from "react";
import MDSpinner from "react-md-spinner";
export const SpinnerExample: React.FC = () => (
);The following is an example of Server-Side Rendering.
Please checkout examples directory for details.
The point is to use ssrBehavior.
Note: The following is pseudo code.
Client-Side:
import React from "react";
import { render } from "react-dom";
import App from "./App";
render(, document.getElementById("app"));Server-Side:
import { ssrBehavior } from "react-md-spinner";
// ...
const html = (root: JSX.Element) => `
${ssrBehavior.getStylesheetString()}
`;
app.get("/", (_req, res) => {
res.status(200).send(`${renderer()}`);
});App:
import React from "react";
import MDSpinner from "react-md-spinner";
export const App: React.FC = () => (
);You can use the following Props. All Props are Optional!
sizetype: number
default: 28
Set the size (diameter) of the spinner circle.
borderSizetype: number
default: undefined
Set the spinner border size of. By default, the appropriate size is calculated according to the value of size.
durationtype: number
default: 1333
Set the animation duration (ms) of the spinner.
color1type: string
default: !rgb(66, 165, 245)
The color of the spinner. Can be set to any valid CSS string (hex, rgb, rgba).
color2type: string
default: rgb(239, 83, 80)
Same as above.
color3type: string
default: rgb(253, 216, 53)
Same as above.
color4type: string
default: rgb(76, 175, 80)
Same as above.
singleColortype: string
default: undefined
Same as above. Use this if the spinner should be in only one single color. The settings (props) for color1 ~ 4 will be ignored by setting this singleColor property.
ssrBehaviorIn Server-Side Rendering you need to inject @keyframes inside the ``.react-md-spinner provides utilities to handle them.
ssrBehavior.getStylesheetString(): stringssrBehavior.getStylesheetComponent(): React.ReactNodeimport { ssrBehavior } from "react-md-spinner";
const html = () => `
${ssrBehavior.getStylesheetString()}
`;import React from "react";
import { ssrBehavior } from "react-md-spinner";
const Html: React.FC = () => (
{ssrBehavior.getStylesheetComponent()}
);See CHANGELOG.md
We are always welcoming your contribution :clap:
$ yarn test command and confirm that it passes :zap:master branch :bulb:yarn testRun unit test using Jest.
yarn lintRun Lint of source code using ESLint.
yarn formatRun formatting using Prettier and ESLint's Fixer.
yarn buildRun build of TypeScript code.
yarn storybookRun Storybook.
暂无开放 Issues,或尚未同步最近议题。