Yes! It is possible with first-class modules:
type iconProps = {
size?: int,
color?: string,
strokeWidth?: int,
absoluteStrokeWidth?: bool,
className?: string,
}
module type Icon = {
let make: React.component<iconProps>
}
module Check: Icon = {
@module("lucide-react")
external make: React.component<iconProps> = "Check"
}
module IconButton = {
@react.component
let make = (~icon: module(Icon)) => {
module Icon = unpack(icon)
<button>
<Icon size={16} color="white" />
</button>
}
}
let _ = <IconButton icon={module(Check)} />
It’s one of the features that still lacks documentation: Document First Class Modules · Issue #155 · rescript-lang/rescript-lang.org · GitHub
EDIT: Updated it to a full example.