Skip to content

Commit c93a249

Browse files
authored
Add the ability to rename the html tag (#269)
1 parent f874ea3 commit c93a249

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ class Example extends React.Component {
3131
## 👀 Properties
3232

3333
| Property | Attribute | Description | Type | Default |
34-
| -------------- | --------------- | ----------------------- | --------- | ----------- |
34+
|----------------|-----------------|-------------------------|-----------|-------------|
3535
| `width` | `width` | Loader Width | `string` | `"100%"` |
3636
| `height` | `height` | Loader Height | `string` | `"1em"` |
3737
| `background` | `background` | Loader background color | `string` | `"#eff1f6"` |
3838
| `circle` | `circle` | Make Skeleton Circle | `boolean` | `false` |
3939
| `borderRadius` | `border-radius` | Loader radius | `string` | `"4px"` |
40-
| `block` | `block` | Whether to start new | `boolean` | `true` |
40+
| `block` | `block` | Whether to start new | `boolean` | `true` |
4141
| `style` | `style` | Extra Styles | `object` | `{}` |
42+
| `as` | -- | The HTML element | `string` | `"div"` |
4243

4344
## License
4445

src/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface SkeletonLoaderProps {
1010
circle?: boolean;
1111
block?: boolean;
1212
style?: React.CSSProperties;
13+
as?: keyof JSX.IntrinsicElements
1314
}
1415

1516
function SkeletonLoader({
@@ -20,9 +21,10 @@ function SkeletonLoader({
2021
circle = false,
2122
block = true,
2223
style = {},
24+
as: Tag = "div",
2325
}: SkeletonLoaderProps) {
2426
return (
25-
<div
27+
<Tag
2628
className={css.skeleton}
2729
style={{
2830
width,
@@ -34,7 +36,7 @@ function SkeletonLoader({
3436
}}
3537
>
3638
&zwnj;
37-
</div>
39+
</Tag>
3840
);
3941
}
4042

0 commit comments

Comments
 (0)