In my view (from the US) and experience, tenure is pretty absolute in the absence of severe breaches of conduct. But changing research fields isn't a breach.
However, while a department in which you earn tenure will almost certainly honor it if you change research fields, the extra "perks" that come with the professorate may be denied you. Perhaps you don't get raises. Perhaps you don't get promoted. Perhaps you have to teach the courses no one else wants. Lots of things.
If you just quit working altogether in the department you can probably be fired - a breach. But if you teach the required load and provide some other services, your job is probably (minimally) safe. Some people, nearing retirement, give up serious research altogether. No one worries a lot about it, provided that there is sufficient activity by other people. And such a professor might be made an offer to give up tenure to make room for a younger professor. A year's salary might be offered as a sort of un-signing bonus to give up tenure. This also happens when too many professors hold positions that might be better offered to more productive people.
And in those fields in which external grant funding is a must and the teaching means advising doctoral students, you can't give that up and expect to keep the job. But some minimal compliance may be enough.
I have a case in mind. A colleague was tenured in CS - an associate professor. But his research was both poor and closely related to another field in which he had no academic credentials. He wanted to be promoted to Full Professor, but never was. I advised him for a while (a formal mentorship) and told him what he needed to do. He said that he understood all that and appreciated my advice, but chose not to do any of it. He served till retirement as an Associate Professor and sort of the goat of the department. He was unhappy about not getting advanced, but sufficiently happy with the situation to continue on.
Some people changing fields can switch to a different department. Whether they keep their tenure or not would be questionable, since it is really a new position, even in the same university. But it is something that might be negotiated (in some places, anyway). But it would require getting some credential to do that.
However, keep in mind that new fields arise from old ones pretty regularly. CS, for example, emerged, in part at least, from mathematics departments. So, the pioneers in CS were often trained in mathematics or engineering, say. They kept their tenure and they got credit for founding a new field.
And, there are situations in which a change of fields can lead to a certain synergy, fusing the ideas of both fields and creating something new. I don't think such situations are especially rare, but not all cases will fit this pattern.
Don't assume all will be well if you want to change fields. But don't assume that it will be catastrophic. As with many things in academia, it is up to the individual to make the case for their own productivity.