Function toggleField

  • Creates a toggle field component for boolean input. Supports both static and dynamic (async) props that can be computed based on the current state.

    Parameters

    • props: UiToggleFieldProps

      Configuration object

    Returns Element

    A JSX element representing the toggle field component

    Basic usage with required props

    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',
    });

    Usage with conditional visibility

    toggleField({
    name: 'darkMode',
    label: 'Dark Mode',
    hidden: (state) => !state.supportsDarkMode,
    });