npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@misnpm/input-text-kit

v1.0.9

Published

Input Text Kit is a powerful and flexible React component library that provides advanced text styling capabilities. It allows developers to easily integrate customizable text input features into their applications, including font selection, color picking,

Readme

Input Text Kit: A Customizable Text Styling Library for React

Input Text Kit is a powerful and flexible React component library that provides advanced text styling capabilities. It allows developers to easily integrate customizable text input features into their applications, including font selection, color picking, and gradient application.

This library is designed to enhance the user experience by offering a rich set of text formatting options within a modal interface. It's ideal for applications that require dynamic text styling, such as content creation tools, design platforms, or any project where text customization is a key feature.

Repository Structure

input-text-kit/
├── package.json
├── rollup.config.js
├── tsconfig.json
├── src/
│   ├── components/
│   │   ├── ButtonWithModal.tsx
│   │   ├── ColorPickerModal.tsx
│   │   ├── FontFamilySelector.tsx
│   │   ├── GradientGrid.tsx
│   │   └── SizeInput.tsx
│   ├── interfaces/
│   │   └── TextStyle.ts
│   ├── utils/
│   │   ├── createTextStyle.ts
│   │   └── gradientes.ts
│   └── index.tsx
└── .storybook/
    ├── main.ts
    └── preview.ts

Usage Instructions

Installation

To install the Input Text Kit library, run the following command in your project directory:

npm install input-text-kit

Ensure you have React and React DOM installed as peer dependencies:

npm install react react-dom

Getting Started

  1. Import the ButtonWithModal component in your React application:
import { ButtonWithModal } from 'input-text-kit';
  1. Use the component in your JSX:
function App() {
  const handleTextStyleChange = (newStyle) => {
    console.log('New text style:', newStyle);
    // Handle the new style here
  };

  return (
    <div>
      <ButtonWithModal onChange={handleTextStyleChange} />
    </div>
  );
}
  1. The ButtonWithModal component will render a button that, when clicked, opens a modal with text styling options.

Configuration

You can pass initial text style values to the ButtonWithModal component:

<ButtonWithModal 
  value={{
    text: {
      fontFamily: 'Arial',
      size: '16px',
      color: '#000000',
      bold: false,
      italic: false,
      underline: false,
      lineThrough: false,
      align: 'left'
    },
    background: {
      color: 'transparent'
    }
  }}
  onChange={handleTextStyleChange}
/>

API Reference

ButtonWithModal Props

  • value: (Optional) An object of type Partial<TextStyle> representing the initial text style.
  • onChange: A callback function that receives the updated TextStyle object when changes are made.

TextStyle Interface

interface TextStyle {
  text: {
    fontFamily: string;
    size: string;
    color: string;
    bold: boolean;
    italic: boolean;
    underline: boolean;
    lineThrough: boolean;
    align: 'left' | 'center' | 'right' | 'justify';
    letterSpacing: string;
    lineHeight: string;
    gradient?: string;
  };
  background: {
    color: string;
  };
}

Examples

Basic Usage

import React from 'react';
import { ButtonWithModal } from 'input-text-kit';

function TextEditor() {
  const handleStyleChange = (newStyle) => {
    console.log('Updated style:', newStyle);
    // Apply the new style to your text element
  };

  return (
    <div>
      <h1>Text Editor</h1>
      <ButtonWithModal onChange={handleStyleChange} />
      <div id="text-preview">
        Preview text will be styled here
      </div>
    </div>
  );
}

export default TextEditor;

With Initial Style

import React, { useState } from 'react';
import { ButtonWithModal } from 'input-text-kit';

function StyledTextEditor() {
  const [textStyle, setTextStyle] = useState({
    text: {
      fontFamily: 'Roboto',
      size: '18px',
      color: '#333333',
      bold: true,
      italic: false,
      underline: false,
      lineThrough: false,
      align: 'left'
    },
    background: {
      color: '#f0f0f0'
    }
  });

  const handleStyleChange = (newStyle) => {
    setTextStyle(newStyle);
  };

  return (
    <div>
      <h1>Styled Text Editor</h1>
      <ButtonWithModal value={textStyle} onChange={handleStyleChange} />
      <div id="text-preview" style={{
        fontFamily: textStyle.text.fontFamily,
        fontSize: textStyle.text.size,
        color: textStyle.text.color,
        fontWeight: textStyle.text.bold ? 'bold' : 'normal',
        fontStyle: textStyle.text.italic ? 'italic' : 'normal',
        textDecoration: `${textStyle.text.underline ? 'underline' : ''} ${textStyle.text.lineThrough ? 'line-through' : ''}`,
        textAlign: textStyle.text.align,
        backgroundColor: textStyle.background.color
      }}>
        This text will update based on the selected styles
      </div>
    </div>
  );
}

export default StyledTextEditor;

Troubleshooting

Common Issues

  1. Font not loading:

    • Ensure you have a valid Google Fonts API key set in the FontFamilySelector component.
    • Check your network connection and console for any API errors.
  2. Styles not applying:

    • Verify that the onChange prop is correctly passing the updated style to your parent component.
    • Ensure you're applying the received styles to your text elements correctly.
  3. Modal not opening:

    • Check for any console errors related to React or Material-UI.
    • Ensure you're not blocking the button with other UI elements.

Debugging

To enable debug mode and verbose logging:

  1. Set a DEBUG environment variable:
export DEBUG=input-text-kit:*
  1. In your application, import the debug logger:
import debug from 'debug';
const log = debug('input-text-kit:main');

// Use it in your component
log('ButtonWithModal rendered with props:', props);

Log files are typically located in your application's log directory. For a Create React App project, check the browser console for logs.

Performance Optimization

To optimize performance when using Input Text Kit:

  1. Memoize the ButtonWithModal component if it's re-rendering unnecessarily:
import React, { useMemo } from 'react';
import { ButtonWithModal } from 'input-text-kit';

function OptimizedTextEditor({ initialStyle }) {
  const memoizedButton = useMemo(() => (
    <ButtonWithModal value={initialStyle} onChange={handleStyleChange} />
  ), [initialStyle]);

  return (
    <div>
      {memoizedButton}
      {/* Rest of your component */}
    </div>
  );
}
  1. Use the React DevTools Profiler to identify performance bottlenecks.

  2. If you're applying styles to a large number of text elements, consider using virtualization techniques like react-window for rendering.

Data Flow

The Input Text Kit library follows a unidirectional data flow pattern. Here's how data flows through the application:

  1. The parent component initializes the ButtonWithModal with optional initial text styles.
  2. User interacts with the ButtonWithModal, opening the styling modal.
  3. User makes style changes within the modal (e.g., font selection, color picking).
  4. Each change updates the local state within ButtonWithModal.
  5. When the user saves changes, the ButtonWithModal calls the onChange prop with the new style object.
  6. The parent component receives the updated style and can apply it to the relevant text elements.
[Parent Component] -> (initial style) -> [ButtonWithModal]
                                              |
                                              v
                                    [User Interaction]
                                              |
                                              v
                                    [Local State Update]
                                              |
                                              v
[Parent Component] <- (updated style) <- [ButtonWithModal]

This flow ensures that the parent component always has the most up-to-date style information, while the ButtonWithModal manages its internal state for a responsive user experience.