Component Wise Dirichlet BC

Hello, how do I apply a Dirichlet BC to the x and y components of displacements at a specific coordinate but leave the z-component free?

U_ele = ufl.VectorElement(“CG”, mesh.ufl_cell(), degree=deg_u)
U = fem.FunctionSpace(mesh, U_ele)

def x_y(x):
return np.logical_and(np.logical_and(np.isclose(x[0], 1.), np.isclose(x[1], 0.)), np.isclose(x[2], 0.))

Is it like this:
x_y_dof_x = fem.locate_dofs_topological(U.sub(0), mesh.topology.dim-1, x_y_facets)
x_y_dof_y = fem.locate_dofs_topological(U.sub(1), mesh.topology.dim-1, x_y_facets)

x_y_bcx = fem.dirichletbc(PETSc.ScalarType(0.), x_y_dof_x, U.sub(0))
x_y_bcy = fem.dirichletbc(PETSc.ScalarType(0.), x_y_dof_y, U.sub(1))

Because this does not work, it only constrains the X-component and not the Y-component.

You would need to add a complete minimal working example that reproduces your error for anyone to be able to help you.
See for instance:
https://jsdokken.com/dolfinx-tutorial/chapter3/component_bc.html#boundary-conditions
and

Thanks for the share Dokken. I fixed the issue with: