pure-react-ui
v1.6.2
Published
A pure React UI component library with Button, Card, Modal, Icon, Space, Flex, Text, Form, and Kanban components
Maintainers
Readme
Pure React UI
A pure React UI component library built with TypeScript. No external dependencies required (except React and ReactDOM as peer dependencies).
Installation
npm install pure-react-uiNote: The Select component requires react-select as a peer dependency. If you're using the Select component, make sure to install it:
npm install react-selectComponents
Button
A versatile button component with multiple variants and sizes.
import { Button } from 'pure-react-ui';
<Button variant="primary" size="medium" onClick={handleClick}>
Click Me
</Button>Props:
variant: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' (default: 'primary')size: 'small' | 'medium' | 'large' (default: 'medium')fullWidth: boolean (default: false)loading: boolean (default: false)- All standard button HTML attributes
Card
A flexible card component for displaying content.
import { Card } from 'pure-react-ui';
<Card
title="Card Title"
subtitle="Card Subtitle"
image="/path/to/image.jpg"
hoverable
shadow="medium"
>
Card content goes here
</Card>Props:
title: string (optional)subtitle: string (optional)image: string (optional)imageAlt: string (optional)footer: React.ReactNode (optional)hoverable: boolean (default: false)shadow: 'none' | 'small' | 'medium' | 'large' (default: 'medium')onClick: () => void (optional)
Modal
A modal dialog component with overlay and keyboard support.
import { Modal } from 'pure-react-ui';
<Modal
isOpen={isOpen}
onClose={() => setIsOpen(false)}
title="Modal Title"
size="medium"
>
Modal content goes here
</Modal>Props:
isOpen: boolean (required)onClose: () => void (required)title: string | React.ReactNode (optional) - Modal title or custom header contentsize: 'small' | 'medium' | 'large' | 'fullscreen' (default: 'medium')position: 'center' | 'top' | 'bottom' | 'left' | 'right' | 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right' (default: 'center')variant: 'default' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'gradient-primary' | 'gradient-success' | 'gradient-danger' | 'gradient-info' (default: 'default')closeOnOverlayClick: boolean (default: true)closeOnEscape: boolean (default: true)showCloseButton: boolean (default: true)scrollable: boolean (default: true) - Enable scrolling for modal bodytopMargin: number | string (optional) - Custom top margin for modalclassName: string (optional) - Additional CSS classesoverlayClassName: string (optional) - Additional CSS classes for overlayheaderClassName: string (optional) - Additional CSS classes for headerbodyClassName: string (optional) - Additional CSS classes for body
Icon
A comprehensive icon component library with 100+ SVG icons.
import { Icon } from 'pure-react-ui';
<Icon name="Home" size={24} color="#007bff" />
<Icon name="Search" size={32} onClick={handleClick} />Props:
name: IconName (required) - Name of the icon to displaysize: number | string (default: 24) - Size of the iconcolor: string (default: 'currentColor') - Color of the iconclassName: string (optional) - Additional CSS classesonClick: () => void (optional) - Click handler (makes icon clickable)
Available Icons:
Arrows & Navigation: ArrowLeft, ArrowRight, ArrowUp, ArrowDown, ArrowUpRight, ArrowDownRight, ChevronLeft, ChevronRight, ChevronUp, ChevronDown, DoubleChevronLeft, DoubleChevronRight, Home, Menu, Close, Search, Filter
Actions: Plus, Minus, Check, X, Edit, Trash, Save, Download, Upload, Copy, Share
Media: Play, Pause, Stop, VolumeUp, VolumeDown, VolumeOff, Image, Video, Camera
Communication: Mail, Message, Phone, Bell, Notification
Files: File, Folder, FolderOpen, FileText, FilePdf
User: User, Users, UserPlus, UserMinus, Settings, Logout
Status: CheckCircle, XCircle, AlertCircle, Info, Warning, Star, Heart, Bookmark
Social: Facebook, Twitter, Instagram, Linkedin, Github, Youtube
Technology: Wifi, Bluetooth, Battery, Zap, Lock, Unlock, Shield
Shopping: ShoppingCart, ShoppingBag, CreditCard, Gift
Time: Clock, Calendar, Timer
Location: MapPin, Globe, Navigation
Weather: Sun, Moon, Cloud
Utility: Eye, EyeOff, Refresh, MoreVertical, MoreHorizontal, Grid, List
You can also import individual icons directly:
import { Home, Search, User } from 'pure-react-ui';
<Home size={24} color="#007bff" />Space
A layout component for adding consistent spacing between elements.
import { Space } from 'pure-react-ui';
<Space size="medium" direction="horizontal">
<Button>Button 1</Button>
<Button>Button 2</Button>
<Button>Button 3</Button>
</Space>
<Space size={20} direction="vertical" align="start">
<Card>Card 1</Card>
<Card>Card 2</Card>
</Space>Props:
size: 'small' | 'medium' | 'large' | number (default: 'medium') - Spacing size between itemsdirection: 'horizontal' | 'vertical' (default: 'horizontal') - Direction of spacingalign: 'start' | 'end' | 'center' | 'baseline' | 'stretch' (default: 'center') - Alignment of itemswrap: boolean (default: false) - Whether items should wrap to next lineclassName: string (optional) - Additional CSS classes
Flex
A flexible container component based on CSS Flexbox.
import { Flex } from 'pure-react-ui';
<Flex direction="row" justify="between" align="center" gap="medium">
<Button>Left</Button>
<Button>Center</Button>
<Button>Right</Button>
</Flex>
<Flex direction="column" justify="start" align="stretch" gap={16}>
<Card>Card 1</Card>
<Card>Card 2</Card>
</Flex>Props:
direction: 'row' | 'column' | 'row-reverse' | 'column-reverse' (default: 'row') - Flex directionjustify: 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly' (default: 'start') - Justify contentalign: 'start' | 'end' | 'center' | 'baseline' | 'stretch' (default: 'start') - Align itemswrap: boolean | 'wrap' | 'nowrap' | 'wrap-reverse' (default: false) - Flex wrap behaviorgap: 'none' | 'small' | 'medium' | 'large' | number (default: 'none') - Gap between itemsclassName: string (optional) - Additional CSS classesstyle: React.CSSProperties (optional) - Additional inline styles
Text
A typography component for consistent text styling with various options.
import { Text } from 'pure-react-ui';
<Text as="h1" size="2xl" weight="bold" color="primary">
Heading Text
</Text>
<Text size="lg" color="muted" align="center">
Centered paragraph text
</Text>
<Text as="span" size="sm" decoration="underline" transform="uppercase">
Styled Text
</Text>Props:
as: 'p' | 'span' | 'div' | 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6' | 'label' | 'small' | 'strong' | 'em' | 'code' | 'pre' (default: 'p') - HTML element to rendersize: 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl' | '3xl' | '4xl' (default: 'md') - Font sizeweight: 'light' | 'normal' | 'medium' | 'semibold' | 'bold' (default: 'normal') - Font weightcolor: 'default' | 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'muted' (default: 'default') - Text coloralign: 'left' | 'center' | 'right' | 'justify' (default: 'left') - Text alignmenttransform: 'none' | 'uppercase' | 'lowercase' | 'capitalize' (default: 'none') - Text transformdecoration: 'none' | 'underline' | 'line-through' | 'overline' (default: 'none') - Text decorationtruncate: boolean (default: false) - Truncate text with ellipsisclassName: string (optional) - Additional CSS classes
Form Components
A comprehensive form component system with all form elements.
Form
The main form container component.
import { Form } from 'pure-react-ui';
<Form layout="vertical" onSubmit={handleSubmit}>
{/* Form fields */}
</Form>Props:
layout: 'vertical' | 'horizontal' | 'inline' (default: 'vertical')size: 'small' | 'medium' | 'large' (default: 'medium')onSubmit: (e: React.FormEvent) => void (optional)- All standard form HTML attributes
Input
Text input field with validation and icons.
import { Input } from 'pure-react-ui';
<Input
label="Email"
type="email"
placeholder="Enter email"
error={errors.email}
helpText="We'll never share your email"
leftIcon={<Icon name="Mail" />}
fullWidth
/>Props:
label: string (optional)error: string (optional) - Error messagehelpText: string (optional) - Help textleftIcon: React.ReactNode (optional)rightIcon: React.ReactNode (optional)fullWidth: boolean (default: false)size: 'small' | 'medium' | 'large' (default: 'medium')- All standard input HTML attributes
Textarea
Multi-line text input.
import { Textarea } from 'pure-react-ui';
<Textarea
label="Message"
placeholder="Enter your message"
rows={4}
resize="vertical"
fullWidth
/>Props:
label: string (optional)error: string (optional)helpText: string (optional)fullWidth: boolean (default: false)size: 'small' | 'medium' | 'large' (default: 'medium')rows: number (default: 4)resize: 'none' | 'both' | 'horizontal' | 'vertical' (default: 'vertical')- All standard textarea HTML attributes
Select
Advanced dropdown select component powered by react-select with search, multi-select, and more features.
Note: This component requires react-select to be installed as a peer dependency:
npm install react-selectimport { Select } from 'pure-react-ui';
// Basic Select
<Select
label="Country"
options={[
{ value: 'us', label: 'United States' },
{ value: 'uk', label: 'United Kingdom' }
]}
placeholder="Choose a country"
fullWidth
/>
// Searchable Select
<Select
label="Search Country"
options={countries}
placeholder="Search and select"
isSearchable
isClearable
fullWidth
/>
// Multi Select
<Select
label="Select Frameworks"
options={frameworks}
placeholder="Select multiple"
isMulti
isSearchable
fullWidth
/>
// Select with Icons
<Select
label="Framework"
options={[
{ value: 'react', label: 'React', icon: <Icon name="Zap" /> },
{ value: 'vue', label: 'Vue.js', icon: <Icon name="Zap" /> }
]}
placeholder="Choose framework"
fullWidth
/>Props:
label: string (optional)error: string (optional)helpText: string (optional)options: SelectOption[] (required) - Array of options withvalue,label, optionaldisabled, and optionaliconplaceholder: string (optional, default: 'Select...')value: string | number | (string | number)[] (optional) - Controlled valuedefaultValue: string | number | (string | number)[] (optional) - Uncontrolled default valuemultipleorisMulti: boolean (default: false) - Enable multi-selectsearchableorisSearchable: boolean (default: false) - Enable search functionalityallowClearorisClearable: boolean (default: false) - Show clear buttondisabled: boolean (default: false)fullWidth: boolean (default: false)size: 'small' | 'medium' | 'large' (default: 'medium')onChange: (value: string | number | (string | number)[]) => void (optional)onSearch: (searchText: string) => void (optional) - Callback when search text changesname: string (optional) - Form field nameid: string (optional) - Custom ID for the selectclassName: string (optional)
Checkbox
Checkbox input with custom styling.
import { Checkbox } from 'pure-react-ui';
<Checkbox
label="I agree to terms"
checked={checked}
onChange={(e) => setChecked(e.target.checked)}
/>Props:
label: string (optional)error: string (optional)helpText: string (optional)fullWidth: boolean (default: false)size: 'small' | 'medium' | 'large' (default: 'medium')- All standard checkbox HTML attributes
Radio
Radio button input.
import { Radio } from 'pure-react-ui';
<Radio
label="Option 1"
name="option"
value="1"
checked={selected === '1'}
onChange={(e) => setSelected(e.target.value)}
/>Props:
label: string (optional)error: string (optional)helpText: string (optional)fullWidth: boolean (default: false)size: 'small' | 'medium' | 'large' (default: 'medium')- All standard radio HTML attributes
Switch
Toggle switch component.
import { Switch } from 'pure-react-ui';
<Switch
label="Enable notifications"
checked={enabled}
onChange={(e) => setEnabled(e.target.checked)}
/>Props:
label: string (optional)error: string (optional)helpText: string (optional)fullWidth: boolean (default: false)size: 'small' | 'medium' | 'large' (default: 'medium')- All standard checkbox HTML attributes (used as switch)
FormGroup
Container for grouping form fields.
import { FormGroup } from 'pure-react-ui';
<FormGroup label="Personal Information" required>
<Input label="Name" />
<Input label="Email" />
</FormGroup>Props:
label: string (optional)error: string (optional)helpText: string (optional)required: boolean (default: false)className: string (optional)
FormRow
Horizontal row for form fields.
import { FormRow } from 'pure-react-ui';
<FormRow gap="medium">
<Input label="First Name" fullWidth />
<Input label="Last Name" fullWidth />
</FormRow>Props:
gap: 'small' | 'medium' | 'large' | number (default: 'medium')className: string (optional)
Styling
All components include their own CSS files and use CSS classes with the pure- prefix. The CSS files are automatically imported with each component. You can also style them by targeting these classes:
- Button:
pure-button,pure-button--primary,pure-button--secondary, etc. - Card:
pure-card,pure-card--hoverable,pure-card--shadow-medium, etc. - Modal:
pure-modal,pure-modal__overlay,pure-modal__header, etc. - Icon:
pure-icon,pure-icon--clickable,pure-icon--small, etc. - Space:
pure-space,pure-space--horizontal,pure-space--vertical, etc. - Flex:
pure-flex,pure-flex--row,pure-flex--column, etc. - Text:
pure-text,pure-text--lg,pure-text--bold, etc. - Form:
pure-form,pure-form--vertical,pure-form--horizontal, etc. - Input:
pure-input,pure-input--error,pure-input--small, etc. - Textarea:
pure-textarea,pure-textarea--error, etc. - Select:
pure-select,pure-select--error, etc. - Checkbox:
pure-checkbox,pure-checkbox--error, etc. - Radio:
pure-radio,pure-radio--error, etc. - Switch:
pure-switch,pure-switch--error, etc.
Each component has its own CSS file located in:
lib/components/Button/Button.csslib/components/Card/Card.csslib/components/Modal/Modal.csslib/components/Icon/Icon.csslib/components/Space/Space.csslib/components/Flex/Flex.csslib/components/Text/Text.csslib/components/Form/Form.css
Examples
A complete example application is available in the example directory. To run it:
# From the root directory, build the package first
npm run build
# Then navigate to example directory
cd example
npm install
npm run devOr check out EXAMPLES.md for code examples and usage patterns.
License
MIT
