Skip to content
Likable Aurora @likable-hair/svelte 5

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.

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

src/lib/components/composed/dashboard/DashboardWidgetShape.svelte · Markdown for LLMs

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.

1 × 1 2 × 1 2 × 2 4 × 2 6 × 1 1 × 3 larger
Code
<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

NameTypeDefaultDescription
width requirednumberWidth in columns.
height requirednumberHeight in rows.
title stringAccessible 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 variableDefault
--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