Use margin for <wa-icon> spacing in native buttons (#1197)

This commit is contained in:
Lindsay M
2025-07-18 09:47:24 -04:00
committed by GitHub
parent f19848c11e
commit 11519625ed
2 changed files with 23 additions and 1 deletions

View File

@@ -380,6 +380,19 @@ Add the `wa-pill` class to give buttons rounded edges.
<button class="wa-pill">Pill button</button>
```
When using `<wa-icon>` within a button, wrap adjacent label text in `<span>` or similar to automatically add margin between the icon and the label, just like the `start` and `end` slots of `<wa-button>`.
```html {.example}
<button>
<wa-icon name="plane-departure"></wa-icon>
<span>Start Icon</span>
</button>
<button>
<span>End Icon</span>
<wa-icon name="plane-arrival"></wa-icon>
</button>
```
### Form controls
Create a variety of form controls with `<input type="">`, `<select>`, and `<textarea>`. Each control closely matches the appearance of the corresponding Web Awesome component.

View File

@@ -564,7 +564,6 @@
display: inline-flex;
align-items: center;
justify-content: center;
gap: 0.5em;
height: var(--wa-form-control-height);
padding: 0 var(--wa-form-control-padding-inline);
@@ -709,6 +708,16 @@
&.wa-pill {
border-radius: var(--wa-border-radius-pill);
}
/* Adds space between icons and adjacent elements
* Prefer sibling selectors over :first-child/:last-child to avoid extra space when an icon is used alone */
& > wa-icon:has(+ *) {
margin-inline-end: 0.75em;
}
& > * + wa-icon {
margin-inline-start: 0.75em;
}
}
/* #endregion */