Lightning-Aura-Components – Difference Between force:inputField and lightning:inputField

In a Lightning Components Developer Guide there are two inputFields – [one] in a force namespace and a [second] in a lightning namespace. Looks like both of them serve the same purpose (being an input field) but their functionality just differs a bit.

I can undestand a reason why there are two types of input fields for both the Lightning Components and Visualforce Pages since they are parts of kinda different frameworks, but can someone explain me why it couldn't be one inputField for a Lightning and they decided to split it on two and put into different namespaces?

Best Answer

tl;dr use lightning:inputField and always choose the lightning namespace components when possible.

The lightning namespace components are the next generation of components for Lightning. These components:

  • Use Salesforce Lightning Design System (SLDS) so will always track the latest look and feel from Salesforce including theming/branding/etc customizations of the org.
  • Use Lightning Data Service (LDS) so will run faster and always be in sync with other LDS-based components.
  • Are optimized for runtime performance.
  • Have improved accessibility built in.

You'll find more capabilities coming to the lightning namespace components with each release.

There are some backwards-compatibility challenges with converging the components from force and lightning. For reasons like this you'll see the force components will continue to exist.

You should also check out the new Lightning Component library at https://developer.salesforce.com/docs/component-library. I find it much easier to use than the other doc site you linked.