Skip to content

Instantly share code, notes, and snippets.

@EduardoAC
Last active March 29, 2025 15:38
Show Gist options
  • Save EduardoAC/d78ccf9f7f05e77d5ae1083857a6e25b to your computer and use it in GitHub Desktop.
Save EduardoAC/d78ccf9f7f05e77d5ae1083857a6e25b to your computer and use it in GitHub Desktop.
Using a Slot - We use a slot inside the RadioButtonGroup, allowing the parent component to control how label is rendered.
<template>
<div class="radio-button-group">
<div
v-for="option in optionList"
:key="option.value"
:disabled="option.disabled"
:class="{ 'option--active': selected === type.value }"
>
<div v-if="type.icon" :class="type.icon" />
<slot :labelText="option.label">
{{option.label}}
</slot>
// ...
</div>
</div>
</template>
<template>
<RadioButtonGroup :optionList="suggestDepositAmounts">
<template #default="{ labelText }">
<CustomElement :labelText="labelText" />
</template>
</RadioButtonGroup>
</template>
<script>
const suggestDepositAmounts = [
{
value: "100",
label: "100 RSD",
}
];
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment