Skip to content

Commit

Permalink
feat(Checkbox/Radio/RadioGroup): add help slot
Browse files Browse the repository at this point in the history
Resolves nuxt#1957
  • Loading branch information
benjamincanac authored and binhth-1206 committed Jul 28, 2024
1 parent c2b7cc8 commit 733fd00
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 6 deletions.
4 changes: 4 additions & 0 deletions docs/content/2.components/checkbox.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ slots:
[Label]{.italic}
::

### `help` :u-badge{label="New" class="align-middle ml-2 !rounded-full" variant="subtle"}

Like the `#label` slot, use the `#help` slot to override the content of the help text.

## Props

:component-props
Expand Down
4 changes: 4 additions & 0 deletions docs/content/2.components/radio-group.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ slots:
[Label]{.italic}
::

### `help` :u-badge{label="New" class="align-middle ml-2 !rounded-full" variant="subtle"}

Like the `#label` slot, use the `#help` slot to override the content of the help text.

### `legend`

Use the `#legend` slot to override the content of the legend.
Expand Down
8 changes: 5 additions & 3 deletions src/runtime/components/forms/Checkbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
</div>
<div v-if="label || $slots.label" :class="ui.inner">
<label :for="inputId" :class="ui.label">
<slot name="label">{{ label }}</slot>
<slot name="label" :label="label">{{ label }}</slot>
<span v-if="required" :class="ui.required">*</span>
</label>
<p v-if="help" :class="ui.help">
{{ help }}
<p v-if="help || $slots.help" :class="ui.help">
<slot name="help" :help="help">
{{ help }}
</slot>
</p>
</div>
</div>
Expand Down
8 changes: 5 additions & 3 deletions src/runtime/components/forms/Radio.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
</div>
<div v-if="label || $slots.label" :class="ui.inner">
<label :for="inputId" :class="ui.label">
<slot name="label">{{ label }}</slot>
<slot name="label" :label="label">{{ label }}</slot>
<span v-if="required" :class="ui.required">*</span>
</label>
<p v-if="help" :class="ui.help">
{{ help }}
<p v-if="help || $slots.help" :class="ui.help">
<slot name="help" :help="help">
{{ help }}
</slot>
</p>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/runtime/components/forms/RadioGroup.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
<template #label>
<slot name="label" v-bind="{ option, selected: option.selected }" />
</template>

<template #help>
<slot name="help" v-bind="{ option, selected: option.selected }" />
</template>
</URadio>
</fieldset>
</div>
Expand Down

0 comments on commit 733fd00

Please sign in to comment.