Skip to content
Back to search

Xamarin.Forms.Skeleton

The new loading approach for cool apps in Xamarin Forms

Safety scan

A static text scan, not a guarantee. Select the badge to see what was scanned and every finding.

Checked today
Badge for your README
findsafeskills safety rating

Markdown

[![findsafeskills safety rating](/api/listings/horussoftwareuy--xamarin-forms-skeleton/badge.svg)](/listings/horussoftwareuy--xamarin-forms-skeleton)

HTML

<a href="/listings/horussoftwareuy--xamarin-forms-skeleton"><img src="/api/listings/horussoftwareuy--xamarin-forms-skeleton/badge.svg" alt="findsafeskills safety rating" /></a>

Install

i

What was scanned

The files the safety scan read, as written by the repository's author and shown as plain text. Lines with a finding are marked.

README.md · README · 271 lines

View this file on GitHub (read at the repository's current version: the scan did not record which commit it read)

  1. # Skeleton for Xamarin and MAUI apps
  2. <img src="https://raw.githubusercontent.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/master/icon.png" width="128">
  3. The Skeleton control is a popular approach to loading content in mobile apps that provides one or more visual placeholders while content is being loaded. This technique is particularly useful for improving user experience, as it reduces perceived load times and provides a more engaging experience.
  4. #
  5. [![Playground Try it live](https://img.shields.io/badge/Playground-Try%20it%20live-red)](https://horus.com.uy/skeleton)
  6. [![AI Skill skill.md](https://img.shields.io/badge/AI%20Skill-skill.md-red)](https://skills.horus.com.uy/skeleton)
  7. ## Playground | Find the animation that fits your app
  8. Six layouts, seven animations and every property we expose. Switch between them and keep the one that belongs in your .NET MAUI project. After installing the NuGet package, you can use your own colors and apply the animations to any layout.
  9. **[horus.com.uy/skeleton](https://horus.com.uy/skeleton)**
  10. <img src="https://raw.githubusercontent.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/master/screenshots/Skeleton.gif" width="800">
  11. ## Setup
  12. ### .NET MAUI
  13. * Available on NuGet: [HorusStudio.Maui.Skeleton](https://www.nuget.org/packages/HorusStudio.Maui.Skeleton/) [![NuGet v3.0.0](https://img.shields.io/badge/NuGet-v3.0.0-red)](https://www.nuget.org/packages/HorusStudio.Maui.Skeleton/)
  14. |Platform|Version|
  15. | ------------------- | :------------------: |
  16. |.NET|8, 9 and 10|
  17. |Android, iOS, macOS, Windows|all versions supported by .NET MAUI|
  18. Version 3.0.0 and later require .NET 8 or newer. Apps on .NET 6 or 7 should stay on 2.0.0, which keeps working.
  19. ### Xamarin.Forms (legacy)
  20. * Available on NuGet: [Xamarin.Forms.Skeleton](https://www.nuget.org/packages/Xamarin.Forms.Skeleton/) [![NuGet](https://img.shields.io/nuget/v/Xamarin.Forms.Skeleton.svg?label=NuGet)](https://www.nuget.org/packages/Xamarin.Forms.Skeleton/)
  21. **Xamarin.Forms reached end of support in May 2024.** This package is frozen at 2.0.0 and will not
  22. receive further updates. New work happens on the .NET MAUI package above.
  23. |Platform|Version|
  24. | ------------------- | :------------------: |
  25. |Xamarin.iOS|iOS 8+|
  26. |Xamarin.Android|API 16+|
  27. |Xamarin.Forms|>= 4.0.0.425677|
  28. ## Agent skill
  29. Rather than learning the API, you can have a coding agent apply it for you. The skill and the two
  30. ways to use it are in
  31. [skills/](https://github.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/tree/master/skills).
  32. ## Usage
  33. You must add this namespace to your xaml files.
  34. For .NET MAUI:
  35. ```XML
  36. xmlns:sk="clr-namespace:Maui.Skeleton;assembly=Maui.Skeleton"
  37. ```
  38. For Xamarin.Forms:
  39. ```XML
  40. xmlns:sk="clr-namespace:Xamarin.Forms.Skeleton;assembly=Xamarin.Forms.Skeleton"
  41. ```
  42. Add the following properties to generate a loading animation:
  43. ```XML
  44. <ListView RowHeight="90"
  45. SeparatorVisibility="None"
  46. SelectionMode="None"
  47. VerticalOptions="FillAndExpand"
  48. BackgroundColor="Transparent"
  49. ItemTemplate="{StaticResource ItemTemplate}"
  50. ItemsSource="{Binding Items}"
  51. sk:Skeleton.IsParent="True"
  52. sk:Skeleton.IsBusy="{Binding IsBusy}"
  53. sk:Skeleton.Animation="{sk:DefaultAnimation Fade}" />
  54. ```
  55. Add the following properties to set a loading animation with a specific background color:
  56. ```XML
  57. <Frame BackgroundColor="Transparent"
  58. HasShadow="False"
  59. CornerRadius="5"
  60. Padding="0"
  61. HorizontalOptions="Start"
  62. sk:Skeleton.IsBusy="{Binding IsBusy}"
  63. sk:Skeleton.BackgroundColor="#c6c6c5">
  64. <Label Text="{Binding Title}"
  65. TextColor="#000000"
  66. FontSize="20"
  67. FontAttributes="Bold"
  68. HorizontalOptions="Start"/>
  69. </Frame>
  70. ```
  71. ### Properties
  72. #### IsBusy (Boolean)
  73. - Indicates if the control is busy in a loading state.
  74. - The default value is false.
  75. **`IsBusy` is not inherited.** Every element that should react needs its own
  76. `sk:Skeleton.IsBusy="{Binding ...}"`. Setting it once on an outer layout does nothing for the
  77. elements inside it.
  78. #### IsParent (Boolean)
  79. - Controls whether a container covers its own content or lets each child draw itself.
  80. - The default value is false.
  81. **The name reads backwards from what it does.** `IsParent="True"` does not mean "handle my
  82. children" — it means **"leave my children alone, they handle themselves"**.
  83. | | What happens |
  84. | --- | --- |
  85. | `IsParent="False"` (default) | The container hides its content and paints its own `BackgroundColor`. You get **one solid shape**. |
  86. | `IsParent="True"` | The content is left untouched. **Every child that should show a placeholder needs its own `IsBusy`.** |
  87. Either way the container still paints its own colour and runs its own animation. `IsParent` only
  88. governs whether it touches what is inside.
  89. **One solid shape** — no `IsParent`, and the container needs a colour:
  90. ```XML
  91. <Border sk:Skeleton.IsBusy="{Binding IsBusy}"
  92. sk:Skeleton.BackgroundColor="#c6c6c5">
  93. <Label Text="{Binding Title}" />
  94. </Border>
  95. ```
  96. **Several shapes** — `IsParent="True"`, and each child declares itself:
  97. ```XML
  98. <VerticalStackLayout sk:Skeleton.IsParent="True"
  99. sk:Skeleton.IsBusy="{Binding IsBusy}">
  100. <Border sk:Skeleton.IsBusy="{Binding IsBusy}"
  101. sk:Skeleton.BackgroundColor="#c6c6c5">
  102. <Label Text="{Binding Title}" />
  103. </Border>
  104. <Border sk:Skeleton.IsBusy="{Binding IsBusy}"
  105. sk:Skeleton.BackgroundColor="#c6c6c5">
  106. <Label Text="{Binding Subtitle}" />
  107. </Border>
  108. </VerticalStackLayout>
  109. ```
  110. **What changed in 3.0.0.** Until 2.0.0 only a `Layout`, such as `Grid` or `StackLayout`, hid its
  111. content. A view holding a single piece of content painted the placeholder and left its content
  112. showing on top of it, which is why samples and apps used `Skeleton.Hide="True"` on each child to get
  113. out of the way. Those views now behave like every other container, so that workaround is no longer
  114. needed. It still works, it is just redundant.
  115. The test is two conditions: a `View` implementing `IContentView`, whose presented content is a
  116. `View`. `Border`, `Frame`, `ContentView`, `ScrollView`, `RefreshView` and `SwipeView` are the ones
  117. that meet both. Implementing the interface is not enough on its own: a `RadioButton` does, but
  118. with its default template it presents nothing, so nothing of it fades.
  119. If content that used to stay visible now disappears, that container is the one deciding it: set
  120. `sk:Skeleton.IsParent="True"` on it to get the old behaviour back.
  121. **Three mistakes this prevents**, none of which reports an error:
  122. - `IsParent="True"` with a child that declares nothing does **nothing at all** to that child. If it
  123. holds real content, the content shows straight through the loading state. If you drew your own
  124. placeholder shape there, it stays on screen after loading finishes, on top of the real content.
  125. - No `IsParent` and no `BackgroundColor` leaves an empty hole: the content is hidden and nothing is
  126. painted in its place.
  127. - `IsBusy` on an outer layout alone renders no placeholders at all, because it is not inherited.
  128. #### BackgroundColor (Color)
  129. - Control background color when is busy.
  130. - The default value is the xamarin forms default color.
  131. #### Hide (Boolean)
  132. - Indicates if the control is hide when is busy.
  133. - The default value is false.
  134. #### Animation (BaseAnimation)
  135. - Control animation when is busy.
  136. - Possible values: None, Fade, Beat, HorizontalShake, VerticalShake, Shimmer, Aurora, Tint and custom animation inheriting from BaseAnimation.
  137. - The default value is null, which means no animation runs.
  138. ### Animation settings
  139. The interval and the parameter are **not** attached properties. They are set on the
  140. `DefaultAnimation` markup extension, alongside `Source`:
  141. ```XML
  142. sk:Skeleton.Animation="{sk:DefaultAnimation Source=Fade, Interval=600, Parameter=0.3}"
  143. ```
  144. `Source` is the extension's content property, so `{sk:DefaultAnimation Fade}` is shorthand for
  145. `{sk:DefaultAnimation Source=Fade}`.
  146. | Setting | Meaning | Default |
  147. | --- | --- | --- |
  148. | `Source` | Which built-in animation to use. `None` resolves to no animation at all. | `None` |
  149. | `Interval` | Duration in milliseconds of **each half** of a cycle, so a `Fade` at 600 takes 1.2s per pulse. | 500 |
  150. | `Parameter` | What the animation interpolates towards. See the table below. | per animation |
  151. | Source | What moves | `Parameter` means | Default |
  152. | --- | --- | --- | --- |
  153. | `Fade` | opacity | opacity to fade to | 0.6 |
  154. | `Beat` | scale | scale to grow to | 1.03 |
  155. | `VerticalShake` | position | offset in units, up and down | 15 |
  156. | `HorizontalShake` | position | offset in units, left and right | 10 |
  157. | `Shimmer` | a band of light across the placeholder | not used, see below | — |
  158. | `Aurora` | a wide field of colour drifting back and forth | not used, see below | — |
  159. | `Tint` | the whole placeholder washing to a colour and back | not used, see below | — |
  160. #### Shimmer, Aurora and Tint
  161. These repaint the placeholder rather than animating a property of the view, so they behave a little
  162. differently from the other four. `Shimmer` sends a band of light across and off the other side;
  163. `Aurora` pans a much wider field of colour back and forth, so colour is always on screen; `Tint`
  164. washes the whole placeholder to a colour and back, with nothing moving at all.
  165. - It must be attached to the element that shows the placeholder colour. It does not carry down to
  166. children the way `Fade` and `Beat` do.
  167. - **It does not work on `Frame`.** `Frame` is deprecated in MAUI and its renderer does not repaint
  168. when the background is replaced, so the band never moves. Use `Border`.
  169. - `Interval` is the whole movement, not half a cycle: one pass for `Shimmer`, out and back for
  170. `Aurora` and `Tint`. 1600 is a good value for any of them.
  171. - They ignore `Parameter`, and take `Direction` and `SweepColors` instead.
  172. ```XML
  173. <Border StrokeShape="RoundRectangle 5"
  174. StrokeThickness="0"
  175. sk:Skeleton.IsBusy="{Binding IsBusy}"
  176. sk:Skeleton.BackgroundColor="#c6c6c5"
  177. sk:Skeleton.Animation="{sk:DefaultAnimation Source=Shimmer, Interval='1600', Direction='Diagonal'}" />
  178. ```
  179. | Setting | Values | Default |
  180. | --- | --- | --- |
  181. | `Direction` | `Horizontal`, `Vertical`, `Diagonal`, `DiagonalReverse`. Not used by `Tint`. | `Horizontal` |
  182. | `SweepColors` | two or three `#AARRGGBB` colours, comma separated and quoted | follows the placeholder |
  183. Left alone, the band contrasts with the placeholder automatically: light over a dark placeholder,
  184. dark over a light one. A placeholder bound with `AppThemeBinding` therefore shimmers correctly in
  185. both themes with no extra work.
  186. ## Demo
  187. ### MAUI
  188. https://github.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/tree/master/SkeletonSample
  189. ### Xamarin.Forms:
  190. https://github.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/tree/master/SkeletonExample
  191. ## Changelog
  192. What changed in each release, including the behaviour change in 3.0.0 and how to opt out of it, is
  193. in [CHANGELOG.md](https://github.com/HorusSoftwareUY/Xamarin.Forms.Skeleton/blob/master/CHANGELOG.md).
  194. ## Developed by
  195. <a href="http://horus.com.uy" ><img src="https://cdn.prod.website-files.com/64a7016392b0b7da3a8604e3/6aa9893608391fb09df87302_horus-github.png" width="128"></a>
  196. ## Contributions
  197. Contributions are welcome! If you find a bug want a feature added please report it.
  198. If you want to contribute code please file an issue, create a branch, and file a pull request.
  199. ## License
  200. MIT License - see LICENSE.txt

Ratings and comments

Sign in to rate this skill.

Sign in

Free to use. If it’s helped, pass it on.