Icon

A flexible icon component that supports Phosphor icons and custom SVG paths.

Anatomy

<script>
  import { Icon } from "@saas-ui/svelte/components/icon";
  import Heart from "phosphor-svelte/lib/Heart";
</script>

<Icon as={Heart} size="lg" colour="pink" weight="fill" />

<!-- Or with custom SVG -->
<Icon viewBox="0 0 24 24" size="md">
  <path d="M12 2L15 8H9L12 2Z" fill="currentColor" />
</Icon>

Examples

Basic Accessibility

Basic icon using a Phosphor icon.

Colours Accessibility

Use the colour prop to change the icon colour.

Custom S V G Accessibility

Create custom icons by passing SVG paths as children.

Sizes Accessibility

Use the size prop to change the icon size.

Weights Accessibility

Use the weight prop to change the icon weight (Phosphor icons). Available weights: thin, light, regular, bold, fill, duotone.

Props

Prop Type Default Description
as any - The icon component to render (e.g. from phosphor-svelte or custom).
size xs | sm | md | lg | xl | 2xl md The size of the icon.
weight thin | light | regular | bold | fill | duotone regular The weight/style of the icon (for Phosphor icons).
mirrored boolean false Whether to flip the icon horizontally (for Phosphor icons).
colour accent | gray | zinc | neutral | stone | slate | red | orange | amber | yellow | lime | green | emerald | teal | cyan | sky | blue | indigo | violet | purple | fuchsia | pink | rose currentColor The colour theme of the icon.
viewBox text 0 0 24 24 The SVG viewBox attribute (for custom icons).
style text - Inline CSS styles to apply to the icon.
children any - SVG path elements for custom icons (if `as` is not provided).
class text - Additional CSS classes to apply to the icon.