Creates a toggle field component for boolean input. Supports both static and dynamic (async) props that can be computed based on the current state.
Configuration object
A JSX element representing the toggle field component
Basic usage with required props
toggleField({ name: 'notifications', label: 'Enable notifications',}); Copy
toggleField({ name: 'notifications', label: 'Enable notifications',});
Usage with async props
toggleField({ name: 'autoSave', label: async (state) => `Auto-save (${state.userType})`, disabled: async (state) => state.userType === 'guest',}); Copy
toggleField({ name: 'autoSave', label: async (state) => `Auto-save (${state.userType})`, disabled: async (state) => state.userType === 'guest',});
Usage with conditional visibility
toggleField({ name: 'darkMode', label: 'Dark Mode', hidden: (state) => !state.supportsDarkMode,}); Copy
toggleField({ name: 'darkMode', label: 'Dark Mode', hidden: (state) => !state.supportsDarkMode,});
Creates a toggle field component for boolean input. Supports both static and dynamic (async) props that can be computed based on the current state.