### Install ink-color-pipe using npm Source: https://github.com/litomore/ink-color-pipe/blob/main/README.md Install the ink-color-pipe package using npm. This is the first step to using the component in your Ink application. ```shell npm i ink-color-pipe ``` -------------------------------- ### Using Built-in Chalk and chalk-pipe Exports Source: https://github.com/litomore/ink-color-pipe/blob/main/README.md Shows how to access and use the underlying Chalk instance, Chark constructor, and chalkPipe function provided by ink-color-pipe for more direct styling control. ```javascript import { Chalk, chalk, chalkPipe } from "ink-color-pipe"; const customChalk = new Chalk({ level: 0 }); console.log(chalk.blue("Hello")); console.log(customChalk.green("World")); console.log(chalkPipe("blue.bgGreen.italic")("Hello World")); ``` -------------------------------- ### Basic Usage of Color Component in Ink Source: https://github.com/litomore/ink-color-pipe/blob/main/README.md Demonstrates how to use the `` component to apply styles like 'blue.underline' and 'bgRed.white' to text within an Ink application. It imports necessary components from 'ink' and 'ink-color-pipe'. ```javascript import React from "react"; import { render, Text } from "ink"; import Color from "ink-color-pipe"; const link = "blue.underline"; const error = "bgRed.white"; render( Unicorn {" Error "} , ); ``` -------------------------------- ### Chalk and Chalk-pipe Exports for Advanced Styling (TypeScript) Source: https://context7.com/litomore/ink-color-pipe/llms.txt Demonstrates re-exporting the complete Chalk library and chalk-pipe utilities for full access to the underlying styling engine. It shows usage of default and custom Chalk instances, color disabling, and integration with Ink components. ```typescript import { Chalk, chalk } from 'ink-color-pipe'; // Use default chalk instance console.log(chalk.blue('Blue text')); console.log(chalk.bgRed.white('White on red')); console.log(chalk.bold.italic.green('Multiple styles')); // Create custom Chalk instances with specific color levels const customChalk = new Chalk({ level: 3 }); // TrueColor support console.log(customChalk.hex('#DEADED')('Hex color text')); console.log(customChalk.rgb(255, 136, 0)('RGB color text')); // Disable colors for specific instance const noColorChalk = new Chalk({ level: 0 }); console.log(noColorChalk.red('This appears without color')); // Combine with Ink components import React from 'react'; import { render, Text } from 'ink'; import Color, { chalk } from 'ink-color-pipe'; const App = () => { // Pre-process some text with chalk const processedText = chalk.dim('(optional)'); return ( Enter your name {' '} {processedText} ); }; render(); ``` -------------------------------- ### Style String Composition for Reusable UI Elements (TypeScript) Source: https://context7.com/litomore/ink-color-pipe/llms.txt Presents a pattern for building complex, reusable style combinations using dot-notation chaining of modifiers, colors, and backgrounds. This promotes consistency and maintainability in UI development. ```tsx import React from 'react'; import { render, Box, Text } from 'ink'; import Color from 'ink-color-pipe'; // Define style constants for consistency const STYLES = { // Text emphasis heading: 'cyan.bold.underline', subheading: 'white.bold', emphasis: 'yellow.italic', // Status indicators error: 'bgRed.white.bold', warning: 'bgYellow.black.bold', success: 'bgGreen.white.bold', info: 'bgBlue.white', // UI elements link: 'blue.underline', code: 'gray.dim', highlight: 'bgWhite.black', // Custom combinations brand: '#6C5CE7.bold', muted: 'gray.dim.italic' }; const StyledInterface = () => { return ( Application Dashboard System Status OK {' Database connection active'} WARN {' High memory usage detected'} INFO {' 5 background tasks running'} {'Visit '} https://docs.example.com {' for more info'} Last updated: 2 minutes ago ); }; render(); ``` -------------------------------- ### Hex and CSS Color Support with Ink (TypeScript) Source: https://context7.com/litomore/ink-color-pipe/llms.txt Illustrates how to use hex triplet notation and CSS color keywords for precise color control within Ink components. This allows for a wider range of color specifications beyond basic named colors. ```tsx import React from 'react'; import { render, Box, Text } from 'ink'; import Color from 'ink-color-pipe'; const ColorPalette = () => { return ( {/* Hex colors */} Coral Red (#FF6B6B) Turquoise (#4ECDC4) Yellow (#FFE66D) {/* CSS keywords */} Crimson (CSS keyword) Sky Blue (CSS keyword) Medium Sea Green {/* Combined with backgrounds */} Custom theme colors ); }; render(); ``` -------------------------------- ### Render Styled Text with Component in Ink Source: https://context7.com/litomore/ink-color-pipe/llms.txt Demonstrates how to use the `` React component to apply various text styles, including basic colors, multiple modifiers, background colors, and complex combinations, within an Ink application. This component internally uses Ink's `` and `chalk-pipe` for styling. ```tsx import React from 'react'; import { render, Text } from 'ink'; import Color from 'ink-color-pipe'; // Basic color styling render( This is blue text ); // Multiple styles combined render( Bold blue underlined text ); // Background colors and foreground colors render( White text on red background ); // Complex styling with multiple properties const link = "blue.underline"; const error = "bgRed.white"; const warning = "yellow.bold"; const success = "green.bold"; render( https://example.com {'/n'} Error {' Something went wrong!'} {'/n'} ⚠ Warning: {'Check your configuration'} {'/n'} ✓ Success: {'Operation completed'} ); ``` -------------------------------- ### Programmatic Styling with chalkPipe Export Source: https://context7.com/litomore/ink-color-pipe/llms.txt Shows how to use the `chalkPipe` function exported by `ink-color-pipe` for applying styles programmatically outside of React components. This function takes a style string and returns a function that applies the specified styles to any given string, supporting hex colors and CSS keywords. ```typescript import { chalkPipe } from 'ink-color-pipe'; // Create style functions const errorStyle = chalkPipe('bgRed.white.bold'); const linkStyle = chalkPipe('blue.underline'); const successStyle = chalkPipe('green.bold'); // Apply styles to strings console.log(errorStyle('Error: File not found')); console.log(linkStyle('https://github.com')); console.log(successStyle('✓ Build completed')); // Use with hex colors const customColor = chalkPipe('#FF6B6B.bold'); console.log(customColor('Custom hex color')); // Use with CSS keywords const infoStyle = chalkPipe('skyblue.italic'); console.log(infoStyle('Information message')); // Combine multiple styling approaches const styles = { error: chalkPipe('bgRed.white'), warning: chalkPipe('yellow.bold'), info: chalkPipe('blue'), success: chalkPipe('green') }; const messages = [ { type: 'error', text: 'Failed to connect' }, { type: 'warning', text: 'Deprecated API usage' }, { type: 'info', text: 'Processing request' }, { type: 'success', text: 'Task completed' } ]; messages.forEach(msg => { console.log(styles[msg.type](msg.text)); }); ``` -------------------------------- ### TypeScript ColorProps Interface for Ink-Color-Pipe Source: https://context7.com/litomore/ink-color-pipe/llms.txt Illustrates the usage of the `ColorProps` TypeScript interface from `ink-color-pipe` to ensure type safety when defining and using the `` component's props. This promotes robust component development by enforcing correct prop types for `styles` and `children`. ```tsx import React from 'react'; import Color, { type ColorProps } from 'ink-color-pipe'; import { render, Text } from 'ink'; // Define reusable styled components with proper types const StyledText: React.FC = ({ styles, children }) => { return {children}; }; // Use with explicit types const MyComponent: React.FC = () => { const props: ColorProps = { styles: 'cyan.bold', children: 'Typed styled text' }; return ( ); }; render(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.