Skip to content

How can I embed a component like an c.Image in a c.Table or c.Detail? #293

Closed
@jimkring

Description

@jimkring

I have a use case where I'd like to display images inside of table cells. Is there some Image or other base class I can use for my image data and add this as a field of my model (that I pass to c.Table or c.Detail)?

# I have an image as base64 encoded `image_data`.

# I can create an image component and use this in a `components=[]` list of a c.Div or similar.
my_image = c.Image(src=f"data:image/png;base64,{image_data}")

# I want to be able to have class where one of the fields is an image
class MyType(BaseModel):
    image: c.Image

# this didn't work
my_object1 = MyType(image = my_image)
detail1 = c.Details(data=my_object1)

# this didn't work either
my_object2 = MyType(image = f"data:image/png;base64,{image_data}")
detail2 = c.Details(data=my_object2)

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions