react-split-pane 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -339,6 +339,115 @@ A subtle single-pixel divider:
|
|
|
339
339
|
}
|
|
340
340
|
```
|
|
341
341
|
|
|
342
|
+
## Tailwind CSS & shadcn/ui
|
|
343
|
+
|
|
344
|
+
React Split Pane works seamlessly with Tailwind CSS and shadcn/ui. The component uses plain CSS and inline styles (no CSS-in-JS), so there are no conflicts with utility-first frameworks.
|
|
345
|
+
|
|
346
|
+
### Using Tailwind Classes
|
|
347
|
+
|
|
348
|
+
Apply Tailwind classes directly via `className` props. Skip importing the default stylesheet for full Tailwind control:
|
|
349
|
+
|
|
350
|
+
```tsx
|
|
351
|
+
import { SplitPane, Pane } from 'react-split-pane';
|
|
352
|
+
// Don't import 'react-split-pane/styles.css' if using Tailwind
|
|
353
|
+
|
|
354
|
+
<SplitPane
|
|
355
|
+
className="h-screen w-full"
|
|
356
|
+
dividerClassName="bg-gray-200 hover:bg-gray-300 dark:bg-gray-700 dark:hover:bg-gray-600 transition-colors"
|
|
357
|
+
>
|
|
358
|
+
<Pane defaultSize="300px" className="bg-white dark:bg-gray-900 p-4">
|
|
359
|
+
<Sidebar />
|
|
360
|
+
</Pane>
|
|
361
|
+
<Pane className="bg-gray-50 dark:bg-gray-800 p-4">
|
|
362
|
+
<MainContent />
|
|
363
|
+
</Pane>
|
|
364
|
+
</SplitPane>
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
### shadcn/ui Integration
|
|
368
|
+
|
|
369
|
+
Use shadcn's CSS variables and utilities for consistent theming:
|
|
370
|
+
|
|
371
|
+
```tsx
|
|
372
|
+
import { SplitPane, Pane } from 'react-split-pane';
|
|
373
|
+
|
|
374
|
+
<SplitPane
|
|
375
|
+
className="h-full w-full"
|
|
376
|
+
dividerClassName="bg-border hover:bg-accent transition-colors"
|
|
377
|
+
>
|
|
378
|
+
<Pane defaultSize="280px" className="bg-background border-r">
|
|
379
|
+
<Sidebar />
|
|
380
|
+
</Pane>
|
|
381
|
+
<Pane className="bg-muted/50">
|
|
382
|
+
<MainContent />
|
|
383
|
+
</Pane>
|
|
384
|
+
</SplitPane>
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
### Custom Divider with shadcn
|
|
388
|
+
|
|
389
|
+
Create a themed divider component using shadcn's `cn` utility:
|
|
390
|
+
|
|
391
|
+
```tsx
|
|
392
|
+
import { cn } from '@/lib/utils';
|
|
393
|
+
import type { DividerProps } from 'react-split-pane';
|
|
394
|
+
|
|
395
|
+
function ThemedDivider({ direction, isDragging, disabled, ...props }: DividerProps) {
|
|
396
|
+
return (
|
|
397
|
+
<div
|
|
398
|
+
className={cn(
|
|
399
|
+
'flex items-center justify-center transition-colors',
|
|
400
|
+
'bg-border hover:bg-accent focus:outline-none focus:ring-2 focus:ring-ring',
|
|
401
|
+
direction === 'horizontal'
|
|
402
|
+
? 'w-1 cursor-col-resize'
|
|
403
|
+
: 'h-1 cursor-row-resize',
|
|
404
|
+
isDragging && 'bg-primary',
|
|
405
|
+
disabled && 'cursor-not-allowed opacity-50'
|
|
406
|
+
)}
|
|
407
|
+
{...props}
|
|
408
|
+
/>
|
|
409
|
+
);
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
<SplitPane divider={ThemedDivider}>
|
|
413
|
+
<Pane>Left</Pane>
|
|
414
|
+
<Pane>Right</Pane>
|
|
415
|
+
</SplitPane>
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### CSS Variables with Tailwind
|
|
419
|
+
|
|
420
|
+
Override the default CSS variables in your `globals.css` to match your Tailwind theme:
|
|
421
|
+
|
|
422
|
+
```css
|
|
423
|
+
/* globals.css */
|
|
424
|
+
@layer base {
|
|
425
|
+
:root {
|
|
426
|
+
--split-pane-divider-size: 4px;
|
|
427
|
+
--split-pane-divider-color: theme('colors.gray.200');
|
|
428
|
+
--split-pane-divider-color-hover: theme('colors.gray.300');
|
|
429
|
+
--split-pane-focus-color: theme('colors.blue.500');
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
.dark {
|
|
433
|
+
--split-pane-divider-color: theme('colors.gray.700');
|
|
434
|
+
--split-pane-divider-color-hover: theme('colors.gray.600');
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Or with shadcn/ui CSS variables:
|
|
440
|
+
|
|
441
|
+
```css
|
|
442
|
+
@layer base {
|
|
443
|
+
:root {
|
|
444
|
+
--split-pane-divider-color: hsl(var(--border));
|
|
445
|
+
--split-pane-divider-color-hover: hsl(var(--accent));
|
|
446
|
+
--split-pane-focus-color: hsl(var(--ring));
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
```
|
|
450
|
+
|
|
342
451
|
## Migration from v0.1.x
|
|
343
452
|
|
|
344
453
|
See [MIGRATION.md](./MIGRATION.md) for detailed migration guide.
|