Fields
Boolean Field
Switch/checkbox input for true/false values
The Boolean Field component provides a switch or checkbox input for collecting true/false boolean values.
Basic Usage
Basic Switch
{
"type": "boolean",
"name": "is_active",
"label": "Active"
}With Description
With Description
{
"type": "boolean",
"name": "notifications",
"label": "Email Notifications",
"description": "Receive email updates about your account"
}Default Value
Pre-checked
{
"type": "boolean",
"name": "terms",
"label": "I agree to the terms and conditions",
"value": true
}Field Schema
interface BooleanFieldSchema {
type: 'boolean';
name: string; // Field name/ID
label?: string; // Field label
description?: string; // Helper text
value?: boolean; // Default value
required?: boolean; // Is field required
readonly?: boolean; // Read-only mode
disabled?: boolean; // Disabled state
className?: string; // Additional CSS classes
}Use Cases
- Feature Toggles: Enable/disable features
- Preferences: User settings and preferences
- Permissions: Access control flags
- Status: Active/inactive, published/draft states
- Agreements: Terms acceptance, consent flags
Cell Renderer
In tables/grids, boolean values are displayed as badges:
import { BooleanCellRenderer } from '@object-ui/fields';
// Renders:
// ✓ True (green badge)
// ✗ False (gray badge)Styling
The boolean field uses the Switch component from Shadcn UI, providing:
- Smooth animations
- Accessible keyboard navigation
- Focus states
- Disabled states