概要
A React renderer for rendering hand-drawn SVGs.
デザイン・メディア計測したスター増加
- 24時間
- 0
- 7日間
- 0
- 15日間
- +1
- 1か月
- 更新が遅れています
期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。
README.md
オリジナルReact Rough Fiber

react-rough-fiber -- A React renderer for rendering hand-drawn SVGs.
Installation
npm install react-rough-fiber react-reconciler
If you are using React 18, you need to install [email protected]; If you are still using React 17, you can install [email protected]
Quick Start
To render the SVG in a hand-drawn style, you only need to add three lines of code:
import { RoughSVG } from 'react-rough-fiber'
export default function App() {
return (
<RoughSVG>
<svg viewBox="0 0 128 128" width="128" height="128">
<circle cx={64} cy={64} r={48} stroke="currentColor" fill="#82ca9d" />
</svg>
</RoughSVG>
)
}

Usage
react-rough-fiber can integrate with many existing SVG-based libraries:


API
RoughSVG
import { RoughSVG } from "react-rough-fiber";
// ... your component code
<RoughSVG containerType="div" options={options}>
{/* your SVG */}
</RoughSVG>
- containerType = 'div': The type of container to use for the
RoughSVG. Optional. - options: RoughOptions | ((shape: SVGShape, props: React.HTMLAttributes) => RoughOptions = {}. It can be a
RoughOptionsfor Rough.js. Also support a function that returnsRoughOptions. Optional.
WCRoughSVG
WCRoughSVGis only compatible with React version 18.0.0 or later.
import { WCRoughSVG } from "react-rough-fiber";
// ... your component code
<WCRoughSVG containerType="div" options={options}>
{/* your SVG */}
</WCRoughSVG>
If you want to use context in RoughSVG, you can use WCRoughSVG instead of RoughSVG. See FAQ for more details.
All parameters of WCRoughSVG are identical to RoughSVG.
Development
This library is a monorepo project. The core package can be found under /packages/react-rough-fiber, and the docs are under /apps/docs
- clone this repo
- run
pnpm installto install dependencies - run
pnpm dev, and openlocalhost:3000to view the documentation. - run
pnpm testto run tests.
PRs are welcome!
How does it work?
See my blog.
Showcases
Credits
react-rough-fiber is powered or inspired by these open source projects:
License
MIT
関連プロジェクトを探す
読み込み中…