### Install Mielo UI Packages
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Installs the necessary Mielo UI packages, including the core CSS framework and the React component library, using npm.
```bash
npm install @mielo-ui/mielo @mielo-ui/mielo-react
```
--------------------------------
### Modal Component Example - React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Shows how to implement a Modal component for displaying content in a full-screen overlay. Includes state management for opening/closing, backdrop click, and escape key handling. Requires the @mielo-ui/mielo-react library and React's useState hook.
```tsx
import { Modal } from "@mielo-ui/mielo-react"
import { useState } from "react"
function ModalExample() {
const [isOpen, setIsOpen] = useState(false)
return (
setIsOpen(false)}
>
Modal Content
This content appears in a modal overlay.
Click outside or press Escape to close.
)
}
```
--------------------------------
### Install Mielo UI Packages
Source: https://github.com/mielo-ui/mielo-react/blob/main/README.md
Installs the core mielo UI package and the mielo-react component library using npm or yarn. This is the first step to using Mielo components in your project.
```sh
npm install @mielo-ui/mielo @mielo-ui/mielo-react # or use "yarn add" instead
```
--------------------------------
### Window Component Examples in React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Illustrates the Mielo UI Window component for creating desktop application-style windows. Features include optional header bars, split view layouts, and window controls for Tauri/Electron apps. Supports transparent and accent-colored themes, and draggable headers.
```tsx
import { Window, HeaderBar, View, Button } from "@mielo-ui/mielo-react"
function WindowExample() {
return (
)
}
```
--------------------------------
### Item Component Examples - React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Illustrates the usage of the Item component for creating versatile list items. Supports titles, descriptions, icons, side content, labels, clickable actions, links, and various layout/style variants. Requires the @mielo-ui/mielo-react library.
```tsx
import { Item } from "@mielo-ui/mielo-react"
function ItemExample() {
return (
{/* Basic item with title */}
{/* Item with title and description */}
{/* Item with icon */}
*}
/>
{/* Item with side content */}
5 new}
/>
{/* Item with label badge */}
New}
/>
{/* Clickable item with active state */}
console.log("Clicked")}
/>
{/* Item as link */}
{/* Accent and color variants */}
{/* Layout variants */}
{/* Custom content instead of title/description */}
Custom Content
Any React content here
}
/>
{/* Hover state */}
)
}
```
--------------------------------
### Mielo UI React Entry Component Example
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Demonstrates the usage of the Mielo UI React Entry component, a styled text input with floating label, prefix/postfix slots, and visual variants. It handles focus states for label and placeholder animation. Dependencies include React and the @mielo-ui/mielo-react library.
```tsx
import { Entry } from "@mielo-ui/mielo-react"
import { useState } from "react"
function EntryExample() {
const [username, setUsername] = useState("")
const [password, setPassword] = useState("")
return (
{/* Basic entry with floating label */}
setUsername(e.target.value)}
/>
{/* Password input */}
setPassword(e.target.value)}
/>
{/* Accent colors */}
{/* Style variants */}
{/* Size variants */}
{/* With prefix and postfix */}
@}
postfix={}
/>
{/* Disabled state */}
{/* With container ID for styling */}
)
}
```
--------------------------------
### Build Mielo React Library from Source
Source: https://github.com/mielo-ui/mielo-react/blob/main/README.md
Provides commands to clone the Mielo React repository, install dependencies, format code, and build the library. This is for developers who want to build from source.
```sh
git clone https://github.com/mielo-ui/mielo-react
cd mielo-react
npm install # or "yarn"
npm run fmt # format & linting components
npm build # build module library with .d.ts
```
--------------------------------
### View Component Examples (React)
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
The View component serves as a versatile content container, offering various background styles (panel, windows, content, osd), scrolling capabilities, and decorative borders. It also supports activatable states for interactive elements and can be themed with accent colors or custom colors.
```tsx
import { View } from "@mielo-ui/mielo-react"
function ViewExample() {
return (
)
}
```
--------------------------------
### Mielo React Button Component Examples
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Showcases various configurations and styles for the Mielo React Button component. This includes basic usage, accent colors, size variants, style modifiers, icon integration, and usage as a link or within a button group.
```tsx
import { Button } from "@mielo-ui/mielo-react"
function ButtonExample() {
return (
{/* Basic button with label */}
)
}
```
--------------------------------
### Rows Component Example - React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Illustrates the Mielo UI Rows component for creating structured form layouts. It showcases basic row usage, rows with select and entry inputs, and a more complex settings page example. Dependencies include React's useState hook and various Mielo UI components like Rows, Select, Entry, and Item.
```tsx
import { Rows, Select, Entry, Item, OptionValue } from "@mielo-ui/mielo-react"
import { useState } from "react"
function RowsExample() {
const [theme, setTheme] = useState()
const [name, setName] = useState("")
const themeOptions: OptionValue[] = [
{ value: "light", title: "Light" },
{ value: "dark", title: "Dark" },
{ value: "system", title: "System" }
]
return (
{/* Basic tabs with array */}
setSelected(name)}
/>
{/* Tabs with animated indicator */}
{/* Tabs with accent color */}
{/* Transparent tabs */}
{/* Record-based tabs */}
{/* Tab content based on selection */}
{selected === "home" &&
Home content
}
{selected === "profile" &&
Profile content
}
{selected === "settings" &&
Settings content
}
{selected === "help" &&
Help content
}
{/* Raw tabs for custom content */}
)
}
```
--------------------------------
### Mielo React Checkbox Component Examples
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Demonstrates the usage of the Mielo React Checkbox component, including basic functionality, accent colors, size variants, disabled states, circular styling, and toggle mode (switch). It also shows how to use custom icons and children for labels.
```tsx
import { Checkbox } from "@mielo-ui/mielo-react"
import { useState } from "react"
function CheckboxExample() {
const [isChecked, setIsChecked] = useState(false)
return (
{/* Basic checkbox with label */}
setIsChecked(e.target.checked)}
/>
{/* Checkbox with accent colors */}
{/* Size variants */}
{/* Disabled state */}
{/* Circular style */}
{/* Toggle mode (switch style) */}
setIsChecked(e.target.checked)}
/>
{/* Toggle with custom icons */}
ON,
unchecked: OFF
},
layout: {
checked: *,
unchecked: -
}
}}
/>
{/* Using children instead of label */}
Custom content as children
)
}
```
--------------------------------
### Dropdown Component Example in React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Demonstrates the usage of the Mielo UI Dropdown component in React. It covers basic dropdown functionality, programmatic control via ref, custom menu height, and custom class names for styling. This component handles open/close state, click-outside detection, and keyboard navigation.
```tsx
import { Dropdown, DropdownHandles, Button, List, Item } from "@mielo-ui/mielo-react"
import { useRef } from "react"
function DropdownExample() {
const dropdownRef = useRef(null)
return (
{/* Basic dropdown */}
(
)}
menu={({ close }) => (
{ console.log("Option 1"); close() }}
/>
{ console.log("Option 2"); close() }}
/>
{ console.log("Option 3"); close() }}
/>
)}
/>
{/* Dropdown with ref for programmatic control */}
(
)}
menu={({ close }) => (
)}
/>
{/* Dropdown with custom class names */}
}
menu={() =>
Styled dropdown menu
}
/>
)
}
```
--------------------------------
### HeaderBar Component Examples (React)
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
The HeaderBar component creates a header bar with customizable left, center, and right content areas. It supports various styling options like borders, transparency, and accent colors, and is designed for desktop-style applications, including window dragging support for Tauri and Electron.
```tsx
import { HeaderBar, Button } from "@mielo-ui/mielo-react"
function HeaderBarExample() {
return (
{/* Basic header bar */}
}
right={}
/>
{/* Header bar with window controls */}
}
controls={
-[]x
}
/>
{/* Bordered header bar */}
{/* Transparent header bar */}
{/* Accent colored header bar */}
{/* Desktop draggable header (for Tauri/Electron) */}
)
}
```
--------------------------------
### Collapsible Component Example - React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Demonstrates the Mielo UI Collapsible component for creating expandable content sections. It shows basic usage, an accordion pattern, and how to manage multiple open sections. Dependencies include React's useState hook and Mielo UI's Collapsible and Button components.
```tsx
import { Collapsible, Button } from "@mielo-ui/mielo-react"
import { useState } from "react"
function CollapsibleExample() {
const [isOpen, setIsOpen] = useState(false)
const [sections, setSections] = useState({ a: true, b: false, c: false })
return (
)
}
```
--------------------------------
### Mielo UI React Select Component Example
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Illustrates the Mielo UI React Select component, a customizable dropdown for selection. It supports various options, labels, styling, and event callbacks. Internally uses the Dropdown component and allows custom item rendering. Dependencies include React and @mielo-ui/mielo-react.
```tsx
import { Select, OptionValue } from "@mielo-ui/mielo-react"
import { useState } from "react"
function SelectExample() {
const [selected, setSelected] = useState()
const options: OptionValue[] = [
{ value: "react", title: "React" },
{ value: "vue", title: "Vue.js" },
{ value: "angular", title: "Angular" },
{ value: "svelte", title: "Svelte", description: "Compiler-based framework" }
]
return (
{/* Basic select */}
)
}
```
--------------------------------
### Sidebar Component Examples (React)
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
The Sidebar component provides a collapsible panel suitable for navigation or additional content. It supports different animation styles (width, overlap, shift), header bars, and can be styled with accent colors and size variants. It's often used in conjunction with main content areas.
```tsx
import { Sidebar, HeaderBar, List, Item, Button } from "@mielo-ui/mielo-react"
import { useState } from "react"
function SidebarExample() {
const [isOpen, setIsOpen] = useState(true)
return (
)
}
```
--------------------------------
### Mielo UI Core Types and Usage in React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Defines and demonstrates the core type definitions for Mielo UI components, including size, accent, and color options. These types ensure consistent styling across various components like Button, Entry, Label, Progress, and Checkbox. The example shows how to apply these types for semantic meaning and custom theming.
```typescript
// Size options for components
type CoreSize = "mini" | "tiny" | "small" | "large" | "big" | "huge" | "massive"
// Accent options for semantic coloring
type CoreAccent = boolean | "warning" | "error" | "success"
// Color palette options
type CoreColor =
| "blue"
| "green"
| "yellow"
| "orange"
| "red"
| "purple"
| "brown"
| "pink"
| "deeppurple"
| "indigo"
| "lightgreen"
| "deeporange"
| "light"
| "dark"
// Example usage across components
import { Button, Entry, Label, Progress, Checkbox } from "@mielo-ui/mielo-react"
function CoreTypesExample() {
return (
<>
{/* Size applies to most components */}
{/* Accent for semantic meaning */}
{/* Color for custom theming */}
>
)
}
```
--------------------------------
### Import Mielo CSS and React Components
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Demonstrates how to import the Mielo CSS framework and the Mielo React components into your main application file. Ensure the CSS is imported before components are used.
```typescript
// Import CSS in your main file
import '@mielo-ui/mielo/css/mielo.css'
// Import components
import * as Mie from "@mielo-ui/mielo-react"
```
--------------------------------
### Create and Style Dialog Boxes with Mielo UI React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Demonstrates how to use the Dialog component from '@mielo-ui/mielo-react' to create standalone, modal-attached, and styled dialog boxes. It covers different accent colors, sizes, and action button configurations.
```tsx
import { Dialog, Button } from "@mielo-ui/mielo-react"
import { useState } from "react"
function DialogExample() {
const [isOpen, setIsOpen] = useState(false)
return (
{/* Standalone dialog (not in modal) */}
{/* Dialog with actions */}
{/* Dialog attached to modal */}
setIsOpen(true)}>Open Modal Dialog
{/* Size variants */}
{/* Color variants */}
)
}
```
--------------------------------
### Implement Promise-Based Confirmations with Mielo UI React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Illustrates the usage of the Confirm component from '@mielo-ui/mielo-react' for handling user confirmations via promises. It shows basic confirmation dialogs, custom actions, and three-way choices (confirm/reject/cancel).
```tsx
import { Confirm, ConfirmHandles, Button } from "@mielo-ui/mielo-react"
import { useRef } from "react"
function ConfirmExample() {
const confirmRef = useRef(null)
const handleDelete = async () => {
const result = await confirmRef.current?.confirm()
if (result?.action === "confirm") {
console.log("User confirmed deletion")
// Perform delete operation
} else if (result?.action === "cancel") {
console.log("User cancelled")
} else if (result?.action === "reject") {
console.log("User rejected")
}
}
return (
{/* Confirm with three-way choice (confirm/reject/cancel) */}
Do you accept the terms of service?
)
}
```
--------------------------------
### Progress Component Usage in React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Illustrates the usage of the Mielo UI Progress component in React. It showcases basic progress bars, accent colors, size variants, various indeterminate animation styles, stacked progress bars, and transparent or custom-content bars.
```tsx
import { Progress, ProgressBar } from "@mielo-ui/mielo-react"
function ProgressExample() {
return (
{/* Basic progress bar with percentage */}
{/* Accent colors */}
{/* Size variants */}
{/* Indeterminate animations: pulsating, filling, sliding, swinging */}
{/* Multiple progress bars (stacked) */}
{/* Transparent progress bar */}
{/* Custom content in progress bar */}
)
}
```
--------------------------------
### Use Mielo React Button Component
Source: https://github.com/mielo-ui/mielo-react/blob/main/README.md
Demonstrates how to import and use a Mielo React Button component. It shows importing the Mie namespace and rendering a button with a label and accent color.
```typescript
import * as Mie from "@mielo-ui/mielo-react"
```
--------------------------------
### Radio Component Usage in React
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
Demonstrates how to use the Mielo UI Radio component in a React application. It covers controlled mode with state management, accent colors, size variants, disabled states, and color options.
```tsx
import { Radio } from "@mielo-ui/mielo-react"
import { useState } from "react"
function RadioExample() {
const [selected, setSelected] = useState("option1")
return (
{/* Radio group */}
setSelected("option1")}
>
Option 1
setSelected("option2")}
>
Option 2
setSelected("option3")}
>
Option 3
{/* Accent colors */}
Success
Warning
Error
{/* Size variants */}
SmallLarge
{/* Disabled state */}
Disabled Option
{/* Color variants */}
BluePurple
)
}
```
--------------------------------
### Import Mielo CSS
Source: https://github.com/mielo-ui/mielo-react/blob/main/README.md
Imports the main Mielo CSS file into your project. This ensures that all styles provided by the mielo.css framework are applied to your components.
```css
@import 'mielo/css/mielo.css'
```
--------------------------------
### Create and Style Lists with Mielo UI List Component (React)
Source: https://context7.com/mielo-ui/mielo-react/llms.txt
The List component from '@mielo-ui/mielo-react' creates a styled container for Item components. It's suitable for navigation menus, settings lists, and data displays. The component supports basic lists, navigation-style lists with descriptions and active states, lists with icons and side content, and a shorthand syntax using List.Item.
```tsx
import { List, Item } from "@mielo-ui/mielo-react"
function ListExample() {
return (
{/* Basic list with items */}
{/* Navigation list */}
{/* List with icons and side content */}
B}
side={5}
/>
M}
side={12}
/>
{/* Using List.Item shorthand */}