Skip to content

Allow passing 'style' prop to UnpicImageProps / Image component #822

@thevuong

Description

@thevuong

Is your feature request related to a problem? Please describe.
Currently, the UnpicImageProps type omits the style prop (React.CSSProperties), so TypeScript does not allow passing a style prop to the Image component, even though at runtime the image component forwards all other props to the underlying <img /> element. This leads to friction for users who want to pass inline styles, as they either have to use className only or cast style via as any, weakening type safety.

Describe the solution you'd like
Please consider allowing the style prop (style?: React.CSSProperties) in UnpicImageProps so that TypeScript users can pass custom styles to the Image component. This aligns with standard expectations for React image components, and does not break runtime behavior, only improves the developer experience.

If there is a specific reason for omitting style from the type definition, please document it clearly in the README or relevant docs.

Describe alternatives you've considered

  • Using only className and external CSS (not always desirable, especially for dynamic styles).
  • Type casting with as any to bypass TS error (not ideal and weakens type safety).
  • Creating a wrapper component to reintroduce style (boilerplate, should not be needed for common use cases).

Additional context
Many users expect to be able to use the style prop with React components. Supporting this natively improves the developer experience and aligns with React conventions.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions