Image
A responsive image component with fallback support and various fitting options.
Usage
Image Props
Prop | Type | Default |
---|---|---|
src | string | - |
alt | string | - |
fit | "contain" | "cover" | "fill" | cover |
radius | "none" | "small" | "medium" | "full" | - |
fallback | string | - |
width | string | number | - |
height | string | number | - |
className | string | - |
Examples
Object Fit
Control how the image fills its container with different object-fit modes.
Border Radius
Choose from different border radius styles to match your design.
Fallback
Handle image loading failures gracefully with fallback images.
Styling
The IconButton uses CSS variables for consistent styling across themes:
- Background color uses
--rs-color-background-base-primary
- Border color uses
--rs-color-border-base-primary
- Text color uses
--rs-color-foreground-base-primary
- Hover state uses
--rs-color-background-base-primary-hover
- Disabled state uses reduced opacity and different background/border colors
Accessibility
The IconButton component inherits all the accessibility features of the native HTML button element:
- Keyboard navigation support
- Proper disabled state handling
- Can be focused and activated using keyboard
- Supports all standard button ARIA attributes
For better accessibility, make sure to:
- Provide meaningful aria-label when the button's purpose isn't clear from the icon alone
- Consider adding tooltips for icon-only buttons
Accessibility
The Image component follows accessibility best practices:
ARIA Attributes
role="img"
: Explicitly defines the image role for assistive technologiesaria-label
: Provides description matching alt text for screen readersalt
: Required alternative text description for screen readers
Performance
loading="lazy"
: Default lazy loading for better performancedecoding="async"
: Asynchronous image decoding to prevent blocking- Fallback support for failed image loads