ionic-team / ionic-team/ionic-framework

feat: allow custom spinners for `ion-spinner`/`ion-loading`

未关闭
#23,912 6 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看
package: core type: feature request
主要语言
TypeScript
星标
52.7k
派生
13.3k
平均合并
1 天 15 小时
30 天内合并 PR
51

描述

### Prequisites

- [X] I have read the [Contributing Guidelines](https://github.com/ionic-team/ionic-framework/blob/main/.github/CONTRIBUTING.md#creating-an-issue).
- [X] I agree to follow the [Code of Conduct](https://ionicframework.com/code-of-conduct).
- [X] I have searched for [existing issues](https://github.com/ionic-team/ionic-framework/issues) that already include this feature request, without success.

### Describe the Feature Request

Allow an HTML element (such as one created with `createElement()`) to be given to the `ion-spinner`. This functionality should be able to come through to `ion-loading`, as it uses an `ion-spinner` under the hood.

### Describe the Use Case

Sometimes I want a spinner that "just works", but want it to be slightly more "on brand" than a stock style.
I created a Vue component that holds an animated SVG (for easy reuse), but have no way to use it with Ionic.
Note: a Vue component gets compiled to standard HTML elements, so the root element of the Vue component can be passed to the `ion-spinner`.

Maybe using a custom spinner design violates someone's interface design guidelines/rules? (looking at you Apple)

### Describe Preferred Solution

Allow an element to be given when creating a spinner using the spinner controller.

Not sure which way would be best.
Maybe change the `spinner` property/param to allow `HTMLElement` as well or something?
For the element version of `ion-spinner`, it could use a named slot: `slot="spinner"`?

### Describe Alternatives

1. Use a custom spinner instead of `ion-spinner`. This can actually work in many cases, but not when I want to use `ion-loading`.
2. Set the spinner style to `none` and target the background of the spinner with CSS. e.g. `background: url(#my-spinner-svg)`
Someone on the Ionic forum mentioned doing this as a workaround. I can find it again if needed.
This unfortunately is more complex and only allows for a single SVG to be set.

### Related Code

_No response_

### Additional Information

As to implementing, I looked at Ionic's source, and I think this could get hairy. If it would be too complex, please say so and feel free to drop the request :).

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。