It appears that I can't put a lightning-input in a slot. I would like the input and button to line up side by side on the right, preferably in line with the lightning-card title. Any ideas on how to accomplish this?
HTML:
<lightning-card class="slds-size_12-of-12" title="Requests" icon-name="standard:lead_list" variant="narrow">
<div class="slds-grid slds-wrap" slot="actions">
<div class="slds-m-top_small slds-m-bottom_medium">
<lightning-input
class="slds-m-top_none slds-m-bottom_small slds-m-right_xx-large"
onchange={searchRR}
name="enter-search"
label=""
type="search"
placeholder="Search this list..."
slot="actions">
</lightning-input>
</div>
<template if:false={isPortalUser}>
<div class="slds-float_right">
<lightning-button
variant="neutral"
label="New"
title="New"
onclick={handleClick}
class="slds-m-left_x-small"
slot="actions">
</lightning-button>
</div>
</template>
</div>
. . .
Best Answer
Input fields, by default, have a label. Use the
variant="label-hidden"
to remove this extra space. Also, usingslot
on each element moves them all up to the "top" which results in the weird appearance. Remove the slot attributes on all except the topdiv
.Edit: Demo.