Skip to content

Commit a1e0cf3

Browse files
committed
v1.1.0-beta.3: Add comprehensive customization documentation
- Add detailed customization section to README - Create advanced CUSTOMIZATION.md guide with examples: * Custom styling with className * Wrapper components for theming * Responsive design patterns * CSS-in-JS integration * Multi-instance color pickers * Gradient builder example * Performance optimization tips * Accessibility best practices * Testing examples - Include migration guide from CSS to inline styles - Add troubleshooting section for common issues
1 parent 5829ac7 commit a1e0cf3

4 files changed

Lines changed: 875 additions & 3 deletions

File tree

README.md

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,248 @@ function CustomPresetsExample() {
164164
}
165165
```
166166

167+
## 🎨 Customization
168+
169+
Since version 1.1.0-beta.2, React Color Pikr uses inline styles, making it easy to customize the appearance without CSS conflicts.
170+
171+
> 📖 **For advanced customization examples, see the [Complete Customization Guide](./docs/CUSTOMIZATION.md)**
172+
173+
### Custom Styling with className
174+
175+
You can add custom styles by providing a `className` and using CSS:
176+
177+
```tsx
178+
import { ColorPicker } from "react-color-pikr";
179+
import "./custom-color-picker.css";
180+
181+
function CustomStyledPicker() {
182+
return (
183+
<ColorPicker
184+
value="#3498db"
185+
onChange={setColor}
186+
className="my-custom-picker"
187+
width={320}
188+
height={240}
189+
/>
190+
);
191+
}
192+
```
193+
194+
```css
195+
/* custom-color-picker.css */
196+
.my-custom-picker {
197+
border: 2px solid #e74c3c;
198+
border-radius: 16px;
199+
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
200+
}
201+
202+
.my-custom-picker input {
203+
font-family: 'Roboto Mono', monospace;
204+
font-size: 16px;
205+
}
206+
```
207+
208+
### Wrapper Component for Advanced Customization
209+
210+
Create a wrapper component to override specific styles:
211+
212+
```tsx
213+
import React from 'react';
214+
import { ColorPicker, type ColorPickerProps } from 'react-color-pikr';
215+
216+
interface CustomColorPickerProps extends ColorPickerProps {
217+
theme?: 'light' | 'dark';
218+
}
219+
220+
const CustomColorPicker: React.FC<CustomColorPickerProps> = ({
221+
theme = 'light',
222+
...props
223+
}) => {
224+
const wrapperStyle = {
225+
padding: '20px',
226+
borderRadius: '12px',
227+
backgroundColor: theme === 'dark' ? '#2c3e50' : '#ffffff',
228+
border: `2px solid ${theme === 'dark' ? '#34495e' : '#e0e0e0'}`,
229+
};
230+
231+
return (
232+
<div style={wrapperStyle}>
233+
<ColorPicker
234+
{...props}
235+
width={props.width || 300}
236+
height={props.height || 220}
237+
/>
238+
</div>
239+
);
240+
};
241+
```
242+
243+
### Themed Color Picker
244+
245+
Create different themes for your color picker:
246+
247+
```tsx
248+
const themes = {
249+
minimal: {
250+
container: {
251+
border: '1px solid #e0e0e0',
252+
borderRadius: '8px',
253+
padding: '12px',
254+
backgroundColor: '#fafafa',
255+
}
256+
},
257+
modern: {
258+
container: {
259+
border: 'none',
260+
borderRadius: '16px',
261+
padding: '24px',
262+
backgroundColor: '#ffffff',
263+
boxShadow: '0 10px 40px rgba(0, 0, 0, 0.1)',
264+
}
265+
},
266+
dark: {
267+
container: {
268+
border: '1px solid #444',
269+
borderRadius: '12px',
270+
padding: '20px',
271+
backgroundColor: '#2c3e50',
272+
color: '#ecf0f1',
273+
}
274+
}
275+
};
276+
277+
function ThemedColorPicker({ theme = 'modern' }) {
278+
return (
279+
<div style={themes[theme].container}>
280+
<ColorPicker
281+
value={color}
282+
onChange={setColor}
283+
showAlpha={true}
284+
/>
285+
</div>
286+
);
287+
}
288+
```
289+
290+
### Responsive Color Picker
291+
292+
Make the color picker responsive for different screen sizes:
293+
294+
```tsx
295+
import { useState, useEffect } from 'react';
296+
297+
function ResponsiveColorPicker() {
298+
const [dimensions, setDimensions] = useState({ width: 280, height: 200 });
299+
300+
useEffect(() => {
301+
const updateDimensions = () => {
302+
const width = window.innerWidth;
303+
if (width < 480) {
304+
setDimensions({ width: 260, height: 180 });
305+
} else if (width < 768) {
306+
setDimensions({ width: 300, height: 220 });
307+
} else {
308+
setDimensions({ width: 320, height: 240 });
309+
}
310+
};
311+
312+
updateDimensions();
313+
window.addEventListener('resize', updateDimensions);
314+
return () => window.removeEventListener('resize', updateDimensions);
315+
}, []);
316+
317+
return (
318+
<ColorPicker
319+
value={color}
320+
onChange={setColor}
321+
width={dimensions.width}
322+
height={dimensions.height}
323+
showAlpha={true}
324+
/>
325+
);
326+
}
327+
```
328+
329+
### Custom Preset Colors with Categories
330+
331+
Organize preset colors into categories:
332+
333+
```tsx
334+
const colorCategories = {
335+
primary: ['#3498db', '#2ecc71', '#e74c3c', '#f39c12', '#9b59b6'],
336+
neutral: ['#95a5a6', '#7f8c8d', '#34495e', '#2c3e50', '#ecf0f1'],
337+
pastel: ['#ffeaa7', '#fab1a0', '#fd79a8', '#a29bfe', '#6c5ce7'],
338+
};
339+
340+
function CategorizedColorPicker() {
341+
const [selectedCategory, setSelectedCategory] = useState('primary');
342+
343+
return (
344+
<div>
345+
{/* Category Selector */}
346+
<div style={{ marginBottom: '16px' }}>
347+
{Object.keys(colorCategories).map(category => (
348+
<button
349+
key={category}
350+
onClick={() => setSelectedCategory(category)}
351+
style={{
352+
margin: '0 4px',
353+
padding: '6px 12px',
354+
borderRadius: '4px',
355+
border: selectedCategory === category ? '2px solid #3498db' : '1px solid #ddd',
356+
background: selectedCategory === category ? '#e3f2fd' : '#fff',
357+
}}
358+
>
359+
{category.charAt(0).toUpperCase() + category.slice(1)}
360+
</button>
361+
))}
362+
</div>
363+
364+
<ColorPicker
365+
value={color}
366+
onChange={setColor}
367+
presetColors={colorCategories[selectedCategory]}
368+
showPresets={true}
369+
/>
370+
</div>
371+
);
372+
}
373+
```
374+
375+
### Integration with CSS-in-JS Libraries
376+
377+
Use with styled-components or emotion:
378+
379+
```tsx
380+
import styled from 'styled-components';
381+
import { ColorPicker } from 'react-color-pikr';
382+
383+
const StyledColorPickerWrapper = styled.div`
384+
.color-picker {
385+
border: 2px solid ${props => props.theme.primary};
386+
border-radius: 16px;
387+
388+
input {
389+
font-family: 'JetBrains Mono', monospace;
390+
background: ${props => props.theme.inputBg};
391+
color: ${props => props.theme.text};
392+
}
393+
}
394+
`;
395+
396+
function StyledColorPicker() {
397+
return (
398+
<StyledColorPickerWrapper>
399+
<ColorPicker
400+
value={color}
401+
onChange={setColor}
402+
className="color-picker"
403+
/>
404+
</StyledColorPickerWrapper>
405+
);
406+
}
407+
```
408+
167409
## Development
168410

169411
```bash

0 commit comments

Comments
 (0)