![Rio](https://img.shields.io/badge/Rio-outline.svg?color=%2311e8e3e&link=https%3A%2F%2Frio.dev&style=flat-square&logo=data:image/svg%2bxml;base64, )
![Version](https://img.shields.io/pypi/v/rio-ui?color=%2311e8e3e&style=flat-square)
![Discord](https://img.shields.io/discord/1213589765484576818?color=%2311e8e3e&label=discord&style=flat-square)
![Python Version](https://img.shields.io/pypi/pyversions/rio-ui?style=flat-square)
![License](https://img.shields.io/pypi/l/rio-ui?color=%2311e8e3e&style=flat-square)
![GitHub Stars](https://img.shields.io/github/stars/rio-labs/rio?style=flat-square)

<!-- https://shields.io/badges -->

<img src="https://github.com/rio-labs/rio/blob/dev/rio/assets/hosted/rio-logos/logo-and-text-horizontal.png?raw=true" alt="Rio Logo" style="width: 16rem" />

🌊 You've arrived at **Rio**, an easy to use framework for creating websites and
apps.

🐍 Rio is based **entirely on Python**. You **won't need a single line of HTML, CSS, or
JavaScript** to create beautiful, modern apps.

[Tutorial](https://rio.dev/get-started) - [Examples](https://rio.dev/examples) - [Discord](https://discord.gg/7ejXaPwhyH) - [Docs](https://rio.dev/docs) - [Source Code](https://github.com/rio-labs/rio)

Rio brings React-style components to Python. Pull from a wealth of built-in
components and combine them to create your own custom components. Then combine
those into entire apps. Best of all, Rio apps can run both locally on your
machine and on the web.

## Features 🧩

-   Modern, **declarative UI** framework
-   **100% Python** - Zero HTML, CSS, or JavaScript required
-   Over **50 Built-in components** for common UI elements, such as `rio.Switch`, `rio.Button`, and `rio.Text`, and many more
-   Integrates with **modern Python tooling**: Thanks to being **entirely Type Safe** editors can give you instant suggestions and highlight problems right away
-   Apps can run **both locally and on the web**
-   **Open Source & Free forever**

## Installation 🛠️

Rio is available on PyPI, so you can install it using pip:

```bash
pip install rio-ui
```

## Getting Started 🎓

Rio comes with a very helpful command line utility to help you out. Create a new project in one short command:

```bash
rio new
```

You can choose from a variety of built-in templates to get you started. Here's a complete example to create a project based on the tic-tac-toe template:

```bash
rio new my-project --type website --template "Tic-Tac-Toe"
cd my-project
rio run
```

You'll have your first app up and running in seconds!

## How it works 🧠

TODO: Minimal example

```python
from typing import *  # type: ignore
import rio
from openai import AsyncOpenAI

client = AsyncOpenAI()


class DallEPage(rio.Component):
    prompt: str = ""
    image_url: str = ""
    is_loading: bool = False

    async def get_image(self) -> None:
        """Get an image by prompt."""

        self.is_loading = True
        await self.force_refresh()

        if self.prompt == "":
            self.image_url = ""
            self.is_loading = False
            return

        try:
            response = await client.images.generate(
                model="dall-e-2",
                prompt=self.prompt,
                size="256x256",
                quality="standard",
                n=1,
            )
            self.image_url = response.data[0].url

        finally:
            self.is_loading = False

    def build(self) -> rio.Component:

        return rio.Rectangle(
            content=rio.Card(
                rio.Column(
                    rio.Text("DALL-E", style="heading1"),
                    rio.TextInput(
                        text=self.bind().prompt,
                        label="Prompt:",
                    ),
                    rio.Button(
                        "Create Image",
                        on_press=self.get_image,
                        is_loading=self.is_loading,
                    ),
                    # Add the image to the page if it exists
                    *(
                        [
                            rio.Image(
                                rio.URL(self.image_url),
                                height=36,
                            )
                        ]
                        if self.image_url
                        else []
                    ),
                    spacing=1,
                    margin=2,
                ),
                width=40,
                align_x=0.5,
                align_y=0.5,
                margin=2,
            ),
            fill=rio.Color.GREY,
        )


# Run the app
app = rio.App(
    pages=[
        rio.Page(
            name="Home",
            page_url="",
            build=DallEPage,
        ),
    ],
)
```

## Status: In Development 🚧

Rio is still in development. We're working hard to bring you the best possible
experience. If you have any feedback, please let us know on [our Discord server](https://discord.gg/7ejXaPwhyH).

## Contributing 🤝

TODO: Write how someone can contribute to the project. :)
