diff --git a/COMPONENT_INDEX.md b/COMPONENT_INDEX.md index 3bf77ceba7..7e2532ca29 100644 --- a/COMPONENT_INDEX.md +++ b/COMPONENT_INDEX.md @@ -250,6 +250,7 @@ None. | Prop name | Required | Kind | Reactive | Type | Default value | Description | | :-------- | :------- | :--------------- | :------- | ---------------------------------------------------------------------------------------------------------------------------- | ------------------ | ------------------------ | | ratio | No | let | No | "2x1" | "2x3" | "16x9" | "4x3" | "1x1" | "3x4" | "3x2" | "9x16" | "1x2" | "2x1" | Specify the aspect ratio | +| tag | No | let | No | keyof HTMLElementTagNameMap | "div" | Specify the tag name | ### Slots diff --git a/docs/src/COMPONENT_API.json b/docs/src/COMPONENT_API.json index 38a34b0716..e240b211d9 100644 --- a/docs/src/COMPONENT_API.json +++ b/docs/src/COMPONENT_API.json @@ -217,13 +217,25 @@ "isRequired": false, "constant": false, "reactive": false + }, + { + "name": "tag", + "kind": "let", + "description": "Specify the tag name", + "type": "keyof HTMLElementTagNameMap", + "value": "\"div\"", + "isFunction": false, + "isFunctionDeclaration": false, + "isRequired": false, + "constant": false, + "reactive": false } ], "moduleExports": [], "slots": [{ "name": "__default__", "default": true, "slot_props": "{}" }], "events": [], "typedefs": [], - "rest_props": { "type": "Element", "name": "div" } + "rest_props": { "type": "Element", "name": "svelte:element" } }, { "moduleName": "Breadcrumb", diff --git a/docs/src/pages/components/AspectRatio.svx b/docs/src/pages/components/AspectRatio.svx index 6de7aafac6..77c3f99928 100644 --- a/docs/src/pages/components/AspectRatio.svx +++ b/docs/src/pages/components/AspectRatio.svx @@ -7,7 +7,9 @@ The `AspectRatio` component is useful for constraining fluid content within an a Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`. -## Default (2x1) +## Ratio 2x1 + +The default aspect ratio is `2x1`. 2x1 @@ -61,8 +63,19 @@ Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `" 1x2 +## Custom tag + +By default, the `AspectRatio` component renders a `div` element. You can change this by specifying a `tag`. + + + Content + + ## Tile (16x9) - Content - \ No newline at end of file + + Content + + + diff --git a/src/AspectRatio/AspectRatio.svelte b/src/AspectRatio/AspectRatio.svelte index e48418beee..ebf9974b5e 100644 --- a/src/AspectRatio/AspectRatio.svelte +++ b/src/AspectRatio/AspectRatio.svelte @@ -1,12 +1,21 @@ -
-
+ diff --git a/types/AspectRatio/AspectRatio.svelte.d.ts b/types/AspectRatio/AspectRatio.svelte.d.ts index 36ded80484..63a1abf08c 100644 --- a/types/AspectRatio/AspectRatio.svelte.d.ts +++ b/types/AspectRatio/AspectRatio.svelte.d.ts @@ -1,7 +1,7 @@ import type { SvelteComponentTyped } from "svelte"; import type { SvelteHTMLElements } from "svelte/elements"; -type RestProps = SvelteHTMLElements["div"]; +type RestProps = SvelteHTMLElements["svelte:element"]; export interface AspectRatioProps extends RestProps { /** @@ -19,6 +19,12 @@ export interface AspectRatioProps extends RestProps { | "9x16" | "1x2"; + /** + * Specify the tag name + * @default "div" + */ + tag?: keyof HTMLElementTagNameMap; + [key: `data-${string}`]: any; }