spino-elements-ts

A Vue.js 3 component library for dynamically adjusting text sizes and other reusable UI components.
2,215
Install
npm install spino-elements-ts
Latest Version:1.8.2
Vue:3
License:MIT
Last Updated:May 13, 2025
Links: Bitbucket  ·  npm
Maintainer: ron.b_spinomenal

TextFit-Spino

A Vue.js 2 component library for dynamically adjusting text sizes within elements using TextFit. Includes components for managing text fitting and setting text width limits.

Installation

To install the library, run the following command in your Vue 2 project:

npm install textfit-spino

Usage TextfitManager

In your template, use the TextfitManager component. You can register it in App.vue and use it globally.

import { TextfitManager } from "textfit-spino";

export default {
  components: {
    TextfitManager,
  },
  data() {
    return {
      isMobile: false, // Adjust based on device type
    };
  },
};

TextfitManager Example Usage

In your template, use the TextfitManager component:

<TextfitManager
  :i_ElementToTextfit="['textfit-subtitle-1', 'textfit-title']"
  :i_SameSizeElements="['textfit-title']"
  :i_ResizeStopOn="modalIsVisible"
  :i_Component="'BuyFeature'"
  :isMobile="isMobile"
/>

Props TextfitManager

  • i_ElementToTextfit: Array of class names of elements that should be text-fitted.
  • i_SameSizeElements: Array of class names that should have the same font size.
  • i_PrioritizeElement: String of a class name to prioritize the font size of the other elements.
  • i_ResizeStopOn: Boolean flag to stop resizing when the condition is met.
  • i_Component: String identifier for the component.
  • isMobile: Boolean to define if the device is mobile.

Usage TextfitLimiter

In all places where you want to fit text elements dynamically, use the TextfitLimiter component instead with the following implementation.

import { TextfitLimiter } from "textfit-spino";

export default {
  components: {
    TextfitLimiter,
  },
  data() {
    return {};
  },
};

TextfitLimiter Example Usage

In your template, use the TextfitManager component:

<TextfitLimiter
  :i_Class="'custom-class'"
  :i_Text="'Sample Text'"
  :config="{ minCharWidth: 2, maxCharWidth: 40, minPercentage: 70, maxPercentage: 90 }"
  :i_isReactiveFix="true"
  :i_isBreakLine="false"
/>

Props TextfitLimiter

  • i_Class: String — Optional. Specifies a CSS class name that will be applied to the component, allowing for custom styling.

  • i_Text: String — Optional. Defines the text content to be displayed within the component.

  • config: Object — Required. Sets configuration parameters for text fitting within the component. The default configuration is:

    {
      minCharWidth: 1,
      maxCharWidth: 50,
      minPercentage: 65,
      maxPercentage: 85
    }
    
  • i_isReactiveFix: Boolean — Optional (default: false). If set to true, enables a reactive fix to adjust text dynamically when data changes.

  • i_isBreakLine: Boolean — Optional (default: false). If set to true, allows text to break into multiple lines if needed.

Notes

  • Ensure the parent container has a defined width to properly fit the text.
  • The config prop allows customization of text scaling behavior.
  • If i_isBreakLine is false, the text will try to fit within a single line.
  • If i_isReactiveFix is true, text will automatically adjust when content changes.

Development

To contribute or make changes:

  1. Clone the repository:

    git clone https://github.com/ronbSpino/TextFit.git
    
  2. Install dependencies:

    npm install
    
  3. Run the build process:

    npm run build
    
  4. Make your changes and test them.

License

MIT License. See the LICENSE file for more details.

Related Packages

xc-workflow-ui

基于vant二次封装工作流组件库

4,034
weiyun-ui

UI library For Vue

7,638
lemon-ui-vue2

可视化大屏UI库

1,722 5
day-ui

基于 Vue3 的组件库,样式借用 element-plus 的,用于学习使用

1,326 2
weiyun-bui

UI library For Vue

633

Version History

Version Released Vue License
1.8.2 ^3.2.0 MIT
1.8.1 ^3.2.0 MIT
1.8.0 ^3.2.0 MIT
1.7.0 ^3.2.0 MIT
1.6.2 ^3.2.0 MIT