# Hide inputs for a component dynamically

**URL:** <https://forum.builder.io/t/hide-inputs-for-a-component-dynamically/595>\
**Category:** Technical Questions\
**Tags:** react\
**Created:** [April 26, 2021, 3:15am UTC](https://forum.builder.io/t/hide-inputs-for-a-component-dynamically/595 "2021-04-26T03:15:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mossen](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@mossen](https://forum.builder.io/u/mossen)\
**Post date:** [April 26, 2021, 3:15am UTC](https://forum.builder.io/t/hide-inputs-for-a-component-dynamically/595/1 "2021-04-26T03:15:09Z")

</div>

I have a parent component which has default children as following:

```
defaultChildren: [
    {
      '@type': '@builder.io/sdk:Element',
      responsiveStyles: {
        large: {
          marginTop: '10px',
          marginBottom: '10px'
        }
      },
      component: {
        name: 'Text Input',
        options: {
          hideFromInputsUI: true, // passing an option to hide inputs for this component
          type: 'search',
          id: 'address_line_1',
          placeholder: 'Search address here...'
        }
      }
    },
]

```

The child component has some input which should be visible in the UI by default, is there any way to make `hideFromUI` dynamic for an input?

```
Builder.registerComponent(TextInput, {
  name: 'Text Input',
  image: input,
  inputs: [
    {
      name: 'name',
      type: 'text',
      required: true,
      hideFromUI: options => options.hideFromUI // something like this, or get the parent options here?
    },
]
})
```

---

<div class="post-metadata">

**Author:** ![korey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/korey/32/12_2.png) [@korey](https://forum.builder.io/u/korey)\
**Post date:** [April 26, 2021, 4:52pm UTC](https://forum.builder.io/t/hide-inputs-for-a-component-dynamically/595/2 "2021-04-26T16:52:37Z")

</div>

Hi @mossen ,

You can use `showIf` on the input to dynamically show and hide it. Here is a link to the [type definition](https://github.com/BuilderIO/builder/blob/2e1be3a1f659b50b3d1bd9473e154e6245935276/packages/core/src/builder.class.ts#L448) and here is a link to an [example of how it is used](https://github.com/BuilderIO/builder/blob/791999cdbadd038c791cad1635b9d0176f2bc71b/packages/widgets/src/components/Masonry.config.ts#L93).

The `options` object that is passed to the `showIf` function is a map of the current options set on the component. Hopefully you are able to accomplish what you need with that. If that does not work and you need access to the parent of the current component, the update we have planned to fix this issue for you: [Get parent block in Builder.registerComponent - #6 by korey](https://forum.builder.io/t/get-parent-block-in-builder-registercomponent/570/6) will also fix this!

---

<div class="post-metadata">

**Author:** ![mossen](https://avatars.discourse-cdn.com/v4/letter/m/76d3ee/32.png) [@mossen](https://forum.builder.io/u/mossen)\
**Post date:** [April 26, 2021, 11:49pm UTC](https://forum.builder.io/t/hide-inputs-for-a-component-dynamically/595/3 "2021-04-26T23:49:15Z")

</div>

Thanks @korey that helped, however I’d like to know when showIf has more flexibility why there is something as hideFromUi?

---

<div class="post-metadata">

**Author:** ![korey](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/korey/32/12_2.png) [@korey](https://forum.builder.io/u/korey)\
**Post date:** [April 27, 2021, 5:58pm UTC](https://forum.builder.io/t/hide-inputs-for-a-component-dynamically/595/4 "2021-04-27T17:58:42Z")

</div>

`hideFromUI` and `showIf` provide similar functionality, so you can essentially use either one interchangeably. If you **never** want a field to be shown (i.e. you are using the field to add data to the component from your codebase and do not want someone to be able to edit it in the Builder editor), `hideFromUI` is simpler to use. `showIf` is more helpful if you want to dynamically hide or show an input to a user depending on other settings.

---

<div class="post-metadata">

**Author:** ![LucasMatuszewski](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.builder.io/lucasmatuszewski/32/2130_2.png) [@LucasMatuszewski](https://forum.builder.io/u/LucasMatuszewski)\
**Post date:** [December 23, 2021, 12:56am UTC](https://forum.builder.io/t/hide-inputs-for-a-component-dynamically/595/5 "2021-12-23T00:56:53Z")

</div>

Important note:  
`showIf` won’t work inside List’s `subFields` array. But we got this “hack” to make it work (TS type doesn’t support strings for that fields, so we have to ignore ts…)

```auto
//@ts-ignore example provided by Builder to convert value to string in subfields
showIf: `options.get('someField') === 'someValue'`,

```
