mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
feat(button): infer hasIconOnly using $$slots API
- requires Svelte version >=3.25
This commit is contained in:
parent
ff5921d31c
commit
74d48e78cd
2 changed files with 2 additions and 5 deletions
|
@ -1,7 +1,3 @@
|
|||
---
|
||||
description: High-level description
|
||||
---
|
||||
|
||||
<script>
|
||||
import { Button } from "carbon-components-svelte";
|
||||
import Add16 from "carbon-icons-svelte/lib/Add16";
|
||||
|
@ -48,7 +44,7 @@ Set `hasIconOnly` to `true` to use the icon-only button variant.
|
|||
|
||||
The tooltip position and alignment can be controlled by the `tooltipPosition`, `tooltipAlignment` props, respectively.
|
||||
|
||||
<Button hasIconOnly tooltipPosition="bottom" tooltipAlignment="center" iconDescription="Tooltip text" icon={Add16} />
|
||||
<Button tooltipPosition="bottom" tooltipAlignment="center" iconDescription="Tooltip text" icon={Add16} />
|
||||
|
||||
### Link button
|
||||
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
$: if (ctx && ref) {
|
||||
ctx.declareRef(ref);
|
||||
}
|
||||
$: hasIconOnly = icon && !$$slots.default;
|
||||
$: buttonProps = {
|
||||
role: "button",
|
||||
type: href && !disabled ? undefined : type,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue