add without-arrow to hide arrows without artifacts (#1253)

This commit is contained in:
Cory LaViska
2025-07-30 14:08:26 -04:00
committed by GitHub
parent 6c8bbd51d1
commit b7a6ebd228
5 changed files with 14 additions and 7 deletions

View File

@@ -91,7 +91,7 @@ Use the `distance` attribute to control how far the popover appears from its anc
### Arrow Size
Use the `--arrow-size` custom property to change the size of the popover's arrow. Set it to `0` to remove the arrow entirely.
Use the `--arrow-size` custom property to change the size of the popover's arrow. To remove it, use the `without-arrow` attribute.
```html {.example}
<div style="display: flex; gap: 1rem; align-items: center;">
@@ -99,7 +99,7 @@ Use the `--arrow-size` custom property to change the size of the popover's arrow
<wa-popover for="popover__big-arrow" style="--arrow-size: 8px;">I have a big arrow</wa-popover>
<wa-button id="popover__no-arrow">No arrow</wa-button>
<wa-popover for="popover__no-arrow" style="--arrow-size: 0;">I don't have an arrow</wa-popover>
<wa-popover for="popover__no-arrow" without-arrow>I don't have an arrow</wa-popover>
</div>
```

View File

@@ -113,11 +113,11 @@ Tooltips can be controller programmatically by setting the `trigger` attribute t
### Removing Arrows
You can control the size of tooltip arrows by overriding the `--wa-tooltip-arrow-size` design token. To remove them, set the value to `0` as shown below.
You can control the size of tooltip arrows by overriding the `--wa-tooltip-arrow-size` design token. To remove the arrow, use the `without-arrow` attribute.
```html {.example}
<wa-button id="no-arrow">No Arrow</wa-button>
<wa-tooltip for="no-arrow" style="--wa-tooltip-arrow-size: 0;">This is a tooltip with no arrow</wa-tooltip>
<wa-tooltip for="no-arrow" without-arrow>This is a tooltip with no arrow</wa-tooltip>
```
To override it globally, set it in a root block in your stylesheet after the Web Awesome stylesheet is loaded.

View File

@@ -13,8 +13,9 @@ Components with the <wa-badge variant="warning">Experimental</wa-badge> badge sh
### New Features {data-no-outline}
- Added the `icon-position` attribute to `<wa-details>` [discuss:1099]
- Added the `animating` custom state to `<wa-details>`
- Added the `animating` custom state to `<wa-details>` [pr:1214]
- Added `--wa-tooltip-border-color`, `--wa-tooltip-border-style`, and `--wa-tooltip-border-width` tokens [issue:1224]
- Added the `without-arrow` attribute to `<wa-popover>` and `<wa-tooltip>` to hide arrows without artifacts
### Bug Fixes and Improvements {data-no-outline}

View File

@@ -85,6 +85,9 @@ export default class WaPopover extends WebAwesomeElement {
/** The ID of the popover's anchor element. This must be an interactive/focusable element such as a button. */
@property() for: string | null = null;
/** Removes the arrow from the popover. */
@property({ attribute: 'without-arrow', type: Boolean, reflect: true }) withoutArrow = false;
private eventController = new AbortController();
connectedCallback() {
@@ -300,7 +303,7 @@ export default class WaPopover extends WebAwesomeElement {
skidding=${this.skidding}
flip
shift
arrow
?arrow=${!this.withoutArrow}
.anchor=${this.anchor}
>
<div part="body" class="body" @click=${this.handleBodyClick}>

View File

@@ -89,6 +89,9 @@ export default class WaTooltip extends WebAwesomeElement {
*/
@property() trigger = 'hover focus';
/** Removes the arrow from the tooltip. */
@property({ attribute: 'without-arrow', type: Boolean, reflect: true }) withoutArrow = false;
@property() for: string | null = null;
@state() anchor: null | Element = null;
@@ -332,7 +335,7 @@ export default class WaTooltip extends WebAwesomeElement {
skidding=${this.skidding}
flip
shift
arrow
?arrow=${!this.withoutArrow}
hover-bridge
.anchor=${this.anchor}
>