In this post I am going to explain how to add dependant field in admin system configuration in magento 2.

In order to create a field dependant on single value, use the below code:

<depends>
	<field id="parent_field_id">1</field>
</depends>

And to create a field dependant on two or more values, use the below code:

<depends>
	<field id="parent_field_id">1,2,3</field>
</depends>

Here is the example in which, if parent field’s (Enabled) value “1” then “Title” field will appear.

<field id="enabled" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1">
	<label>Enabled</label>
	<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
<field id="title" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
	<label>Title</label>
	<depends>
		<field id="enabled">1</field>
	</depends>
</field>

Thats it. Enjoy Magento 2!!