### 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 item Second item Third item // Spacing options: xxs=4px, xs=8px, sm=12px, md=16px, lg=24px, xl=40px, xxl=64px Tight spacing Loose spacing // Alternative gap prop (alias for spacing) Using gap prop // Alignment Stretch (default) Center aligned Start aligned End 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 1 Item 2 Item 3 // Direction Horizontal (default) Vertical Reversed horizontal Reversed vertical // Justify content (main axis) Start (default) Center End Space between Space around Space evenly // Align items (cross axis) Align start (default) Align center Align end Align 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 Logo Home About Contact // Card grid example Card 1 Card 2 Card 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 1 Content for section 1 Section 2 Content for section 2 // Width control // Full example Above the divider Below 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 around Top and bottom margins Horizontally centered with auto margins // Background colors Primary background Darker primary Accent background Alert background Gray background // Border Black border Gray border Primary color border // Border radius Small radius Medium radius Large radius Full/pill radius // Width options Full width (100%) Fixed width with constraints // Text styling Styled text content Centered text Non-wrapping text // Inline display Inline box // Different HTML elements Section element Article element Aside element // Complex example: Card-like component Card Title Card 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 (
    {error && {error}}
    ); } ``` -------------------------------- ### Center Layout Component Examples (React) Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Illustrates the use of the Center component for centering content. It can center children both horizontally and vertically. Imported from '@ubie/ubie-ui'. ```tsx import { Center, Text, Box } from '@ubie/ubie-ui'; // Basic centered content
    Centered content
    // With explicit dimensions
    Centered box
    // Full page center (e.g., loading screen)
    Loading...
    ``` -------------------------------- ### Heading Component Examples (React) Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Demonstrates the usage of the Heading component, showcasing semantic HTML element support, various size options, and optional leading border decoration. It also covers color, text alignment, bold property, and no-wrap functionality, importing Heading and Stack from '@ubie/ubie-ui'. ```tsx import { Heading, Stack } from '@ubie/ubie-ui'; // Basic headings with semantic HTML elements Page Title Section Heading Subsection Heading Minor Heading Small Heading // Heading sizes: xs=16px, sm=18px, md=20px (default), lg=24px, xl=28px Extra Small Small Medium (default) Large Extra Large // With leading border decoration Section with Border // Colors Main color (default) White (for dark backgrounds) // Text alignment Centered Heading // Non-bold heading Normal weight heading // No wrap Single line heading that won't wrap // Full example Welcome to Ubie Getting Started Installation ``` -------------------------------- ### Ubie UI Input Component Example Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Shows how to use the Input, Label, ErrorMessage, and HelperMessage components for creating a styled text input field. It includes state management for input value and validation error, along with accessibility features like htmlFor and data-testid. ```tsx import { Input, Label, ErrorMessage, HelperMessage } from '@ubie/ubie-ui'; import { useState } from 'react'; function EmailForm() { const [email, setEmail] = useState(''); const [error, setError] = useState(''); const handleChange = (e: React.ChangeEvent) => { const value = e.target.value; setEmail(value); setError(value.includes('@') ? '' : 'Please enter a valid email'); }; return (
    We'll never share your email {error && {error}}
    ); } ``` -------------------------------- ### Ubie UI Button Component Examples Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Demonstrates the usage of the Button and LinkButton components from Ubie UI. It covers various variants, sizes, states (loading, disabled), icon placements, block display, margin props, and integration with Next.js Link component. ```tsx import { Button, LinkButton } from '@ubie/ubie-ui'; // Primary button (default) // Button variants // Button sizes // Full width button // With icons // Loading state // Disabled state // Submit button for forms // Margin props // Link styled as button Go to Next Page // Link button with custom render (e.g., Next.js Link) import Link from 'next/link'; }>Dashboard ``` -------------------------------- ### ActionModal Examples in React Source: https://context7.com/ubie-oss/ubie-ui/llms.txt ActionModal is a versatile modal dialog for user confirmations and decisions. It supports primary and secondary actions, destructive actions, fixed heights with scrolling, and hero images. It requires React and the '@ubie/ubie-ui' library. ```tsx import { ActionModal, Button, Stack, Text } from '@ubie/ubie-ui'; import { useState } from 'react'; function ConfirmDialog() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(false)} onPrimaryAction={() => { console.log('Confirmed!'); setIsOpen(false); }} primaryActionLabel="Confirm" closeLabel="Cancel" > Are you sure you want to proceed with this action? ); } // With secondary action function ThreeButtonModal() { const [isOpen, setIsOpen] = useState(false); return ( setIsOpen(false)} onPrimaryAction={() => { /* save and close */ }} primaryActionLabel="Save" onSecondaryAction={() => { /* discard and close */ }} secondaryActionLabel="Discard" closeLabel="Cancel" > You have unsaved changes. What would you like to do? ); } // Alert/destructive action setIsOpen(false)} onPrimaryAction={handleDelete} primaryActionLabel="Delete" primaryActionColor="alert" overlayOpacity="darker" closeLabel="Cancel" > This action cannot be undone. // Fixed height with scrollable content setIsOpen(false)} onPrimaryAction={() => setIsOpen(false)} primaryActionLabel="Accept" >
    {longTermsContent}
    // With hero image } onClose={() => setIsOpen(false)} onPrimaryAction={() => setIsOpen(false)} primaryActionLabel="Get Started" showClose={false} > Thanks for joining us! ``` -------------------------------- ### MessageModal Examples in React Source: https://context7.com/ubie-oss/ubie-ui/llms.txt MessageModal is a simplified modal for displaying information with a single close action. It supports hero images and fixed heights with sticky headers/footers. It requires React and the '@ubie/ubie-ui' library. ```tsx import { MessageModal, Button, Text, Stack } from '@ubie/ubie-ui'; import { useState } from 'react'; function InfoModal() { const [isOpen, setIsOpen] = useState(false); return ( <> setIsOpen(false)} closeLabel="Got it" > This is an informational message for the user. Additional details can be provided here. ); } // With hero image } onClose={() => setIsOpen(false)} > Your operation completed successfully. // Fixed height with sticky elements setIsOpen(false)} >
    {longContent}
    ``` -------------------------------- ### Accordion Examples in React Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Accordion is an expandable and collapsible content panel component. It supports various configurations including headers, descriptions, sizes, initial open state, and toggle callbacks. It requires React and the '@ubie/ubie-ui' library. ```tsx import { Accordion, Stack, Text } from '@ubie/ubie-ui'; // Basic accordion This content is revealed when the accordion is opened. // With description Here is the detailed answer to the question. // Sizes Medium accordion content Small accordion content // Initially open This accordion starts in the open state. // With toggle callback console.log('Accordion toggled')} > Toggle events are tracked. // FAQ section example Ubie UI is a React component library implementing Ubie's design system. Run: npm install @ubie/ubie-ui Yes, all components follow accessibility best practices. ``` -------------------------------- ### Form Helper Components with React Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Shows how to use Label, ErrorMessage, and HelperMessage components for accessible form input labeling and validation feedback. Includes examples for required indicators and different label elements. Requires '@ubie/ubie-ui' and 'react'. ```tsx import { Label, Input, ErrorMessage, HelperMessage, Stack } from '@ubie/ubie-ui'; import { useState } from 'react'; function FormField() { const [value, setValue] = useState(''); const [touched, setTouched] = useState(false); const error = touched && value.length < 3 ? 'Minimum 3 characters required' : ''; return ( {/* Label with required indicator */} {/* Helper text */} Choose a unique username {/* Input field */} setValue(e.target.value)} onBlur={() => setTouched(true)} isInvalid={!!error} /> {/* Error message (announces to screen readers) */} {error && {error}} ); } // Label as different element // Label without required indicator ``` -------------------------------- ### Basic Usage of Ubie UI Button Component Source: https://github.com/ubie-oss/ubie-ui/blob/main/README.md Demonstrates how to import and use the Button component from the Ubie UI library within a React application. It shows the basic structure for rendering a component and mounting it to the DOM. ```tsx import React from 'react'; import ReactDOM from 'react-dom'; import { Button } from '@ubie/ubie-ui'; function App() { return ; } ReactDOM.render(, document.querySelector('#app')); ``` -------------------------------- ### Generate New Component with CLI Source: https://github.com/ubie-oss/ubie-ui/blob/main/README.md Initiates the process of creating a new component using the Ubie UI command-line interface. This command scaffolds the necessary files for a new component and updates the project's index file. ```sh npm run generate ``` -------------------------------- ### Toggle Component Usage (React) Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Demonstrates the controlled and uncontrolled modes of the Toggle component, including disabled states and default checked values. It utilizes the useState hook for managing toggle states and imports necessary components from '@ubie/ubie-ui'. ```tsx import { Toggle, Stack, Text } from '@ubie/ubie-ui'; import { useState } from 'react'; function SettingsPanel() { const [notifications, setNotifications] = useState(true); const [darkMode, setDarkMode] = useState(false); return ( {/* Controlled toggle */} {/* Controlled toggle */} {/* Uncontrolled toggle with default value */} {/* Disabled toggle */} ); } ``` -------------------------------- ### Text Component Variations (React) Source: https://context7.com/ubie-oss/ubie-ui/llms.txt Illustrates the various styling and functional options for the Text component, including size, color, weight, line height, alignment, and HTML element rendering. It imports the Text component from '@ubie/ubie-ui'. ```tsx import { Text } from '@ubie/ubie-ui'; // Basic text Default body text paragraph // Text sizes (body type): xs, sm, md (default), lg Extra small text Small text Medium text (default) Large text // Text colors Main text color (default) Subdued text Link text Subdued link Disabled text Alert/error text White text (for dark backgrounds) // Bold text Bold text // Line height (leading) Default line height Narrow line height Tight line height // Text alignment Left aligned Center aligned Right aligned // No wrap This text will not wrap to the next line // Different HTML elements Inline span element Paragraph element (default) Div element Link element (auto link color) // Text types: body (default), heading, button, tag Heading style text Button style text Tag style text // With custom render for framework links import Link from 'next/link'; }>Next.js Link ``` -------------------------------- ### TextArea: Multi-line Text Input with Validation (React) Source: https://context7.com/ubie-oss/ubie-ui/llms.txt A multi-line text input component that supports validation states. It's useful for longer form content and includes features like placeholder text and row adjustment. Dependencies include React and the ubie-ui library. ```tsx import { TextArea, Label, ErrorMessage } from '@ubie/ubie-ui'; import { useState } from 'react'; function FeedbackForm() { const [feedback, setFeedback] = useState(''); const isInvalid = feedback.length > 500; return (