# DashboardWidgetShape

Small outline of a widget size, `width` columns by `height` rows, as the size buttons of the `DashboardShaper` catalog draw it: each cell is `--dashboard-widget-shape-cell-size` wide, shrunk so that the shape fits in `--dashboard-widget-shape-max-width` by `--dashboard-widget-shape-max-height`. Use it in `catalogItemSnippet` or `catalogBodySnippet` to keep the thumbnails of the default catalog. Without `title` it is decorative and hidden from screen readers. It takes the color of the text around it.

```ts
import { DashboardWidgetShape } from '@likable-hair/svelte';
```

Category: composed. Source: `src/lib/components/composed/dashboard/DashboardWidgetShape.svelte`.

## Examples

### Sizes

The outline of a widget size, as in the size buttons of the `DashboardShaper` catalog: each cell is 7px wide, shrunk so that wide or tall sizes fit in 28 × 14px. It takes the color of the text; `title` makes it an image with an accessible name.

```svelte
<script lang="ts">
	import { DashboardWidgetShape } from '@likable-hair/svelte';

	const sizes = [
		{ width: 1, height: 1 },
		{ width: 2, height: 1 },
		{ width: 2, height: 2 },
		{ width: 4, height: 2 },
		{ width: 6, height: 1 },
		{ width: 1, height: 3 }
	];
</script>

<div class="row">
	{#each sizes as size (`${size.width}x${size.height}`)}
		<span class="size">
			<DashboardWidgetShape width={size.width} height={size.height} title="{size.width} × {size.height}" />
			{size.width} × {size.height}
		</span>
	{/each}
	<span class="size accent">
		<DashboardWidgetShape width={3} height={2} --dashboard-widget-shape-cell-size="12px" --dashboard-widget-shape-max-width="48px" --dashboard-widget-shape-max-height="32px" --dashboard-widget-shape-opacity="1" />
		larger
	</span>
</div>

<style>
	.row {
		display: flex;
		flex-wrap: wrap;
		align-items: center;
		gap: 16px;
	}

	.size {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		color: var(--global-color-text-2);
		font-family: var(--global-font-family-mono);
		font-size: 12px;
	}

	.accent {
		color: var(--global-color-primary);
	}
</style>
```

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `width` (required) | `number` |  | Width in columns. |
| `height` (required) | `number` |  | Height in rows. |
| `title` | `string` |  | Accessible name. Without it the shape is decorative and hidden from screen readers. |
| `class` | `string` | `''` | Extra classes on the root element. |

## CSS variables

For a single instance, pass them as style props: `<DashboardWidgetShape --dashboard-widget-shape-color="tomato">`. The `--dashboard-widget-shape-default-*` defaults apply to the whole app: override them in `:root` or in a theme.

| Per-instance variable | Default |
| --- | --- |
| `--dashboard-widget-shape-cell-size` | `--dashboard-widget-shape-default-cell-size`: `7px` |
| `--dashboard-widget-shape-max-width` | `--dashboard-widget-shape-default-max-width`: `28px` |
| `--dashboard-widget-shape-max-height` | `--dashboard-widget-shape-default-max-height`: `14px` |
| `--dashboard-widget-shape-border-width` | `--dashboard-widget-shape-default-border-width`: `1.5px` |
| `--dashboard-widget-shape-color` | `--dashboard-widget-shape-default-color`: `currentColor` |
| `--dashboard-widget-shape-border-radius` | `--dashboard-widget-shape-default-border-radius`: `2px` |
| `--dashboard-widget-shape-opacity` | `--dashboard-widget-shape-default-opacity`: `0.7` |
