React Components
Val provides React components to help you render Val content in your application. These components are optimized for Val's content types and handle visual editing integration automatically.
ValRichText
The ValRichText component renders Val's rich text content with customizable styling. It converts Val's rich text structure into properly formatted HTML while maintaining visual editing capabilities.
Props
content(required) - The Val rich text content to rendertheme(optional) - CSS classes for styling rich text elements. If provided, you must style all enabled features from your schema.
Basic usage
With custom theme
The theme object uses CSS classes (like Tailwind) to style each rich text feature. TypeScript ensures you provide styling for all features enabled in your schema:
Type Safety
The theme prop is type-checked based on your rich text schema. If you enable bold and italic in your schema, the theme must include styling for both. This prevents missing styles when you extend your rich text capabilities.
ValImage
The ValImage component is a wrapper around Next.js's optimized Image component that works seamlessly with Val image content. It automatically extracts image metadata (width, height, alt text) and provides proper optimization.
Props
src(required) - The Val image object from your contentAll other Next.js Image props -
className,priority,loading, etc.
Basic usage
With Next.js Image props
You can pass all standard Next.js Image component props to customize image rendering:
Why use ValImage?
While you can use Next.js Image directly with image.url, ValImage provides several benefits:
Automatically extracts and uses image metadata (width, height, alt)
Handles visual editing attributes for click-to-edit functionality
Uses hotspot automatically
Works seamlessly with both local and remote images
ValProvider
The ValProvider component is a React context provider that enables Val functionality throughout your application. This component is typically set up once during project initialization and rarely needs to be modified.
Props
config(required) - The configuration object frominitValchildren(required) - Your application components
Setup in root layout
The ValProvider is typically added to your root layout file during initial Val setup. This was likely done automatically if you used the Val initialization script:
When do I need this?
You only need to interact with ValProvider during initial project setup. If you used npm create @valbuild or the Val initialization script, this is already configured for you. You won't need to modify it unless you're integrating Val into an existing project manually.