### Install Ubie UI Package
Source: https://github.com/ubie-oss/ubie-ui/blob/main/README.md
Installs the Ubie UI package using npm. This is the primary step to integrate the component library into a React project. It requires Node.js and npm to be installed.
```sh
npm install @ubie/ubie-ui
```
--------------------------------
### Stack Component Examples - Ubie UI (TypeScript/React)
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Illustrates the usage of the Stack component for vertical layout. Examples cover basic stacking with spacing, different spacing options, alignment, padding and margin, width control, rendering different HTML elements, and a form layout example.
```tsx
import { Stack, Box, Text, Heading } from '@ubie/ubie-ui';
// Basic stack with spacing
First itemSecond itemThird item
// Spacing options: xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
Tight spacingLoose spacing
// Alternative gap prop (alias for spacing)
Using gap prop
// Alignment
Stretch (default)Center alignedStart alignedEnd aligned
// With padding and margin
Padded and margined stack
// Width control
Width-constrained stack
// Different HTML element
List item 1
List item 2
// Form layout example
```
--------------------------------
### Install React Peer Dependencies
Source: https://github.com/ubie-oss/ubie-ui/blob/main/README.md
Installs React and ReactDOM as peer dependencies, which are required for Ubie UI to function. These should already be present in most React projects.
```sh
npm install react react-dom
```
--------------------------------
### Icon Component Examples (React)
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Shows how to use the Icon component to render icons from the '@ubie/ubie-icons' package. It allows for customization of size and color. Imported from '@ubie/ubie-ui'.
```tsx
import { Icon } from '@ubie/ubie-ui';
// Basic icon
// Icon sizes: xs=16px, sm=20px, md=24px (default), lg=28px, xl=32px, xxl=64px, xxxl=80px, xxxxl=104px
// Icon colors
// With accessible label (for meaningful icons)
// Decorative icon (no label = aria-hidden="true")
// Common icons
// Back arrow
// Forward arrow
// Checkmark
// Close/X
// Hamburger menu
// Search
// Settings gear
```
--------------------------------
### Install Ubie UI and Dependencies
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Installs the Ubie UI package along with its required peer dependencies: @ubie/design-tokens, @ubie/ubie-icons, @headlessui/react, react, and react-dom. This command is essential for setting up Ubie UI in a React project.
```bash
npm install @ubie/ubie-ui @ubie/design-tokens @ubie/ubie-icons @headlessui/react react react-dom
```
--------------------------------
### Flex Layout Component Examples (React)
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Demonstrates the usage of the Flex component for creating flexible and responsive layouts. It supports various properties for direction, alignment, spacing, and wrapping. Imported from '@ubie/ubie-ui'.
```tsx
import { Flex, FlexItem, Box, Text } from '@ubie/ubie-ui';
// Basic horizontal flex
Item 1Item 2Item 3
// Direction
Horizontal (default)VerticalReversed horizontalReversed vertical
// Justify content (main axis)
Start (default)CenterEndSpace betweenSpace aroundSpace evenly
// Align items (cross axis)
Align start (default)Align centerAlign endAlign stretch
// Wrap
{items.map((item) => {item})}
// Gap/spacing: xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px
Large gap
// Full width and height
Full dimensions
// Inline flex
Inline flex container
// Padding and margin
Spaced flex
// Navigation bar example
LogoHomeAboutContact
// Card grid example
Card 1Card 2Card 3
```
--------------------------------
### Example: Creating a Button Component
Source: https://github.com/ubie-oss/ubie-ui/blob/main/README.md
Illustrates the interactive prompts and file generation process when creating a new 'Button' component using the `npm run generate` command. It shows the files created and the automatic update of the index file.
```sh
? Please select the output destination directory. src
? Please enter a component name. Button
🐶 Generated 3 files!
✔ src/components/Button/Button.tsx
✔ src/components/Button/Button.module.css
✔ src/stories/Button.stories.tsx
> @ubie-inc/ofro-elements@0.0.1 generate:barrel
> node ./scripts/barrel.mjs
✔ src/index.ts has been updated
```
--------------------------------
### Stepper Component Example with React
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Demonstrates the usage of the Stepper component for multi-step processes. It shows basic implementation, customization with icons, and margin adjustments. Requires '@ubie/ubie-ui' and 'react'.
```tsx
import { Stepper, Stack, Button } from '@ubie/ubie-ui';
import { useState } from 'react';
function MultiStepForm() {
const [currentStep, setCurrentStep] = useState(0);
const steps = [
{ label: 'Personal Info' },
{ label: 'Contact Details' },
{ label: 'Review' },
{ label: 'Complete' },
];
return (
{currentStep === 0 &&
Personal information form...
}
{currentStep === 1 &&
Contact details form...
}
{currentStep === 2 &&
Review your information...
}
{currentStep === 3 &&
Thank you for completing the form!
}
);
}
// With custom icons
const stepsWithIcons = [
{ label: 'Account', icon: 'UserIcon', doneIcon: 'CheckAIcon' },
{ label: 'Payment', icon: 'CardIcon', doneIcon: 'CheckAIcon' },
{ label: 'Confirm', icon: 'FileIcon', doneIcon: 'CheckAIcon' },
];
// With margins
```
--------------------------------
### Divider Component Example with React
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Illustrates the use of the Divider component to create horizontal rules. Examples cover basic usage, border color variations, margin control, and width adjustments. Requires '@ubie/ubie-ui'.
```tsx
import { Divider, Stack, Text, Heading } from '@ubie/ubie-ui';
// Basic divider
// Border color variants
// Default
// With margins
Section 1Content for section 1Section 2Content for section 2
// Width control
// Full example
Above the dividerBelow the divider
```
--------------------------------
### Box Component Examples - Ubie UI (TypeScript/React)
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Demonstrates various use cases for the Box component, including padding, margin, background colors, borders, radius, width control, text styling, inline display, and rendering different HTML elements. It also shows a complex example of a card-like structure.
```tsx
import { Box, Text, Heading } from '@ubie/ubie-ui';
// Basic box with padding
Content with medium padding all around
// Padding options: xxs, xs, sm, md, lg, xl, xxl
Asymmetric padding
// Margin options
Margin all aroundTop and bottom marginsHorizontally centered with auto margins
// Background colors
Primary backgroundDarker primaryAccent backgroundAlert backgroundGray background
// Border
Black borderGray borderPrimary color border
// Border radius
Small radiusMedium radiusLarge radiusFull/pill radius
// Width options
Full width (100%)Fixed width with constraints
// Text styling
Styled text content
Centered textNon-wrapping text
// Inline display
Inline box
// Different HTML elements
Section elementArticle elementAside element
// Complex example: Card-like component
Card TitleCard description text goes here
```
--------------------------------
### Ubie UI Select Component Example
Source: https://context7.com/ubie-oss/ubie-ui/llms.txt
Illustrates the use of the Select, Label, and ErrorMessage components for creating a custom dropdown select element. This example demonstrates state management for the selected value and validation, including options for disabling the select and displaying error messages.
```tsx
import { Select, Label, ErrorMessage } from '@ubie/ubie-ui';
import { useState } from 'react';
function CountrySelect() {
const [country, setCountry] = useState('');
const [error, setError] = useState('');
const handleChange = (e: React.ChangeEvent) => {
setCountry(e.target.value);
setError(e.target.value ? '' : 'Please select a country');
};
return (