FittedText
This component can be useful in situations where an internationalized string is being placed into the UI and it's unclear if all variations of it will fit without excessive amounts of edge-case CSS. Ultimately, it's good at making sure what you put in doesn't overflow.
Installation
npm i boundless-fitted-text --save
Then use it like:
/** @jsx createElement */ import createElement from 'react';import Button from 'boundless-button';import FittedText from 'boundless-fitted-text'; <div ='spread'> <Button ='tall-button'> <FittedText>Welcome</FittedText> </Button> <Button ='tall-button'> <FittedText>Добро пожаловать</FittedText> </Button> <Button ='tall-button'> <FittedText>Benvenuto</FittedText> </Button> <Button ='tall-button'> <FittedText>환영합니다</FittedText> </Button> <Button ='tall-button'> <FittedText>സ്വാഗതം</FittedText> </Button> </div>;
FittedText can also just be directly used from the main Boundless library. This is recommended when you're getting started to avoid maintaining the package versions of several components:
npm i boundless --save
the ES6 import
statement then becomes like:
;
Props
Note: only top-level props are in the README, for the full list check out the website.
Required Props
There are no required props.
Optional Props
-
*
· any React-supported attributeExpects Default Value any
n/a
-
component
· any valid HTML tag nameExpects Default Value string
'span'
-
upscale
· controls if FittedText will automatically scale up the content to fit the available space; normally the component only scales text down as needed to fitExpects Default Value bool
false
Reference Styles
Stylus
You can see what variables are available to override in variables.styl.
// Redefine any variables as desired, e.g:color-accent = royalblue // Bring in the component styles; they will be autoconfigured based on the above@require "node_modules/boundless-fitted-text/style"
CSS
If desired, a precompiled plain CSS stylesheet is available for customization at /build/style.css
, based on Boundless's default variables.