boundless-fitted-text

1.1.0 • Public • Published

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';
 
export default () => (
    <div className='spread'>
        <Button className='tall-button'>
            <FittedText>Welcome</FittedText>
        </Button>
        <Button className='tall-button'>
            <FittedText>Добро пожаловать</FittedText>
        </Button>
        <Button className='tall-button'>
            <FittedText>Benvenuto</FittedText>
        </Button>
        <Button className='tall-button'>
            <FittedText>환영합니다</FittedText>
        </Button>
        <Button className='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:

import { FittedText } from 'boundless';

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 attribute

    Expects Default Value
    any n/a
  • component · any valid HTML tag name

    Expects 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 fit

    Expects 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.

Package Sidebar

Install

npm i boundless-fitted-text

Weekly Downloads

0

Version

1.1.0

License

MIT

Last publish

Collaborators

  • sighrobot