Is it possible to use a dictionary as a typst element's properties?

This question is so simple that I am embarrassed for not having the answer myself. I’d like to know what would be the correct way to use a dictionary in a variable as the property dictionary that typst elements usually expect. For example (assuming that we are already in code mode):

let boxprops = (
  inset: 1mm,
)

box(
  boxprops
)[
Content
]

This does not work because the box element does not have a property with name props.

So what would be the correct way?

I am not interested in solutions like the following:

let boxprops = (
  inset: 1mm,
)

box(
  inset: boxprops.inset,
)[
Content
]

The reason is that the boxprops variable -depending on the situation- can contain an arbitrary number of dictionary entries, from 0 entries up to the full set of entries that are valid for a box element.

Of course, there are complicated and ugly ways to construct a box element from a dictionary in a variable. But I’d like know if there is an easy and elegant one that I have missed.

Thank you very much in advance!

P.S. This is a general question that applies to all typst elements. The box element was just an example.

Hi! This trick is to ..spread:

let boxprops = (
  inset: 1mm,
)

box(..boxprops)[
  Content
]

An alternative solution is function.with:

let your-box = box.with(
  inset: 1mm,
)

your-box[
  Content
]

By the way, AI services like https://deepwiki.com/typst/typst and Typst (websites/typst_app) | Context7 have full access to the Typst Documentation. For simple questions like this one, you can use these services to get the answer more quickly.

Another option is to use the argument type. From what I can see the only(?) benefit compared to a dictionary is you can include positional arguments too.

From the documentation:

#let args = arguments(stroke: red, inset: 1em, [Body])
#box(..args)

@Y.D.X

I see. Thank you very much. I had totally forgotten about argument spreading. Shame on me … had used it before, but had to focus on other tasks during the last weeks.

Regarding research, I had googled for the solution before posting of course. But obviously I had used the wrong keywords.

@gezepi

Thank you very much, too. I had not come across the argument type yet. It looks promising. But I still have to check whether it works if I pass a variable which already contains a dictionary to the arguments() function. Like this: #let args = arguments(boxprops,[body]). Otherwise, I couldn’t use it in my specific case.