Image
An <img> with Wave fit, shape, shadow and border options.
alt is required: a description of the image, or alt="" for a decorative image. Without it screen readers may announce the file name, so JavaScript code that leaves it out gets a development warning.
Examples
Default
export const Default: Story = {
args: {
src: placeholder(200, 200),
alt: 'Placeholder image',
width: 200,
height: 200,
},
};Circular
export const Circular: Story = {
args: {
src: placeholder(150, 150),
alt: 'Circular image',
shape: 'circular',
width: 150,
height: 150,
},
};Rounded
export const Rounded: Story = {
args: {
alt: 'Rounded image',
shape: 'rounded',
},
};With Shadow
export const WithShadow: Story = {
args: {
alt: 'Image with shadow',
shadow: true,
},
};Bordered
export const Bordered: Story = {
args: {
alt: 'Image with border',
bordered: true,
},
};Decorative
export const Decorative: Story = {
args: {
alt: '',
},
};Block
export const Block: Story = {
args: {
src: placeholder(600, 200),
alt: 'Block image',
block: true,
width: 600,
height: 200,
},
};Fit Modes
export const FitModes: Story = {
args: {
src: placeholder(200, 100),
width: 100,
height: 100,
},
render: (args) => (
<div className="flex gap-4">
{(['none', 'center', 'contain', 'cover', 'default'] as const).map((fit) => (
<figure key={fit} className="m-0 flex flex-col items-center gap-1">
<div className="size-[100px] border border-wave-border">
<Image {...args} alt={`Fit ${fit}`} fit={fit} />
</div>
<figcaption className="text-wave-caption-1 text-wave-foreground">{fit}</figcaption>
</figure>
))}
</div>
),
};Props
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
alt | string | Yes | Text alternative of the image, required. Describe what the image shows, or pass | |
fit | 'none' | 'center' | 'contain' | 'cover' | 'default' | No | 'default' | How the image fits its box: |
shape | 'circular' | 'square' | 'rounded' | No | 'square' | Shape of the image border radius. |
shadow | boolean | No | false | Whether to apply a shadow to the image. |
block | boolean | No | false | Whether the image is displayed as a block element filling the width of its parent. Otherwise it is inline and never wider than its parent. With the default |
bordered | boolean | No | false | Whether to show a border around the image. |
ref | React.Ref<HTMLImageElement> | No | Ref to the |
Any other prop is passed to the element it renders (HTMLImageElement).
Stable class names
| Part | Class |
|---|---|
root | wave-image |