1.0.6 • Published 3 years ago

fitr-svg-text v1.0.6

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

fitr-svg-text

React text component that fits the text within svg to specified dimensions and position.

Install

npm install --save fitr-svg-text

Usage

import React from 'react';
import ReactDOM from 'react-dom';
import FitrSvgText from 'fitr-svg-text';

ReactDOM.render(
  <svg id="some-svg-container" viewBox="0 0 400 200" >
    <FitrSvgText
      text='This should fit in 200px'
      width={200}
      maxHeight={80}
      x={200}
      y={100}
      textAnchor='middle'
    />
  </svg>,
  document.getElementById('root')
);

API

NameTypeDefaultDescription
textstring-Text to render
widthnumber-Width to fit text to
maxHeightnumber-Limit height so text can not grow to much if there is for example only 2 characters but width is 400px
xnumber-x position of text relative to parent svg. It respects the text-achor property
ynumber-y position of text baseline relative to parent svg
textAnchorstring'start'native text-anchor accepting one of 'start', 'middle' or 'end' https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/text-anchor

Develop

  1. run npm install
  2. run npm start
  3. go to http://localhost:9001/

Generate static doc

run npm run static-docs to generate docs in docs folder

License

fitr-svg-text is released under the MIT license.

1.0.6

3 years ago

1.0.5

4 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago