How to repeat the same input UI element twice? (Two UI elements for one `input$` variable)

For example, if I wanted to have

selectInput("carDropdown", "Variable:",
                c("Cylinders" = "cyl",
                  "Transmission" = "am",
                  "Gears" = "gear"))

But I want that dropdown to appear in two separate places in the app (and when the user changes one, the other will automatically update since they are representing the same input$carDropdown variable).

I want to do this because I need to repeat a dropdown across two tabs, but it is a very complicated selectizeInput using reactive elements and I do not want to repeat all the code twice.

Do you know about Shiny modules? It's a piece of functionality that contains a UI and a server part that can be re-used. Every time you add a module to your app, it needs to have an unique ID, since you can't have 2 elements in your app with the same ID.
So you would need some additional code to keep the two instances in sync.

Try to create two separate UIs with different ids and then use updateSelectInput in the server with an observer that updates the other UI. So you have two observeEvents(input$ui1) and observeEvents(input$ui2) and then you update UI2 and ui1 in each observer