### Installation and Basic Setup
Source: https://context7.com/umami-software/react-zen/llms.txt
Install the React Zen library and import global styles. Create a basic app structure with ZenProvider for theming and essential components like Box, Heading, Text, and Button.
```bash
npm install @umami/react-zen
```
```tsx
// Import the global styles once at your app root
import '@umami/react-zen/styles.css';
import { ZenProvider, Button, Heading, Text, Box } from '@umami/react-zen';
function App() {
return (
Welcome to React ZenModern, minimalist components
);
}
export default App;
```
--------------------------------
### Install React Zen library via npm
Source: https://github.com/umami-software/react-zen/blob/master/README.md
Installs the @umami/react-zen package using npm. This command adds the library to your project's dependencies, enabling you to import its components and styles. Requires npm installed and internet access.
```shell
npm install @umami/react-zen
```
--------------------------------
### React Zen TextField Component Examples
Source: https://context7.com/umami-software/react-zen/llms.txt
Demonstrates the usage of the TextField component from '@umami/react-zen', showcasing different variants like basic input, password, textarea, read-only with copy, and disabled states. It also includes an example of a controlled input with email validation.
```tsx
import { TextField, Flexbox, Box, Text } from '@umami/react-zen';
import { useState } from 'react';
function TextFieldExamples() {
const [value, setValue] = useState('');
return (
{/* Basic text field */}
{/* Password field */}
{/* Textarea mode */}
{/* Read-only with copy */}
{/* Disabled state */}
);
}
// Controlled input with validation
function ControlledTextField() {
const [email, setEmail] = useState('');
const [error, setError] = useState('');
const validateEmail = (value) => {
const regex = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}$/i;
if (!regex.test(value)) {
setError('Invalid email address');
} else {
setError('');
}
setEmail(value);
};
return (
{error && {error}}
);
}
```
--------------------------------
### React Example: Border Widths
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/design/borders.mdx
Illustrates setting the border width for an ExampleBox component. Accepts numeric values '1' through '4' to control the thickness of the border.
```jsx
```
--------------------------------
### React Example: Border Positions
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/design/borders.mdx
Demonstrates how to set the border position on an ExampleBox component. Supports default (all sides) or specific sides like 'top', 'right', 'bottom', and 'left'.
```jsx
```
--------------------------------
### React Example: Border Colors
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/design/borders.mdx
Demonstrates applying custom border colors to an ExampleBox component. Supports predefined color names like 'primary', 'red', 'blue', and 'green'.
```jsx
```
--------------------------------
### React Zen Select and ComboBox Components Examples
Source: https://context7.com/umami-software/react-zen/llms.txt
Illustrates the use of Select and ComboBox components from '@umami/react-zen' for dropdown selections. The Select component is shown for single selection with a list of countries, and the ComboBox demonstrates searchable input with a list of frameworks.
```tsx
import { Select, SelectItem, ComboBox, ComboBoxItem, Flexbox, Text } from '@umami/react-zen';
import { useState } from 'react';
function SelectExample() {
const [selected, setSelected] = useState('');
const countries = [
{ id: 'us', name: 'United States' },
{ id: 'uk', name: 'United Kingdom' },
{ id: 'ca', name: 'Canada' },
{ id: 'au', name: 'Australia' },
{ id: 'de', name: 'Germany' }
];
return (
{/* Basic select */}
{/* Selected value display */}
{selected && (
Selected: {countries.find(c => c.id === selected)?.name}
)}
);
}
// Searchable ComboBox
function ComboBoxExample() {
const [value, setValue] = useState('');
const frameworks = [
{ id: 'react', name: 'React' },
{ id: 'vue', name: 'Vue.js' },
{ id: 'angular', name: 'Angular' },
{ id: 'svelte', name: 'Svelte' },
{ id: 'next', name: 'Next.js' },
{ id: 'nuxt', name: 'Nuxt.js' }
];
return (
{frameworks
.filter(f =>
f.name.toLowerCase().includes(value.toLowerCase())
)
.map(framework => (
{framework.name}
))
}
);
}
```
--------------------------------
### React Example: Border Radii
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/design/borders.mdx
Shows how to apply different border radius values to an ExampleBox component. Supports predefined radii '1' through '4', and a 'full' option for fully rounded corners.
```jsx
```
--------------------------------
### React Tooltip Example
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/tooltip.mdx
This snippet demonstrates the usage of a React tooltip component. It showcases different placement options (top, left, right, bottom) and the ability to display an arrow. The `TooltipTrigger` and `Tooltip` components are used for triggering and displaying the tooltip content respectively.
```jsx
Hello
```
```jsx
{`Hello`}{`Hello`}{`Hello`}{`Hello`}
```
```jsx
{`Hello`}
{`Hello`}
{`Hello`}
{`Hello`}
```
```jsx
```
--------------------------------
### UI Layout Composition Using Zen Components in JSX
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/index.mdx
This snippet demonstrates composing a welcome card layout using Zen's Box, Flexbox, Heading, Text, and Button components. It relies on React and Zen library installations, with props for styling like padding, alignment, and variants. Outputs a centered, shadowed container with text and interactive button; limitations include dependency on Zen's design system for full styling.
```jsx
Welcome
This is the zen way.
```
--------------------------------
### React Modal Examples with Various Placements
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/modal.mdx
Demonstrates the usage of the Modal component in React, showcasing different placement options (center, top, left, right, bottom, fullscreen) for overlay dialogs. It utilizes DialogTrigger and Button components for interaction.
```jsx
```
--------------------------------
### Image component basic usage
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/image.mdx
Demonstrates basic usage of the Image component with a maxWidth container. The component is imported from the 'react-zen' package and renders an image from a local path with alt text. This example is framework-agnostic beyond React, relies on the image file existing at the given src, and omits explicit width/height or lazy-loading controls.
```JSX
```
--------------------------------
### Import and render Button component from React Zen
Source: https://github.com/umami-software/react-zen/blob/master/README.md
Shows how to import the Button component from the React Zen library and render it within a React functional component. The example demonstrates a minimal usage scenario without extra props. Ensure the stylesheet is imported for proper styling.
```javascript
import { Button } from '@umami/react-zen';
export default function () {
return ;
}
```
--------------------------------
### Display DataTable component with prop definitions in JSX
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/layout/box.mdx
Provides an example of the DataTable component populated with a list of prop definitions and nested DataColumn components. Demonstrates passing complex data arrays and rendering table columns. Useful for documenting component APIs.
```jsx
' },
{ name: 'position', value: 'Responsive<"static" | "relative" | "absolute" | "fixed" | "sticky">' },
{ name: 'backgroundColor', value: 'BackgroundColor' },
{ name: 'borderColor', value: 'BorderColor' },
{ name: 'borderSize', value: 'Responsive<"1" | "2" | "3" | "4">' },
{ name: 'borderTop', value: 'Responsive<"1" | "2" | "3" | "4">' },
{ name: 'borderRight', value: 'Responsive<"1" | "2" | "3" | "4">' },
{ name: 'borderBottom', value: 'Responsive<"1" | "2" | "3" | "4">' },
{ name: 'borderLeft', value: 'Responsive<"1" | "2" | "3" | "4">' },
{ name: 'borderRadius', value: 'Responsive<"1" | "2" | "3" | "4" | "5" | "6">' },
{ name: 'hoverColor', value: 'HoverColor' },
{ name: 'hoverBackgroundColor', value: 'HoverColor' },
{ name: 'hoverBorderColor', value: 'HoverColor' },
{ name: 'padding', value: 'Responsive' },
{ name: 'paddingX', value: 'Responsive' },
{ name: 'paddingY', value: 'Responsive' },
{ name: 'paddingTop', value: 'Responsive' },
{ name: 'paddingRight', value: 'Responsive' },
{ name: 'paddingBottom', value: 'Responsive' },
{ name: 'paddingLeft', value: 'Responsive' },
{ name: 'margin', value: 'Responsive' },
{ name: 'marginX', value: 'Responsive' },
{ name: 'marginY', value: 'Responsive' },
{ name: 'marginTop', value: 'Responsive' },
{ name: 'marginRight', value: 'Responsive' },
{ name: 'marginBottom', value: 'Responsive' },
{ name: 'marginLeft', value: 'Responsive' },
{ name: 'width', value: 'Responsive' },
{ name: 'minWidth', value: 'Responsive' },
{ name: 'maxWidth', value: 'Responsive' },
{ name: 'height', value: 'Responsive' },
{ name: 'minHeight', value: 'Responsive' },
{ name: 'maxHeight', value: 'Responsive' },
{ name: 'flexBasis', value: 'Responsive' },
{ name: 'flexGrow', value: 'Responsive' },
{ name: 'flexShrink', value: 'Responsive' },
{ name: 'gridRow', value: 'Responsive' },
{ name: 'gridColumn', value: 'Responsive' },
{ name: 'order', value: 'Responsive' },
{ name: 'as', value: 'string' },
{ name: 'asChild', value: 'boolean' },
]}
>
```
--------------------------------
### Basic Toggle Group Example (React)
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/toggle-group.mdx
Demonstrates a basic React Toggle Group with single selection mode. It requires the ToggleGroup and ToggleGroupItem components. This component allows users to select a single option from a group of buttons.
```jsx
OneTwoThree
```
--------------------------------
### Flexbox Layout Example (React)
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/layout/flexbox.mdx
Demonstrates the usage of the Flexbox component to create row and column layouts with customizable gap. It showcases the flexibility of Flexbox for arranging child elements.
```jsx
```
--------------------------------
### React Button with onClick Handler
Source: https://context7.com/umami-software/react-zen/llms.txt
Shows how to implement an interactive Button component with an associated click handler. The 'onPress' prop is used to define the function executed when the button is clicked. This example requires '@umami/react-zen'.
```tsx
import { Button } from '@umami/react-zen';
function InteractiveButton() {
const handleClick = () => {
console.log('Button clicked!');
// Perform action
};
return (
);
}
```
--------------------------------
### React Alert Banner Example
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/alert-banner.mdx
Demonstrates the use of the AlertBanner component in React, including variations for error and info alerts. It utilizes React components for the alert banner and associated buttons.
```jsx
}
>
```
--------------------------------
### Text Field with Placeholder - React
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/text-field.mdx
Configures the text field to display placeholder text. The placeholder guides the user on the expected input without being part of the actual value.
```jsx
import {
TextField
} from "@umami-software/react-zen";
function App() {
return ;
}
```
--------------------------------
### Image object fit modes
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/image.mdx
Shows how objectFit controls the image scaling within a fixed-height container. The same image is rendered with cover, fill, contain, scale-down, and none, each illustrating how the image is cropped or sized to fit the container. Uses Box/Column/Label to arrange examples vertically. Ensure sufficient container height and overflow settings to visualize differences; aspect ratio of the source image affects the visual result.
```JSX
```
--------------------------------
### React Navbar Component Implementation
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/navbar.mdx
Demonstrates how to structure a navigation bar using the Navbar component with nested dropdown menus. The example shows three main navigation sections (Product, Resources, Company) each containing sub-menu items, plus an external GitHub link. The component supports hierarchical menu structures and external URL navigation.
```jsx
GitHub
```
--------------------------------
### Theme Management Hook and Components in React TSX
Source: https://context7.com/umami-software/react-zen/llms.txt
This implements theme state management using a Zustand hook with localStorage persistence and system preference detection, including toggle button, radio selector, and provider setup. Dependencies: @umami/react-zen (useTheme, ZenProvider, Button, Flexbox, Text). Inputs: Theme state ('light'|'dark') and color scheme ('system'); outputs: Updated theme application across app. Limitations: Assumes Zustand integration in hook; radio inputs use native HTML without library styling.
```tsx
import { useTheme } from '@umami/react-zen';
import { Button, Flexbox, Text } from '@umami/react-zen';
function ThemeToggleButton() {
const { theme, setTheme } = useTheme();
const toggleTheme = () => {
setTheme(theme === 'light' ? 'dark' : 'light');
};
return (
);
}
// Theme selector with radio buttons
function ThemeSelector() {
const { theme, setTheme } = useTheme();
return (
Theme Settings
);
}
// Initialize theme in app root
import { ZenProvider, useInitTheme } from '@umami/react-zen';
function App() {
return (
);
}
```
--------------------------------
### React Form Submission with Validation
Source: https://context7.com/umami-software/react-zen/llms.txt
This snippet demonstrates how to submit a form with validation using React Hook Form. It includes example validation rules for required fields, minimum length, and pattern matching. It showcases making an API call after successful submission.
```tsx
import {
Form,
FormField,
FormSubmitButton,
FormResetButton,
TextField,
Flexbox
} from '@umami/react-zen';
function LoginForm() {
const handleSubmit = (values) => {
console.log('Form submitted:', values);
// { username: 'john', password: 'secret123' }
// Make API call
fetch('/api/login', {
method: 'POST',
body: JSON.stringify(values),
headers: { 'Content-Type': 'application/json' }
})
.then(res => res.json())
.then(data => console.log('Success:', data))
.catch(err => console.error('Error:', err));
};
return (
);
}
// Complex form with multiple field types
function UserRegistrationForm() {
const [error, setError] = useState(null);
const onSubmit = async (data) => {
try {
const response = await fetch('/api/register', {
method: 'POST',
body: JSON.stringify(data),
headers: { 'Content-Type': 'application/json' }
});
if (!response.ok) throw new Error('Registration failed');
const result = await response.json();
console.log('User registered:', result);
} catch (err) {
setError(err.message);
}
};
return (
);
}
```
--------------------------------
### Toggle Group with Icons (React)
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/toggle-group.mdx
Shows how to use icons within React ToggleGroupItems for a more visually descriptive interface. This example requires Icon and specific icon components (e.g., ExampleIcons.AlignLeft). Each item displays an icon instead of text.
```jsx
```
--------------------------------
### Form Controls: Checkbox, RadioGroup, and Switch in React Zen
Source: https://context7.com/umami-software/react-zen/llms.txt
This example demonstrates binary and multiple choice form components using Checkbox for toggling agreement, RadioGroup for selecting options, and Switch for enabling features like notifications. It relies on React's useState for managing component states and imports from '@umami/react-zen' for UI elements. Inputs are controlled via props like isSelected and onChange; outputs reflect states in a display box. Limitations include dependency on the library's theme system via ZenProvider.
```tsx
import {
Checkbox,
RadioGroup,
Radio,
Switch,
Flexbox,
Text
} from '@umami/react-zen';
import { useState } from 'react';
function FormControlsExample() {
const [checked, setChecked] = useState(false);
const [radioValue, setRadioValue] = useState('option1');
const [switchOn, setSwitchOn] = useState(false);
return (
{/* Checkbox */}
I agree to the terms and conditions
{/* Radio group */}
Option 1Option 2Option 3
{/* Switch */}
Enable notifications
{/* Display state */}
Checkbox: {checked ? 'Checked' : 'Unchecked'}Radio: {radioValue}Switch: {switchOn ? 'On' : 'Off'}
);
}
```
--------------------------------
### React Heading Component Sizing Examples
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/typography/heading.mdx
Illustrates how to control the visual size of the Heading component using the 'size' prop. The 'size' prop accepts values from '1' to '6', corresponding to standard HTML heading levels. This allows for semantic and visual hierarchy control within the UI. Assumes the Heading component internally maps these sizes to appropriate HTML tags or CSS styles.
```jsx
Heading 1Heading 2Heading 3Heading 4Heading 5Heading 6
```
--------------------------------
### Menu with Separators in React JSX
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/menu.mdx
This example adds MenuSeparator components to divide menu items into groups. Depends on Menu, MenuItem, and MenuSeparator from React Zen. Inputs are standard menu items; outputs grouped visual sections. Limited to horizontal separators without styling options shown.
```jsx
```
--------------------------------
### React Heading Component Letter Spacing Examples
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/typography/heading.mdx
Demonstrates controlling letter spacing for the Heading component via the 'spacing' prop. The prop accepts numerical values (1-5), which likely translate to CSS letter-spacing values. This allows for fine-tuning the visual appearance and readability of headings. Assumes the Heading component applies these spacing adjustments via CSS.
```jsx
Letter spacing 1Letter spacing 2Letter spacing 3Letter spacing 4Letter spacing 5
```
--------------------------------
### Basic List in React
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/list.mdx
Creates a simple list with items. Uses the List and ListItem components to display a collection of items. No dependencies beyond React and React-Zen.
```react
OneTwoThreeFourFive
```
--------------------------------
### Basic Icon Usage with SVG - React
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/icon.mdx
Demonstrates the basic usage of the Icon component by wrapping an SVG element. It requires the Icon component and an SVG component (e.g., from ExampleIcons).
```jsx
import { Icon } from 'your-icon-library';
import { Wifi } from 'your-icon-library/icons'; // Assuming icons are imported like this
function MyComponent() {
return (
);
}
```
--------------------------------
### Render table with alignment
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/table.mdx
Configures column alignment using align property. Supports 'start', 'center', and 'end' values. No additional dependencies needed. Does not affect row height or wrapping.
```jsx
```
--------------------------------
### Basic React Select Component Usage
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/select.mdx
Demonstrates the fundamental usage of the React Select component to display a list of options triggered by a button. It requires an array of items and an optional placeholder.
```javascript
import React from 'react';
import { Box, Select } from '@umami/design-system';
function App() {
return (
);
}
```
--------------------------------
### Configurable Spinner and Dots Sizes - React
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/loading.mdx
Demonstrates how to set the size of the Spinner and Dots components using the 'size' prop. Supported sizes include 'sm', 'md', and 'lg'. This allows for visual consistency across different UI contexts.
```jsx
```
--------------------------------
### Configure Grid Item Placement in React
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/layout/grid.mdx
Shows advanced grid layout with explicit row and column placement for grid items using gridRow and gridColumn props. Demonstrates spanning items across multiple grid tracks to create complex layouts. Includes responsive sizing with width and height properties
--------------------------------
### Menu with Sections in React JSX
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/menu.mdx
This snippet uses MenuSection to organize items under titled headers. Requires Menu, MenuSection, and MenuItem components. Purpose is to categorize options; inputs include title props for sections. Outputs structured menu with headings; no nested sections supported in this example.
```jsx
```
--------------------------------
### Box Component - Universal Container
Source: https://context7.com/umami-software/react-zen/llms.txt
Foundation Box component accepting comprehensive design props for layout, spacing, colors, borders, and positioning. Demonstrates responsive design with breakpoint objects and composition pattern using asChild prop.
```tsx
import { Box, Text } from '@umami/react-zen';
function DesignPropsExample() {
return (
All styling via props - no CSS needed
);
}
```
```tsx
// Responsive design with breakpoint objects
function ResponsiveBox() {
return (
Adapts to screen size: xs(576), sm(768), md(992), lg(1200), xl(1200+)
);
}
```
```tsx
// Composition pattern with asChild
function BoxAsButton() {
return (
);
}
```
--------------------------------
### Basic Loading Button Usage in React
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/loading-button.mdx
Demonstrates the fundamental usage of the LoadingButton component in React, showing how to enable the loading indicator. This component is useful for providing visual feedback during asynchronous operations.
```jsx
```
--------------------------------
### Import React Zen CSS styles in JavaScript
Source: https://github.com/umami-software/react-zen/blob/master/README.md
Imports the global stylesheet for React Zen components to apply the library's pure CSS styling. Place this import at the root of your application before using any Zen components. No additional configuration required.
```javascript
import '@umami/react-zen/styles.css';
```
--------------------------------
### React Button Basic Usage
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/button.mdx
Demonstrates the fundamental usage of the Button component in React. This component allows users to perform actions via mouse, touch, or keyboard. It requires no external dependencies beyond React itself.
```jsx
```
--------------------------------
### Render basic table
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/table.mdx
Displays a simple table with headers and rows. No dependencies required. Takes no input parameters beyond the static data shown. Does not support interactivity beyond navigation.
```jsx
```
--------------------------------
### Basic Menu Usage in React JSX
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/components/menu.mdx
This snippet demonstrates a simple menu with a list of MenuItem components. It requires the Menu and MenuItem components from React Zen. No selection mode is specified, defaulting to non-selectable items. Outputs a vertical list of clickable options.
```jsx
```
--------------------------------
### React Heading Component Alignment Examples
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/typography/heading.mdx
Shows how to align text within the Heading component using the 'align' prop. Accepted values are 'left', 'center', and 'right'. This functionality likely relies on CSS text-align properties applied internally by the component. It's demonstrated within a Box component, suggesting layout utilities might be used in conjunction.
```jsx
LeftCenterRight
```
--------------------------------
### Render basic Box component with JSX
Source: https://github.com/umami-software/react-zen/blob/master/src/content/docs/layout/box.mdx
Demonstrates rendering a simple Box component containing text. No additional props are required, only the child content is provided. Suitable for quick layout elements.
```jsx
I am a box.
```