Examples

This guide walks you through the example projects included in the ruio repository.

Available Examples

The /examples directory contains working demonstrations of ruio:

  • vite-simple/ - Minimal starter showing basic setup

  • blog/ - Realistic blog layout with nested components

Running the Examples

Prerequisites

  1. Clone the ruio repository:

    git clone https://github.com/gary-rivera/ruio.git
    cd ruio
  2. Install dependencies:

    npm install

Starting an Example

Run the development server:

This will start Vite's dev server and you can explore the examples in your browser.

Example 1: vite-simple

Location: examples/vite-simple/

What It Demonstrates

This minimal example shows:

  • Basic ruio setup with RuioContextProvider

  • Simple component hierarchy

  • How ruio visualizes nested components

Code Structure

Try It Out

  1. Open the example in your browser

  2. Click the ruio toggle button

  3. Hover over different elements

  4. Click the crosshair icon to enter selection mode

  5. Click any element to make it the root

Example 2: blog

Location: examples/blog/

What It Demonstrates

This realistic example shows:

  • Complex, nested component structure

  • Real-world layout patterns (header, sidebar, content, footer)

  • Multiple levels of component nesting

  • Using ruio-exclude for UI elements

Code Structure

Component Hierarchy

Try It Out

  1. Enable ruio with the toggle

  2. Notice how different nesting levels have different colors

  3. Use element selection mode to focus on:

    • Just the Header

    • A single BlogPost

    • The Sidebar

  4. Observe how complex layouts become easier to understand

Real-World Example

For a production example of ruio in action, check out this calculator app.

What It Shows

  • ruio integrated into a real application

  • How ruio helps debug calculator layout

  • Complex button grid visualization

  • State management with visual feedback

Creating Your Own Example

Want to test ruio in your own project? Here's a quick template:

Common Patterns

Pattern 1: Modal with Exclusion

Pattern 2: Conditional Rendering

Pattern 3: List Rendering

Tips for Examples

  1. Start Simple: Begin with the vite-simple example to understand basics

  2. Graduate to Complex: Move to the blog example for real-world patterns

  3. Experiment: Modify the examples to test different scenarios

  4. Use Selection Mode: Practice using element selection to focus on specific components

  5. Exclude Strategically: Try adding ruio-exclude to different elements to see the effect

Troubleshooting Examples

Example Won't Start

Ruio Not Appearing

  • Check that NODE_ENV is not set to 'production'

  • Verify RuioContextProvider is wrapping your components

  • Check browser console for errors

Borders Not Showing

  • Make sure ruio is enabled (click the toggle)

  • Check that elements don't have ruio-exclude class

  • Verify your components are descendants of RuioContextProvider

Next Steps

Last updated

Was this helpful?