Labs ICT
Pro Login

Fragment Parameters

Passing data to fragments.

Passing Parameters to Fragments

Fragment parameters make your fragments dynamic and reusable. You pass values when you include the fragment, and they get used inside it.


Hello, Guest!

The parameter 'Alice' gets passed to the fragment and displayed in the greeting.

Parameter Defaults

You can set default values for parameters using the ~{default value} syntax. This makes parameters optional.


Alert

Details

If you don't pass details, it uses "No additional details" by default.

Try it Yourself →

Multiple Parameters

Fragments can accept multiple parameters. Just separate them with commas.


User

Email

Role

Now you can create different user cards by passing different combinations of parameters.

Parameter Expressions

You can pass expressions as parameters, not just literal strings.


This lets you compute values before passing them to the fragment.

Fragment with No Parameters

Fragments don't need parameters. Sometimes you just want to reuse static content.


© 2026 My Company. All rights reserved.

Version 2.0

Even without parameters, fragments are useful for keeping your HTML DRY (Don't Repeat Yourself).

Try it Yourself →

Mixed Parameters and Defaults

You can mix required parameters with optional ones that have defaults.


Now you can call button('Click Me') for a default primary medium button, or button('Delete', 'danger', 'large') for a custom one.

Using Parameters in Logic

You can use fragment parameters in conditional expressions and loops.


status

The parameter drives the logic inside the fragment, making it truly dynamic.