React UI Library
Description
The React UI Library by Oliasoft is a versatile set of React UI components designed for building modern web applications. It offers a comprehensive suite of layout, navigation, and control components that are flexible and configurable. With detailed examples available in Storybook, developers can easily understand how to implement and customize components for their needs. This library is open-source and can be freely used and modified under the MIT License.
Installation
To install the React UI Library, you can use either npm or yarn as follows:
Using npm:
npm install @oliasoft-open-source/react-ui-library
Using yarn:
yarn add @oliasoft-open-source/react-ui-library
Quick Start: React and Vite
To quickly start a new project using the React UI Library with Vite, you can use the create-vite tool, which sets up everything for you in a few simple steps:
-
Create a New Vite Project: Use the create-vite command to scaffold a new React project. Run:
npm create vite@latest my-new-project -- --template react
Or with yarn
yarn create vite my-new-project --template react
-
Navigate into the Project Directory:
cd my-new-project
-
Install React UI Library: Add the React UI Library to your project:
npm install @oliasoft-open-source/react-ui-library
Or with yarn
yarn add @oliasoft-open-source/react-ui-library
-
Modify the Sample Page: Open the src/App.jsx file and import a component from the React UI Library to use it:
import React from 'react';
import { Text } from '@oliasoft-open-source/react-ui-library';
function App() {
return (
<div className="App">
<Text>Hello World!</Text>
</div>
);
}
export default App;
-
Start the Development Server: Begin development by starting the Vite server:
npm run dev
Or with yarn
yarn dev
Components
- Accordion
- AccordionWithDefaultToggle
- Actions
- Badge
- Breadcrumb
- Button
- ButtonGroup
- Card
- CheckBox
- Column
- Divider
- Dialog
- Drawer
- Empty
- FileInput & readFile
- Field
- Flex
- FormRow
- Grid
- Icon
- InputGroup
- InputGroupAddon
- HelpIcon
- Heading
- Input
- Label
- List
- ListHeading
- ListSubheading
- Loader
- Menu
- Message
- Modal
- OptionDropdown
- Page
- Pagination
- Popover
- Portal
- PrintHeader
- ProgressBar
- RadioButton
- RichTextInput
- NativeSelect
- Row
- Select
- SideBar
- Slider
- Spacer
- Spinner
- Table
- Tabs
- Text
- TextLink
- TextArea
- toast
- Toggle
- Tooltip
- TopBar
- PopConfirm
- Tree
- NumberInput
- UnitInput
- UnitTable
Storybook
To see live examples and demos of the components, please visit our Storybook.
License
This project is open-source and available under the MIT License.
Questions or Issues?
If you have any questions or encounter any issues, please open an issue on the issues page of the repository.
Components Details
Accordion Component
The Accordion component provides a versatile way to toggle visibility of content. It can be expanded to show content or collapsed to hide content, with additional options for styling and behavior customization.
Properties
| Prop Name |
Description |
Default Value |
heading |
The content displayed in the accordion header. |
None (required) |
expanded |
If true, the accordion will be initially expanded. |
false |
managed |
Determines if the accordion's expansion state is controlled externally. |
false |
bordered |
If true, adds a border to the accordion. |
false |
padding |
If true, adds padding inside the accordion content area. |
true |
children |
The content to be displayed within the accordion when it is expanded. |
None (optional) |
onClick |
Function to handle click events on the accordion header. |
None (optional) |
squareBottom |
If true, the bottom of the accordion will be square instead of rounded. |
false |
testId |
An optional identifier used for testing. |
None (optional) |
Usage Example
<Accordion heading="Section 1" expanded bordered onClick={() => console.log('Accordion clicked')}>
Content goes here
</Accordion>
AccordionWithDefaultToggle
An enhanced accordion component that includes a default toggle feature, allowing for more interactive and user-driven content display. It extends the basic functionality of an accordion by offering a built-in toggle option with customizable label and behavior.
Props
| Prop Name |
Description |
Default Value |
heading |
The content to be displayed in the accordion header. |
None (required) |
toggleLabel |
Label for the default toggle switch. |
None (required) |
expanded |
Controls if the accordion is expanded or collapsed by default. |
false |
defaultEnabled |
Determines if the default toggle is enabled. |
true |
onClickDefaultToggle |
Function called when the default toggle is clicked. Receives the change event as an argument. |
None (optional) |
padding |
If true, adds padding to the accordion content for better spacing. |
true |
children |
The content to be displayed inside the accordion when it is expanded. |
None (optional) |
Usage Example
<AccordionWithDefaultToggle
heading="Section 1"
toggleLabel="Enable Section"
onClickDefaultToggle={(evt) => console.log(evt.target.checked)}
expanded
defaultEnabled
padding
>
{/* Content here */}
</AccordionWithDefaultToggle>
Actions
The Actions component is designed to display a set of actions or options. It supports primary actions, subactions, icons, tooltips, and can conditionally hide or disable actions. Ideal for implementing interactive lists, toolbars, or context menus within your application.
Properties
| Prop Name |
Description |
Type |
Default Value (optional) |
actions |
Array of action items to display. |
IAction[] |
|
closeLayer |
Function to close the action layer. Optional. |
TEmpty (Function with no arguments and no return value) |
None |
IAction Properties
| Prop Name |
Description |
Type |
Default Value (optional) |
label |
Text label for the action. |
TStringNumberNull (String, number, or null) |
None |
childComponent |
Component to render as a child. |
ReactNode | (() => ReactNode) |
None |
subActions |
Array of subaction items. |
ISubAction[] |
None |
primary |
Marks the action as primary. |
boolean |
False |
icon |
Icon to display alongside the label. |
ReactNode |
None |
testId |
Identifier for testing purposes. |
string |
None |
hidden |
Whether the action is hidden. |
boolean |
False |
disabled |
Whether the action is disabled. |
boolean |
False |
onClick |
Function to call when the action is clicked. |
(evt: React.MouseEvent, id?: TStringOrNumber) => void |
None |
tooltip |
Tooltip to display on hover. |
ReactNode | string |
None |
Usage Example
<Actions
actions={[
{
label: 'Action 1',
onClick: () => console.log('Action 1 clicked'),
primary: true,
},
{
label: 'Action 2',
onClick: () => console.log('Action 2 clicked'),
disabled: true,
},
{
label: 'Action 3',
onClick: () => console.log('Action 3 clicked'),
tooltip: 'This is a tooltip for Action 3',
},
]}
/>
Badge
The Badge component is used to display a small badge, often used to show a count or to label an item with a short piece of text. This component can be customized with color, size, and optional dot mode for notifications or status indicators.
Properties
| Prop Name |
Description |
Default Value |
| children |
The content inside the badge. |
None (optional) |
| color |
The color of the badge. |
'' (empty string) |
| title |
The title or text displayed inside the badge. |
None (optional) |
| dot |
If true, displays a dot instead of the children. |
false |
| margin |
Margin around the badge. |
None (optional) |
| small |
If true, displays a smaller version of the badge. |
false |
Usage Example
<Badge color="red" title="New" dot margin="0 8px" small>
{/* Children here, if any */}
</Badge>
Breadcrumb Component
The Breadcrumb component displays a navigation path, typically used to show the user's location within a hierarchical structure.
Props:
| Prop Name |
Description |
Default Value |
| links |
An array of objects representing the breadcrumb links. (See ILinkProps for details) |
Required |
| small |
If true, displays a smaller version of the breadcrumb. |
false |
ILinkProps Interface:
This interface defines the properties for each breadcrumb link.
| Prop Name |
Description |
| type |
The type of the link (implementation-specific). |
| label |
The text displayed for the link. |
| title |
Muted caption rendered above the link label. |
| url |
The URL the link points to. |
| onClick |
A function to be called when the link is clicked. |
| active |
If true, indicates the link is the current location. |
| disabled |
If true, the link is disabled and cannot be clicked. |
| element |
A React node to render instead of the default link behavior. |
Usage Example:
<Breadcrumb
links={[
{ title: 'Section', label: 'Home', url: '/' },
{ label: 'Products', url: '/products' },
{ label: 'Current Product', active: true },
]}
/>
Button
The Button component is a versatile interface element that supports various styles and states, including active, basic, colored, disabled, and loading states. It's suitable for a wide range of actions within an application, from form submissions to interactive commands.
Props
| Prop |
Description |
Default Value |
active |
Shows the button in an active state. |
false |
basic |
Applies a link-style appearance to the button. |
false |
colored |
Applies color styling. Can be boolean or string (color code or name). |
false |
disabled |
If true, disables the button. |
false |
groupOrder |
Specifies the button's position in a group (e.g., start, middle, end). |
None (optional) |
icon |
An icon to be displayed on the button. Deprecated in favor of using label. |
None (optional) |
ignoreDisabledContext |
Allows the button to be enabled even when inside DisabledContext. |
false |
label |
The content of the button, which can be text or a ReactNode. |
None (optional) |
loading |
Shows an activity indicator, suggesting that an action is in progress. |
false |
name |
The name of the button, which can be used in forms. |
None (optional) |
onClick |
Function to call when the button is clicked. |
None (optional) |
pill |
Deprecated. Use round for rounded corners instead. |
false |
round |
If true, applies rounded corners to the button. |
false |
small |
If true, displays the button in a smaller size. |
false |
styles |
Custom styles to be applied to the button. |
None (optional) |
width |
The width of the button, can be a number or string. |
None (optional) |
title |
Tooltip text for the button. |
None (optional) |
type |
The button type (e.g., "button", "submit"). |
button |
error |
Displays an error state or message. |
None (optional) |
warning |
Displays a warning state or message. |
None (optional) |
testId |
A test identifier for the button. |
None (optional) |
tooltip |
Tooltip content. Can be text or a ReactNode. |
None (optional) |
inverted |
Deprecated. |
false |
tabIndex |
The tab index of the button. |
None (optional) |
Usage Example