Add content slot to tooltip (#322)

This commit is contained in:
Denis Korablev
2021-02-08 19:37:50 +04:00
committed by GitHub
parent f73f152031
commit 4e5b0e06dc
2 changed files with 12 additions and 1 deletions

View File

@@ -163,5 +163,15 @@ To override it globally, set it in a root block in your stylesheet after `shoela
}
```
### Custom content
Use the `content` slot to pass an element to the tooltip.
```html preview
<sl-tooltip>
<sl-button>Hover me</sl-button>
<strong slot="content">Bolded content</strong>
</sl-tooltip>
```
[component-metadata:sl-tooltip]

View File

@@ -8,6 +8,7 @@ let id = 0;
* @status stable
*
* @slot - The tooltip's target element. Only the first element will be used as the target.
* @slot content - The tooltip's content. Alternatively, you can use the content prop.
*
* @part base - The component's base wrapper.
*/
@@ -253,7 +254,7 @@ export class Tooltip {
role="tooltip"
aria-hidden={this.open ? 'false' : 'true'}
>
{this.content}
<slot name="content">{this.content}</slot>
</div>
</div>
)}