React component that automatically fits the text to the element size. Ultra lightweight and efficient.
npm install @plutonium-js/react-fit-text
> npm install @plutonium-js/react-fit-text
`
:arrow_up_small:
$3
* Module
In ES6 the code example below imports the Fit Text component.
`javascript
import FitText from '@plutonium-js/react-fit-text';
`
Or when using CommonJS...
`javascript
const {FitText} = require('@plutonium-js/react-fit-text');
`
* CDN Script Tag
Add the component directly to a web page.
`html
`
:arrow_up_small:
$3
To create a basic fit text component add the 'FitText' tag to your JSX.
`jsx
class App extends Component {
render() {
return (
Add your text to fit here.
);
}
}
`
:arrow_up_small:
$3
Add properties as needed (all properties are optional).
`jsx
class App extends Component {
render() {
return minSize = {20}
maxSize = {200}
updateOnResize = {{
delay:0
}}
id = "myId"
className = "myClassNames"
style = {{
myStyle:'myStyleValue'
}}
>Add your text to fit here.;
}
}
`
Min and max size is in pixels. The delay is in milliseconds. The 'id', 'className', and 'style' props are added to the components root element.
:arrow_up_small:
$3
The component has a default class name of 'FitText' which can be used to style the root element.
`css
.FitText {position:relative;height:100%;}
`
The 'id', 'className', and 'style' props are added to the components root element.
`jsx
render() {
return id = "myId"
className = "myClassNames"
style = {{
myStyle:'myStyleValue'
}}
>Add your text to fit here.;
}
``